# vigneshrajnadar/ai-tender-government-contract-intelligence-platform architecture

> Architecture diagram of the GitHub repository vigneshrajnadar/ai-tender-government-contract-intelligence-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform
- Repository: https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform

## Overview

#### Purpose and entry points
A full-stack Indian government-procurement intelligence platform: discover tenders, evaluate company fit and risk, generate proposals, and provide ML/RAG-backed market intelligence. Backend API starts at `backend/main.py`; React SPA starts at `frontend/src/main.jsx` and routes from `frontend/src/App.jsx`. `run.sh` is the likely local orchestration entry point.

#### Client application
The Vite/React frontend is a multi-page operational console. Pages call the backend through a centralized API client and retain company-profile state globally.
- `frontend/src/api/client.js`
- `frontend/src/context/CompanyContext.jsx`
- `frontend/src/pages/TenderBrowser.jsx`
- `frontend/src/pages/MultiAgent.jsx`
- `frontend/src/pages/ProposalGenerator.jsx`

#### API composition and persistence boundary
FastAPI composes domain routers under `/api`, separating tender CRUD/discovery, company data, analytics, AI workflows, and advanced intelligence. SQLAlchemy models form the persistence boundary over SQLite; tenders, companies, bid history, alerts, and notifications are shared state for downstream analysis.
- `backend/main.py`
- `backend/routers/tenders.py`
- `backend/routers/ai_analysis.py`
- `backend/routers/advanced_ai.py`
- `backend/models/models.py`
- `backend/core/database.py`

#### Tender ingestion and alert source flow
Scraping services fetch and normalize public procurement data from GeM, CPPP, NIC/state sources, then persist discovered tenders for browser, analytics, recommendations, and AI analysis. Scheduled refresh is configured at the backend application layer; manual scrape exposure is routed through tender APIs.
- `backend/services/scraper_service.py`
- `backend/routers/tenders.py`
- `backend/main.py`
- `backend/run_scraper.py`

#### RAG and LLM analysis layer
AI routers use a shared LLM service and vector retrieval service. Retrieval chunks source tender text and curated procurement knowledge, builds/searches FAISS embeddings, then supplies relevant context to OpenRouter-hosted LLMs. Knowledge is repo-managed rather than a remote document store.
- `backend/services/vector_service.py`
- `backend/services/llm_service.py`
- `backend/data/govt_rules/gfr_2017.txt`
- `backend/data/risk_cases/scope_creep_cases.txt`
- `backend/data/proposal_templates.json`

#### Multi-agent decision workflow
The orchestrator executes specialized tender-reader, eligibility, risk, competitor, proposal, and financial analyses in parallel, then produces a unified tender assessment. This is an orchestration boundary above common LLM/RAG services and below the agents API.
- `backend/agents/orchestrator.py`
- `backend/routers/agents.py`
- `backend/routers/ai_analysis.py`

#### Predictive ML and intelligence services
Persisted scikit-learn artifacts support bid optimization, competitor/department analysis, fraud/risk classification, market forecasting, and win prediction. Router endpoints invoke service layers rather than training scripts; training remains offline/rebuild-oriented.
- `backend/services/ml_service.py`
- `backend/services/advanced_ml_service.py`
- `backend/routers/ml_pipeline.py`
- `backend/ml/model_manager.py`
- `backend/ml/models/win_predictor.pkl`

#### Runtime and external dependencies
Runtime is Python/FastAPI with SQLAlchemy/SQLite, APScheduler, BeautifulSoup/httpx, FAISS, Sentence Transformers, and scikit-learn; frontend is React 18/Vite. External integration boundaries are OpenRouter LLM APIs and scraped government procurement portals. Local database artifacts exist at `backend/tender_platform.db` and repository root `tender_platform.db`.

Main entry points: [`backend/main.py`](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/main.py) (FastAPI application), [`backend/services/scraper_service.py`](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/scraper_service.py) (Procurement scraper), [`frontend/src/pages/TenderBrowser.jsx`](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/pages/TenderBrowser.jsx) (Tender, agent & proposal pages), [`backend/agents/orchestrator.py`](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/agents/orchestrator.py) (Multi-agent orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React Console"]
  node_spa["React SPA<br/>Vite/React app<br/>[main.jsx]"]
  node_app_routes["Application routes<br/>React routing<br/>[App.jsx]"]
  node_api_client["API client<br/>frontend API layer<br/>[client.js]"]
  node_company_context["Company profile state<br/>React context<br/>[CompanyContext.jsx]"]
  node_operations_pages["Tender, agent &amp; proposal pages<br/>React pages<br/>[TenderBrowser.jsx]"]
end

subgraph group_api["FastAPI Backend"]
  node_fastapi["FastAPI application<br/>API composition &amp; scheduler<br/>[main.py]"]
  node_tender_api["Tender APIs<br/>FastAPI router<br/>[tenders.py]"]
  node_ai_apis["AI intelligence APIs<br/>FastAPI routers<br/>[advanced_ai.py]"]
  node_agent_api["Agents API<br/>FastAPI router<br/>[agents.py]"]
  node_models["Domain models<br/>SQLAlchemy models<br/>[models.py]"]
  node_ml_apis["ML pipeline APIs<br/>FastAPI router<br/>[ml_pipeline.py]"]
end

subgraph group_intelligence["AI &amp; Intelligence"]
  node_orchestrator["Multi-agent orchestrator<br/>parallel decision workflow<br/>[orchestrator.py]"]
  node_rag["Vector retrieval<br/>FAISS / embeddings service<br/>[vector_service.py]"]
  node_llm["LLM service<br/>OpenRouter integration<br/>[llm_service.py]"]
  node_openrouter{{"OpenRouter LLM APIs<br/>external AI service"}}
  node_ml_services["ML intelligence services<br/>scikit-learn inference"]
  node_model_artifact["Win predictor artifact<br/>persisted scikit-learn model<br/>[win_predictor.pkl]"]
end

subgraph group_data["Data Sources &amp; Storage"]
  node_database[("Tender platform database<br/>SQLite / SQLAlchemy<br/>[tender_platform.db]")]
  node_scraper["Procurement scraper<br/>ingestion service<br/>[scraper_service.py]"]
  node_government_portals{{"Government procurement portals<br/>external data source"}}
  node_knowledge["Procurement knowledge<br/>repo-managed corpus<br/>[gfr_2017.txt]"]
end

node_spa -->|"boots"| node_app_routes
node_app_routes -->|"renders"| node_operations_pages
node_operations_pages -->|"uses"| node_company_context
node_operations_pages -->|"calls through"| node_api_client
node_api_client -->|"/api"| node_fastapi
node_fastapi -->|"mounts"| node_tender_api
node_fastapi -->|"mounts"| node_ai_apis
node_fastapi -->|"mounts"| node_agent_api
node_fastapi -->|"mounts"| node_ml_apis
node_fastapi -.->|"scheduled refresh"| node_scraper
node_tender_api -->|"manual scrape"| node_scraper
node_scraper -->|"fetches"| node_government_portals
node_scraper -->|"persists tenders"| node_models
node_models -->|"maps state"| node_database
node_ai_apis -->|"retrieves context"| node_rag
node_agent_api -->|"runs assessment"| node_orchestrator
node_orchestrator -->|"uses context"| node_rag
node_orchestrator -->|"delegates analysis"| node_llm
node_rag -->|"indexes/searches"| node_knowledge
node_llm -->|"generates via"| node_openrouter
node_ml_apis -->|"invokes"| node_ml_services
node_ml_services -->|"loads"| node_model_artifact
node_ml_services -->|"analyzes persisted data"| node_database

click node_spa "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/main.jsx"
click node_app_routes "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/api/client.js"
click node_company_context "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/context/CompanyContext.jsx"
click node_operations_pages "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/pages/TenderBrowser.jsx"
click node_fastapi "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/main.py"
click node_tender_api "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/tenders.py"
click node_ai_apis "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/advanced_ai.py"
click node_agent_api "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/agents.py"
click node_database "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/tender_platform.db"
click node_models "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/models/models.py"
click node_scraper "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/scraper_service.py"
click node_orchestrator "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/agents/orchestrator.py"
click node_rag "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/vector_service.py"
click node_knowledge "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/data/govt_rules/gfr_2017.txt"
click node_llm "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/llm_service.py"
click node_ml_apis "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/ml_pipeline.py"
click node_ml_services "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/advanced_ml_service.py"
click node_model_artifact "https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/ml/models/win_predictor.pkl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spa,node_app_routes,node_api_client,node_company_context,node_operations_pages toneBlue
class node_fastapi,node_tender_api,node_ai_apis,node_agent_api,node_models,node_ml_apis toneAmber
class node_orchestrator,node_rag,node_llm,node_openrouter,node_ml_services,node_model_artifact toneMint
class node_database,node_scraper,node_government_portals,node_knowledge toneRose
```

## Components

### React Console

- [React SPA](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/main.jsx): Vite/React app · Operational console for tender, agent, and proposal workflows. · `frontend/src/main.jsx`
- [Application routes](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/App.jsx): React routing · `frontend/src/App.jsx`
- [API client](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/api/client.js): frontend API layer · `frontend/src/api/client.js`
- [Company profile state](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/context/CompanyContext.jsx): React context · `frontend/src/context/CompanyContext.jsx`
- [Tender, agent & proposal pages](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/frontend/src/pages/TenderBrowser.jsx): React pages · `frontend/src/pages/TenderBrowser.jsx`

### FastAPI Backend

- [FastAPI application](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/main.py): API composition & scheduler · Mounts API routers and configures scheduled refresh. · `backend/main.py`
- [Tender APIs](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/tenders.py): FastAPI router · Tender CRUD, discovery, and manual scraping boundary. · `backend/routers/tenders.py`
- [AI intelligence APIs](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/advanced_ai.py): FastAPI routers · `backend/routers/advanced_ai.py`
- [Agents API](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/agents.py): FastAPI router · `backend/routers/agents.py`
- [Domain models](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/models/models.py): SQLAlchemy models · `backend/models/models.py`
- [ML pipeline APIs](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/routers/ml_pipeline.py): FastAPI router · Serves prediction and advanced intelligence workflows. · `backend/routers/ml_pipeline.py`

### AI & Intelligence

- [Multi-agent orchestrator](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/agents/orchestrator.py): parallel decision workflow · Combines specialist tender assessments into a unified result. · `backend/agents/orchestrator.py`
- [Vector retrieval](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/vector_service.py): FAISS / embeddings service · Chunks and retrieves tender and procurement knowledge context. · `backend/services/vector_service.py`
- [LLM service](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/llm_service.py): OpenRouter integration · `backend/services/llm_service.py`
- **OpenRouter LLM APIs**: external AI service
- [ML intelligence services](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/advanced_ml_service.py): scikit-learn inference · Bid, competitor, fraud, forecasting, and win analysis. · `backend/services/advanced_ml_service.py`
- [Win predictor artifact](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/ml/models/win_predictor.pkl): persisted scikit-learn model · `backend/ml/models/win_predictor.pkl`

### Data Sources & Storage

- [Tender platform database](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/tender_platform.db): SQLite / SQLAlchemy · Shared tenders, companies, bid history, alerts, and notifications. · `backend/tender_platform.db`
- [Procurement scraper](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/services/scraper_service.py): ingestion service · Fetches and normalizes public procurement tenders. · `backend/services/scraper_service.py`
- **Government procurement portals**: external data source · GeM, CPPP, NIC, and state procurement sources.
- [Procurement knowledge](https://github.com/vigneshrajnadar/ai-tender-government-contract-intelligence-platform/blob/main/backend/data/govt_rules/gfr_2017.txt): repo-managed corpus · Rules, risk cases, and proposal templates. · `backend/data/govt_rules/gfr_2017.txt`

## Connections

- React SPA → Application routes: boots
- Application routes → Tender, agent & proposal pages: renders
- Tender, agent & proposal pages → Company profile state: uses
- Tender, agent & proposal pages → API client: calls through
- API client → FastAPI application: /api
- FastAPI application → Tender APIs: mounts
- FastAPI application → AI intelligence APIs: mounts
- FastAPI application → Agents API: mounts
- FastAPI application → ML pipeline APIs: mounts
- FastAPI application → Procurement scraper: scheduled refresh
- Tender APIs → Procurement scraper: manual scrape
- Procurement scraper → Government procurement portals: fetches
- Procurement scraper → Domain models: persists tenders
- Domain models → Tender platform database: maps state
- AI intelligence APIs → Vector retrieval: retrieves context
- Agents API → Multi-agent orchestrator: runs assessment
- Multi-agent orchestrator → Vector retrieval: uses context
- Multi-agent orchestrator → LLM service: delegates analysis
- Vector retrieval → Procurement knowledge: indexes/searches
- LLM service → OpenRouter LLM APIs: generates via
- ML pipeline APIs → ML intelligence services: invokes
- ML intelligence services → Win predictor artifact: loads
- ML intelligence services → Tender platform database: analyzes persisted data
