# skygod07/sih-2026 architecture

> Architecture diagram of the GitHub repository skygod07/sih-2026, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skygod07/sih-2026
- Repository: https://github.com/skygod07/sih-2026

## Overview

Sarthi is an innovation-procurement platform: government officers discover and compare startups, simulate pilot outcomes, then manage a pilot’s milestones, evidence, payments, and audit history; startups participate through company profiles and challenge responses. The backend separates HTTP routing, deterministic procurement rules, persistence, simulation, and AI-assisted discovery/explanations. The README documents RAG retrieval and an immutable milestone ledger. Some subsystem links are documented rather than visible in sampled implementation; those are marked dashed where necessary.

Main entry points: [`backend/src/routes/index.ts`](https://github.com/skygod07/sih-2026/blob/main/backend/src/routes/index.ts) (API route registry), [`backend/src/workflow/http/workflow.routes.ts`](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/http/workflow.routes.ts) (Procurement endpoints), [`frontend/src/app/(console)`](https://github.com/skygod07/sih-2026/tree/main/frontend/src/app/(console)) (Procurement console), [`backend/src/sarthi/http/sarthi.routes.ts`](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/http/sarthi.routes.ts) (Sarthi endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_console["Procurement console"]
  node_startup_portal["Startup portal"]
  node_sarthi_client["Sarthi API client<br/>[sarthi.ts]"]
  node_workflow_client["Workflow API client<br/>[workflow.ts]"]
end

subgraph group_api["API and identity"]
  node_app["Express application<br/>[app.ts]"]
  node_routes["API route registry<br/>[index.ts]"]
  node_auth["Authentication and roles<br/>[authenticate.ts]"]
  node_auth_controller["Identity management<br/>[auth.controller.ts]"]
  node_workflow_routes["Procurement endpoints<br/>[workflow.routes.ts]"]
  node_sarthi_routes["Sarthi endpoints<br/>[sarthi.routes.ts]"]
  node_ai_routes["AI endpoints<br/>[ai.routes.ts]"]
  node_pilot_sim_routes["Pilot simulation endpoints<br/>[pilotsim.routes.ts]"]
end

subgraph group_procurement["Procurement lifecycle"]
  node_companies["Company profiles<br/>[company.service.ts]"]
  node_workflow["Challenge-to-pilot workflow"]
  node_audit["Workflow audit<br/>[audit.ts]"]
  node_ledger["Milestone ledger<br/>[ledger.service.ts]"]
end

subgraph group_intelligence["Simulation and AI"]
  node_pilot_sim["Pilot outcome simulation"]
  node_simulator["Confidence and risk"]
  node_discovery["Startup discovery"]
  node_ai_service["AI assistance<br/>[ai.service.ts]"]
  node_rag["Policy RAG retrieval<br/>[rag.service.ts]"]
end

subgraph group_data["Domain data"]
  node_corpus[("Pilot corpus")]
  node_repositories[("Procurement repositories<br/>[repositories.ts]")]
end

node_officer(("Procurement officer"))
node_startup(("Startup user"))
node_ollama["Ollama model service"]

node_officer -.->|"uses"| node_console
node_startup -.->|"uses"| node_startup_portal
node_console -.->|"requests procurement data"| node_workflow_client
node_console -.->|"requests Sarthi services"| node_sarthi_client
node_startup_portal -.->|"requests workflow"| node_workflow_client
node_app -->|"mounts API routes"| node_routes
node_routes -->|"registers"| node_workflow_routes
node_routes -->|"registers"| node_sarthi_routes
node_routes -->|"registers"| node_ai_routes
node_routes -->|"registers"| node_pilot_sim_routes
node_routes -->|"registers"| node_auth_controller
node_auth_controller -->|"requires identity"| node_auth
node_workflow_routes -->|"dispatches workflow calls"| node_workflow
node_workflow_routes -->|"dispatches company calls"| node_companies
node_workflow -->|"reads and writes"| node_repositories
node_companies -->|"reads and writes"| node_repositories
node_workflow -->|"records audit events"| node_audit
node_workflow_routes -->|"authenticates callers"| node_auth
node_sarthi_routes -.->|"dispatches ledger operations"| node_ledger
node_sarthi_routes -.->|"dispatches retrieval"| node_rag
node_ai_routes -->|"calls assistance tasks"| node_ai_service
node_ai_routes -->|"calls discovery"| node_discovery
node_pilot_sim_routes -->|"starts and queries runs"| node_pilot_sim
node_pilot_sim -.->|"uses outcome analysis"| node_simulator
node_ai_service -.->|"requests model assistance"| node_ollama
node_discovery -.->|"requests model assistance"| node_ollama
node_rag -.->|"retrieves pilot records"| node_corpus

click node_console "https://github.com/skygod07/sih-2026/tree/main/frontend/src/app/(console)"
click node_startup_portal "https://github.com/skygod07/sih-2026/tree/main/frontend/src/app/(console)/startup"
click node_sarthi_client "https://github.com/skygod07/sih-2026/blob/main/frontend/src/lib/api/sarthi.ts"
click node_workflow_client "https://github.com/skygod07/sih-2026/blob/main/frontend/src/lib/api/workflow.ts"
click node_app "https://github.com/skygod07/sih-2026/blob/main/backend/src/app.ts"
click node_routes "https://github.com/skygod07/sih-2026/blob/main/backend/src/routes/index.ts"
click node_auth "https://github.com/skygod07/sih-2026/blob/main/backend/src/auth/authenticate.ts"
click node_auth_controller "https://github.com/skygod07/sih-2026/blob/main/backend/src/auth/auth.controller.ts"
click node_workflow_routes "https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/http/workflow.routes.ts"
click node_sarthi_routes "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/http/sarthi.routes.ts"
click node_ai_routes "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/ai.routes.ts"
click node_pilot_sim_routes "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/pilotsim/pilotsim.routes.ts"
click node_companies "https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/company.service.ts"
click node_workflow "https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/workflow.service.ts"
click node_audit "https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/audit.ts"
click node_ledger "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ledger/ledger.service.ts"
click node_pilot_sim "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/pilotsim/pilotsim.service.ts"
click node_simulator "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/simulator/simulator.service.ts"
click node_discovery "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/discovery.service.ts"
click node_ai_service "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/ai.service.ts"
click node_rag "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/rag/rag.service.ts"
click node_corpus "https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/corpus/pilotCorpus.repository.ts"
click node_repositories "https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/repositories.ts"

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_console,node_startup_portal,node_sarthi_client,node_workflow_client,node_startup toneBlue
class node_app,node_routes,node_auth,node_auth_controller,node_workflow_routes,node_sarthi_routes,node_ai_routes,node_pilot_sim_routes toneAmber
class node_companies,node_workflow,node_audit,node_ledger toneMint
class node_pilot_sim,node_simulator,node_discovery,node_ai_service,node_rag toneRose
class node_corpus,node_repositories,node_officer,node_ollama toneIndigo
```

## Components

### User experience

- [Procurement console](https://github.com/skygod07/sih-2026/tree/main/frontend/src/app/(console)): `frontend/src/app/(console)`
- [Startup portal](https://github.com/skygod07/sih-2026/tree/main/frontend/src/app/(console)/startup): `frontend/src/app/(console)/startup`
- [Sarthi API client](https://github.com/skygod07/sih-2026/blob/main/frontend/src/lib/api/sarthi.ts): `frontend/src/lib/api/sarthi.ts`
- [Workflow API client](https://github.com/skygod07/sih-2026/blob/main/frontend/src/lib/api/workflow.ts): `frontend/src/lib/api/workflow.ts`

### API and identity

- [Express application](https://github.com/skygod07/sih-2026/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API route registry](https://github.com/skygod07/sih-2026/blob/main/backend/src/routes/index.ts): `backend/src/routes/index.ts`
- [Authentication and roles](https://github.com/skygod07/sih-2026/blob/main/backend/src/auth/authenticate.ts): `backend/src/auth/authenticate.ts`
- [Identity management](https://github.com/skygod07/sih-2026/blob/main/backend/src/auth/auth.controller.ts): `backend/src/auth/auth.controller.ts`
- [Procurement endpoints](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/http/workflow.routes.ts): `backend/src/workflow/http/workflow.routes.ts`
- [Sarthi endpoints](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/http/sarthi.routes.ts): `backend/src/sarthi/http/sarthi.routes.ts`
- [AI endpoints](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/ai.routes.ts): `backend/src/sarthi/ai/ai.routes.ts`
- [Pilot simulation endpoints](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/pilotsim/pilotsim.routes.ts): `backend/src/sarthi/pilotsim/pilotsim.routes.ts`

### Procurement lifecycle

- [Company profiles](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/company.service.ts): `backend/src/workflow/company.service.ts`
- [Challenge-to-pilot workflow](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/workflow.service.ts): `backend/src/workflow/workflow.service.ts`
- [Workflow audit](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/audit.ts): `backend/src/workflow/audit.ts`
- [Milestone ledger](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ledger/ledger.service.ts): `backend/src/sarthi/ledger/ledger.service.ts`

### Simulation and AI

- [Pilot outcome simulation](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/pilotsim/pilotsim.service.ts): `backend/src/sarthi/pilotsim/pilotsim.service.ts`
- [Confidence and risk](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/simulator/simulator.service.ts): `backend/src/sarthi/simulator/simulator.service.ts`
- [Startup discovery](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/discovery.service.ts): `backend/src/sarthi/ai/discovery.service.ts`
- [AI assistance](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/ai/ai.service.ts): `backend/src/sarthi/ai/ai.service.ts`
- [Policy RAG retrieval](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/rag/rag.service.ts): `backend/src/sarthi/rag/rag.service.ts`

### Domain data

- [Pilot corpus](https://github.com/skygod07/sih-2026/blob/main/backend/src/sarthi/corpus/pilotCorpus.repository.ts): `backend/src/sarthi/corpus/pilotCorpus.repository.ts`
- [Procurement repositories](https://github.com/skygod07/sih-2026/blob/main/backend/src/workflow/repositories.ts): `backend/src/workflow/repositories.ts`

### Other components

- **Procurement officer**
- **Startup user**
- **Ollama model service**

## Connections

- Procurement officer → Procurement console: uses
- Startup user → Startup portal: uses
- Procurement console → Workflow API client: requests procurement data
- Procurement console → Sarthi API client: requests Sarthi services
- Startup portal → Workflow API client: requests workflow
- Express application → API route registry: mounts API routes (evidence: `backend/src/app.ts`)
- API route registry → Procurement endpoints: registers (evidence: `backend/src/routes/index.ts`)
- API route registry → Sarthi endpoints: registers (evidence: `backend/src/routes/index.ts`)
- API route registry → AI endpoints: registers (evidence: `backend/src/routes/index.ts`)
- API route registry → Pilot simulation endpoints: registers (evidence: `backend/src/routes/index.ts`)
- API route registry → Identity management: registers (evidence: `backend/src/routes/index.ts`)
- Identity management → Authentication and roles: requires identity (evidence: `backend/src/auth/auth.routes.ts`)
- Procurement endpoints → Challenge-to-pilot workflow: dispatches workflow calls (evidence: `backend/src/workflow/http/workflow.routes.ts`)
- Procurement endpoints → Company profiles: dispatches company calls (evidence: `backend/src/workflow/http/workflow.routes.ts`)
- Challenge-to-pilot workflow → Procurement repositories: reads and writes (evidence: `backend/src/workflow/workflow.service.ts`)
- Company profiles → Procurement repositories: reads and writes (evidence: `backend/src/workflow/company.service.ts`)
- Challenge-to-pilot workflow → Workflow audit: records audit events (evidence: `backend/src/workflow/workflow.service.ts`)
- Procurement endpoints → Authentication and roles: authenticates callers (evidence: `backend/src/workflow/http/workflow.routes.ts`)
- Sarthi endpoints → Milestone ledger: dispatches ledger operations
- Sarthi endpoints → Policy RAG retrieval: dispatches retrieval
- AI endpoints → AI assistance: calls assistance tasks (evidence: `backend/src/sarthi/ai/ai.routes.ts`)
- AI endpoints → Startup discovery: calls discovery (evidence: `backend/src/sarthi/ai/ai.routes.ts`)
- Pilot simulation endpoints → Pilot outcome simulation: starts and queries runs (evidence: `backend/src/sarthi/pilotsim/pilotsim.routes.ts`)
- Pilot outcome simulation → Confidence and risk: uses outcome analysis
- AI assistance → Ollama model service: requests model assistance
- Startup discovery → Ollama model service: requests model assistance
- Policy RAG retrieval → Pilot corpus: retrieves pilot records
