# alok-codes21/integrated-gdg architecture

> Architecture diagram of the GitHub repository alok-codes21/integrated-gdg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alok-codes21/integrated-gdg
- Repository: https://github.com/alok-codes21/integrated-gdg

## Overview

Integrated Sahayak AI is a citizen-welfare discovery and entitlement-matching platform, delivered through a guided React experience and a separate multi-screen portal. Citizens provide profile details, authenticate when needed, and request scheme matches; the API evaluates eligibility and returns results. The product also supports profile storage, scheme search, AI-assisted profile conversations, document text scanning, and portal journeys for life events and application preparation. The README documents several API capabilities whose route wiring was not included in the sampled source, so those links are limited to documented responsibilities.

Main entry points: [`backend/server/app.js`](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/app.js) (Express API), [`ml-portal/src/pages`](https://github.com/alok-codes21/integrated-gdg/tree/main/ml-portal/src/pages) (Portal journeys), [`frontend/src/App.jsx`](https://github.com/alok-codes21/integrated-gdg/blob/main/frontend/src/App.jsx) (Guided discovery), [`backend/server/services/matchingService.js`](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/matchingService.js) (Eligibility rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Citizen interfaces"]
  node_guided_app["Guided discovery<br/>[App.jsx]"]
  node_portal["Welfare portal<br/>[App.jsx]"]
  node_portal_pages["Portal journeys"]
  node_applications["Application tracking<br/>[applications.js]"]
end

subgraph group_api["API and identity"]
  node_api_server["Express API<br/>[app.js]"]
  node_auth["Authentication<br/>[authService.js]"]
  node_portal_auth["Portal auth client<br/>[authService.js]"]
  node_portal_api["Portal API client<br/>[api.js]"]
end

subgraph group_intelligence["Eligibility intelligence"]
  node_matching["Eligibility rules<br/>[matchingService.js]"]
  node_scheme_search["Scheme retrieval<br/>[ragService.js]"]
  node_profile_ai["Profile extraction<br/>[aiService.js]"]
  node_assistant["AI assistant"]
  node_gemini["Gemini service<br/>[geminiService.js]"]
  node_ocr["Document text scan<br/>[ocrService.js]"]
  node_portal_matching["Portal matching<br/>[matchingEngine.js]"]
end

subgraph group_citizen_data["Citizen data"]
  node_profile_model["Profile model<br/>[Profile.js]"]
  node_user_model["User model<br/>[User.js]"]
  node_mongo[("MongoDB")]
end

node_citizen(("Citizen"))
node_speech_api["Browser speech APIs"]

node_citizen -->|"provides profile"| node_guided_app
node_guided_app -->|"requests matches"| node_api_server
node_api_server -->|"evaluates eligibility"| node_matching
node_matching -->|"returns match results"| node_api_server
node_guided_app -->|"authenticates and saves"| node_api_server
node_api_server -->|"checks credentials"| node_auth
node_api_server -->|"reads and writes users"| node_user_model
node_api_server -->|"reads and writes profiles"| node_profile_model
node_user_model -->|"persists"| node_mongo
node_profile_model -->|"persists"| node_mongo
node_api_server -->|"searches schemes"| node_scheme_search
node_scheme_search -->|"reads scheme catalog"| node_matching
node_api_server -->|"extracts profile"| node_profile_ai
node_api_server -->|"answers questions"| node_assistant
node_assistant -.->|"uses AI provider"| node_gemini
node_api_server -->|"scans document text"| node_ocr
node_citizen -->|"uses portal"| node_portal
node_portal -->|"routes to journeys"| node_portal_pages
node_portal_pages -->|"requests portal data"| node_portal_api
node_portal_pages -->|"authenticates"| node_portal_auth
node_portal_auth -->|"calls API"| node_portal_api
node_portal_pages -->|"evaluates schemes"| node_portal_matching
node_portal_pages -->|"shows tracker data"| node_applications
node_citizen -.->|"speaks or listens"| node_speech_api
node_guided_app -.->|"uses speech features"| node_speech_api

click node_guided_app "https://github.com/alok-codes21/integrated-gdg/blob/main/frontend/src/App.jsx"
click node_portal "https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/App.jsx"
click node_portal_pages "https://github.com/alok-codes21/integrated-gdg/tree/main/ml-portal/src/pages"
click node_api_server "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/app.js"
click node_auth "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/authService.js"
click node_profile_model "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/models/Profile.js"
click node_user_model "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/models/User.js"
click node_matching "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/matchingService.js"
click node_scheme_search "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/ragService.js"
click node_profile_ai "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/aiService.js"
click node_assistant "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/assistantService.js"
click node_gemini "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/geminiService.js"
click node_ocr "https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/ocrService.js"
click node_portal_matching "https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/matchingEngine.js"
click node_portal_auth "https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/authService.js"
click node_portal_api "https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/api.js"
click node_applications "https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/data/applications.js"

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_guided_app,node_portal,node_portal_pages,node_applications,node_speech_api toneBlue
class node_api_server,node_auth,node_portal_auth,node_portal_api toneAmber
class node_matching,node_scheme_search,node_profile_ai,node_assistant,node_gemini,node_ocr,node_portal_matching toneMint
class node_profile_model,node_user_model,node_mongo toneRose
class node_citizen toneIndigo
```

## Components

### Citizen interfaces

- [Guided discovery](https://github.com/alok-codes21/integrated-gdg/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Welfare portal](https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/App.jsx): `ml-portal/src/App.jsx`
- [Portal journeys](https://github.com/alok-codes21/integrated-gdg/tree/main/ml-portal/src/pages): `ml-portal/src/pages`
- [Application tracking](https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/data/applications.js): `ml-portal/src/data/applications.js`

### API and identity

- [Express API](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/app.js): `backend/server/app.js`
- [Authentication](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/authService.js): `backend/server/services/authService.js`
- [Portal auth client](https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/authService.js): `ml-portal/src/services/authService.js`
- [Portal API client](https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/api.js): `ml-portal/src/services/api.js`

### Eligibility intelligence

- [Eligibility rules](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/matchingService.js): `backend/server/services/matchingService.js`
- [Scheme retrieval](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/ragService.js): `backend/server/services/ragService.js`
- [Profile extraction](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/aiService.js): `backend/server/services/aiService.js`
- [AI assistant](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/assistantService.js): `backend/server/services/assistantService.js`
- [Gemini service](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/geminiService.js): `backend/server/services/geminiService.js`
- [Document text scan](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/services/ocrService.js): `backend/server/services/ocrService.js`
- [Portal matching](https://github.com/alok-codes21/integrated-gdg/blob/main/ml-portal/src/services/matchingEngine.js): `ml-portal/src/services/matchingEngine.js`

### Citizen data

- [Profile model](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/models/Profile.js): `backend/server/models/Profile.js`
- [User model](https://github.com/alok-codes21/integrated-gdg/blob/main/backend/server/models/User.js): `backend/server/models/User.js`
- **MongoDB**

### Other components

- **Citizen**
- **Browser speech APIs**

## Connections

- Citizen → Guided discovery: provides profile
- Guided discovery → Express API: requests matches
- Express API → Eligibility rules: evaluates eligibility
- Eligibility rules → Express API: returns match results
- Guided discovery → Express API: authenticates and saves
- Express API → Authentication: checks credentials
- Express API → User model: reads and writes users
- Express API → Profile model: reads and writes profiles
- User model → MongoDB: persists
- Profile model → MongoDB: persists
- Express API → Scheme retrieval: searches schemes
- Scheme retrieval → Eligibility rules: reads scheme catalog
- Express API → Profile extraction: extracts profile
- Express API → AI assistant: answers questions
- AI assistant → Gemini service: uses AI provider
- Express API → Document text scan: scans document text
- Citizen → Welfare portal: uses portal
- Welfare portal → Portal journeys: routes to journeys
- Portal journeys → Portal API client: requests portal data
- Portal journeys → Portal auth client: authenticates
- Portal auth client → Portal API client: calls API
- Portal journeys → Portal matching: evaluates schemes
- Portal journeys → Application tracking: shows tracker data
- Citizen → Browser speech APIs: speaks or listens
- Guided discovery → Browser speech APIs: uses speech features
