How kalradev/bid-intelligence works
Project Type and Purpose
• This is a full-stack web application for intelligent RFP (Request for Proposal) management and analysis.
• Frontend: React + TypeScript SPA (bootstrapped with Vite), multiple pages (Upload, Analysis, Bid Management, etc.).
• Backend: Node.js + Express API server with controllers, middleware, and service modules (document extraction, OpenAI integration).
• Key features: file upload, document text extraction, AI-powered analysis via OpenAI, results presentation.
File Structure Analysis
• Top level:
• Backend/
– server.js (Express entry point)
– routes/rfpRoutes.js (defines REST endpoints)
– controllers/rfpController.js (orchestrates request handling)
– middleware/ (error handling, file upload)
– services/ (documentExtractor, openaiService)
– .env.example (configuration for DB, OpenAI keys)
• Frontend/
– public/index.html
– src/ (React components, pages, context, assets, types)
– vite.config.ts, tsconfig*.json (build and compiler configs)
– pages/ (LandingPage, UploadPage, AnalysisPage, etc.)
– context/AnalysisContext.tsx (state management)
– data/mockAnalysisData.ts (stubbed data for development)
a. Frontend Layer
• Browser / User Interface (React SPA)
• Components & Pages connect via React Router
• State & Context (AnalysisContext)
b. Backend Layer
• API Gateway (Express server)
• Authentication & Middleware (uploadMiddleware, errorHandler)
• Controller Layer (rfpController)
• Service Layer
• documentExtractor (parses uploaded files)
• openaiService (calls OpenAI API for analysis)
• Data Storage (Database for RFP records, analysis results)
• File Storage (local disk or S3 for uploaded documents)
c. External Services
• OpenAI API
• (Optional) Cloud Storage (AWS S3 or equivalent)
• (Optional) Authentication provider / OAuth
Relationships and Data Flow
1. User uploads document via Frontend UploadPage.
2. Frontend sends HTTP POST (/api/rfp/upload) with file payload.
3. Express uploadMiddleware stores file; routes to rfpController.upload.
4. rfpController invokes documentExtractor → extracts text/content.
5. Extracted text passed to openaiService → calls OpenAI API.
6. AI analysis result saved to Database (and/or sent back immediately).
7. Frontend polls or receives result → renders on AnalysisPage and other pages.
8. Frontend navigates through BidManagement, CostEstimation, etc., using stored analysis.
Architectural Patterns and Principles
• Layered architecture: separate concerns (API layer, controllers, services, data).
• Modular services: each service has single responsibility (extraction, AI call).
• Middleware pattern in Express for cross-cutting concerns (error handling, uploads).
• Component-based UI and context API in React for state management.
• Configuration via environment variables (.env).
• Annotations noting key environment variables, config files, and tech stack (Vite, React, Express, Node.js, OpenAI).