Recon is a data intelligence platform designed to scrape, analyze, and manage public procurement data. It provides a web interface for searching, filtering, and managing solicitations, as well as an AI-powered chat assistant for interacting with the data.
The project is a full-stack Next.js application with a sophisticated architecture that includes a web scraper, a backend API, a frontend application, and an AI-powered chat assistant.
The frontend is a Next.js application located in the app directory. It uses:
- React for building the user interface.
- Tailwind CSS and Shadcn UI for styling and UI components.
- CSS Modules for component-level styling.
The backend is composed of several components:
- Next.js API Routes: The
app/apidirectory contains the backend API routes that handle requests from the frontend. - Firebase Functions: The
functionsdirectory contains a separate Node.js project for Firebase Cloud Functions. These functions are used for backend tasks, including scheduled jobs and serverless web scraping with Playwright. - Scraping Scripts: The
scriptsdirectory contains standalone web scraping scripts that can be executed manually.
- Firestore: The primary database for storing scraped solicitation data.
- Algolia: Used for providing advanced search capabilities.
- Hyperbrowser: An AI-powered web scraping agent that uses a large language model (GPT-4) to understand natural language commands and automate browser actions. This makes the scrapers more flexible and easier to maintain.
- Genkit: A framework for building AI-powered features, used here for the chat assistant and other AI tasks.
The application is deployed on Google Cloud:
- Firebase Hosting: The frontend is served by Firebase Hosting at https://reconrfp.cendien.com.
- Cloud Run: The Next.js backend is a Cloud Run service named
recon, managed by Firebase App Hosting. - Project ID: The Google Cloud project ID is
rfpscraper-dc3d8.
-
Install dependencies:
pnpm i
-
Set up environment variables: Create a
.envfile in the root of the project and populate it with the necessary environment variables. You can use the.env.examplefile as a template. -
Run the development server:
pnpm run serve
The application will be available at http://localhost:3000.
The project uses Firebase Functions to automate several backend processes:
- Scheduled Scraping: A daily scheduled function in
functions/src/schedulers/daily.tstriggers the web scraping process for a list of vendors every weekday at 11 PM (America/Chicago time). This function uses Playwright to run the scraping tasks in a serverless environment. - Firestore Triggers: The project uses Firestore triggers to automatically perform actions in response to database events. For example, the
functions/src/firestore/makeUppercase.tstrigger automatically converts a field to uppercase when a new document is created in a specific collection.
The project integrates with Browserbase through the @hyperbrowser/agent library, which is an AI-powered web scraping agent. The scraping scripts in the scripts/scrapers directory use this agent to scrape data from various websites.
The agent is initialized in the scripts/utils.ts file, where it is configured to use a local browser and the GPT-4 language model. The scrapers then use natural language prompts to instruct the agent to perform scraping tasks, such as navigating to a specific URL, extracting data from a table, and paginating through results.
The project uses a number of environment variables to configure the application for different environments. These variables are stored in a .env file in the root of the project.
BIDDIRECT_USERBIDDIRECT_PASSCOOKIE_KEYCOOKIE_SECRET_CURRENTCOOKIE_SECRET_PREVIOUSELASTIC_NODEELASTIC_API_KEYFIREBASE_PROJECT_IDFIREBASE_CLIENT_EMAILFIREBASE_API_KEYFIREBASE_PRIVATE_KEYFIREBASE_STORAGE_BUCKETGEMINI_KEYHYPERBROWSER_API_KEYOPENAI_API_KEYPUBLICPURCHASE_USERPUBLICPURCHASE_PASSVENDORREGISTRY_USERVENDORREGISTRY_PASS
NEXT_PUBLIC_ELASTIC_API_KEYNEXT_PUBLIC_FIREBASE_API_KEYNEXT_PUBLIC_FIREBASE_AUTH_DOMAINNEXT_PUBLIC_FIREBASE_PROJECT_IDNEXT_PUBLIC_FIREBASE_BUCKETNEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_IDNEXT_PUBLIC_FIREBASE_APP_IDNEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
The following scraper scripts are located in the scripts/scrapers directory:
biddirect.tsinstantmarkets.tspublicpurchase.tsvendorregistry.ts
- AI-Powered Scraping: The use of Hyperbrowser for natural language-based scraping is a major strength, making the scrapers more flexible and easier to maintain.
- Modern Tech Stack: The project uses a modern and powerful tech stack (Next.js, Firebase, Algolia, Genkit).
- Clean Architecture: The separation of concerns between the frontend, backend, and scraping scripts is well-done.
- Good Security Practices: The use of Google Secret Manager for storing API keys is a good security practice.
- AI Chat Assistant: The AI-powered chat assistant is a powerful feature for interacting with the data.
- Code Duplication: There is significant code duplication in the data models (
app/models.ts,app/models2.ts,app/models2Server.ts,functions/src/models.ts,functions/src/models2.ts). The model definitions should be consolidated into a single source of truth. - Lack of Testing: There is no automated testing suite in the project. Adding unit tests, integration tests, and end-to-end tests would significantly improve the code quality and reduce the risk of regressions.
- Error Handling: While there is some error handling, it could be more robust and consistent across the application.
- Hardcoded Values: Some parts of the code, especially the scraper scripts, contain hardcoded values that should be moved to configuration files to improve maintainability.
- Outdated
README.md: The previousREADME.mdwas outdated and inaccurate. This file has been updated to reflect the current state of the project. - Scraper Breakage: The web scrapers are dependent on the structure of external websites. They are prone to breaking if the websites change. This is an inherent risk with web scraping, but it's important to be aware of it.