# avani-maurya/janmitra architecture

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

- Interactive diagram: https://gitdiagram.com/avani-maurya/janmitra
- Repository: https://github.com/avani-maurya/janmitra

## Overview

JanMitra is a citizen-assistance platform for government-scheme discovery, civic reporting, chat, and voice assistance. A citizen enters through the routed frontend pages; the documented capabilities are represented there, while the sampled backend shows concrete recommendation and chat API flows. Recommendation requests are validated and evaluated against stored schemes and eligibility rules; chat requests are handled by a service that manages conversation context and scheme matching. The frontend-to-backend links and voice/chat integration are not shown in the excerpts, so those relationships are dashed. The civic-report backend implementation is not evident in the sampled tree.

Main entry points: [`frontend/src/App.jsx`](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/App.jsx) (Page router), [`backend/app/services/recommendation_service.py`](https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/recommendation_service.py) (Scheme recommender), [`backend/app/routes/chatbot_routes.py`](https://github.com/avani-maurya/janmitra/blob/main/backend/app/routes/chatbot_routes.py) (Chat and NLP API), [`backend/app/services/chatbot_service.py`](https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/chatbot_service.py) (Chat orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Citizen interface"]
  node_app["Page router<br/>[App.jsx]"]
  node_home["Home<br/>[Home.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_schemes["Scheme browser<br/>[Schemes.jsx]"]
  node_scheme_detail["Scheme details<br/>[SchemeDetails.jsx]"]
  node_assistant["Chat assistant<br/>[Assistant.jsx]"]
  node_voice["Voice assistant<br/>[VoiceAssistant.jsx]"]
  node_civic["Civic reporting<br/>[CivicReport.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
end

subgraph group_api["Backend API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_recommend_route["Recommendation API"]
  node_chat_route["Chat and NLP API<br/>[chatbot_routes.py]"]
end

subgraph group_services["Domain services"]
  node_recommend["Scheme recommender"]
  node_eligibility["Eligibility evaluator"]
  node_user_model["Citizen profile<br/>[user.py]"]
  node_rule_model["Eligibility rule"]
  node_chat_service["Chat orchestration<br/>[chatbot_service.py]"]
end

subgraph group_data["Persistence"]
  node_scheme_repo["Scheme repository"]
  node_rule_repo["Rule repository<br/>[rule_repository.py]"]
  node_mongo_conn["Mongo connection<br/>[connection.py]"]
end

node_citizen(("Citizen"))
node_mongo[("MongoDB")]
node_gemini["Gemini service"]

node_citizen -->|"opens"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_schemes
node_app -->|"routes to"| node_scheme_detail
node_app -->|"routes to"| node_assistant
node_app -->|"routes to"| node_voice
node_app -->|"routes to"| node_civic
node_assistant -.->|"sends chat"| node_chat_route
node_voice -.->|"submits transcript"| node_chat_route
node_schemes -.->|"requests matches"| node_recommend_route
node_civic -.->|"may analyze text"| node_chat_route
node_api_app -->|"mounts"| node_recommend_route
node_api_app -->|"mounts"| node_chat_route
node_api_app -->|"configures scheme loader"| node_scheme_repo
node_recommend_route -->|"calls"| node_recommend
node_recommend_route -->|"validates input"| node_user_model
node_recommend -->|"loads schemes"| node_scheme_repo
node_recommend -->|"loads rules"| node_rule_repo
node_recommend -->|"evaluates rules"| node_eligibility
node_recommend -->|"parses rule"| node_rule_model
node_eligibility -->|"reads profile"| node_user_model
node_chat_route -->|"dispatches"| node_chat_service
node_chat_service -->|"loads scheme context"| node_scheme_repo
node_scheme_repo -->|"uses connection"| node_mongo_conn
node_mongo_conn -->|"connects"| node_mongo
node_chat_service -.->|"stores conversations"| node_mongo
node_chat_service -.->|"optionally generates replies"| node_gemini

click node_app "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Home.jsx"
click node_login "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Login.jsx"
click node_dashboard "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Dashboard.jsx"
click node_schemes "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Schemes.jsx"
click node_scheme_detail "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/SchemeDetails.jsx"
click node_assistant "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Assistant.jsx"
click node_voice "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/VoiceAssistant.jsx"
click node_civic "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/CivicReport.jsx"
click node_navbar "https://github.com/avani-maurya/janmitra/blob/main/frontend/src/components/Navbar.jsx"
click node_api_app "https://github.com/avani-maurya/janmitra/blob/main/backend/app/main.py"
click node_recommend_route "https://github.com/avani-maurya/janmitra/blob/main/backend/app/routes/recommendation_routes.py"
click node_chat_route "https://github.com/avani-maurya/janmitra/blob/main/backend/app/routes/chatbot_routes.py"
click node_recommend "https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/recommendation_service.py"
click node_eligibility "https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/eligibility_service.py"
click node_user_model "https://github.com/avani-maurya/janmitra/blob/main/backend/app/models/user.py"
click node_rule_model "https://github.com/avani-maurya/janmitra/blob/main/backend/app/models/eligibility_rule.py"
click node_chat_service "https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/chatbot_service.py"
click node_scheme_repo "https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/scheme_repository.py"
click node_rule_repo "https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/rule_repository.py"
click node_mongo_conn "https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/connection.py"

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_app,node_home,node_login,node_dashboard,node_schemes,node_scheme_detail,node_assistant,node_voice,node_civic,node_navbar toneBlue
class node_api_app,node_recommend_route,node_chat_route,node_mongo toneAmber
class node_recommend,node_eligibility,node_user_model,node_rule_model,node_chat_service toneMint
class node_scheme_repo,node_rule_repo,node_mongo_conn toneRose
class node_citizen,node_gemini toneIndigo
```

## Components

### Citizen interface

- [Page router](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Home](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Login](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Dashboard](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Scheme browser](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Schemes.jsx): `frontend/src/pages/Schemes.jsx`
- [Scheme details](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/SchemeDetails.jsx): `frontend/src/pages/SchemeDetails.jsx`
- [Chat assistant](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/Assistant.jsx): `frontend/src/pages/Assistant.jsx`
- [Voice assistant](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/VoiceAssistant.jsx): `frontend/src/pages/VoiceAssistant.jsx`
- [Civic reporting](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/pages/CivicReport.jsx): `frontend/src/pages/CivicReport.jsx`
- [Navigation](https://github.com/avani-maurya/janmitra/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`

### Backend API

- [FastAPI app](https://github.com/avani-maurya/janmitra/blob/main/backend/app/main.py): `backend/app/main.py`
- [Recommendation API](https://github.com/avani-maurya/janmitra/blob/main/backend/app/routes/recommendation_routes.py): `backend/app/routes/recommendation_routes.py`
- [Chat and NLP API](https://github.com/avani-maurya/janmitra/blob/main/backend/app/routes/chatbot_routes.py): `backend/app/routes/chatbot_routes.py`

### Domain services

- [Scheme recommender](https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/recommendation_service.py): `backend/app/services/recommendation_service.py`
- [Eligibility evaluator](https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/eligibility_service.py): `backend/app/services/eligibility_service.py`
- [Citizen profile](https://github.com/avani-maurya/janmitra/blob/main/backend/app/models/user.py): `backend/app/models/user.py`
- [Eligibility rule](https://github.com/avani-maurya/janmitra/blob/main/backend/app/models/eligibility_rule.py): `backend/app/models/eligibility_rule.py`
- [Chat orchestration](https://github.com/avani-maurya/janmitra/blob/main/backend/app/services/chatbot_service.py): `backend/app/services/chatbot_service.py`

### Persistence

- [Scheme repository](https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/scheme_repository.py): `backend/app/database/scheme_repository.py`
- [Rule repository](https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/rule_repository.py): `backend/app/database/rule_repository.py`
- [Mongo connection](https://github.com/avani-maurya/janmitra/blob/main/backend/app/database/connection.py): `backend/app/database/connection.py`

### Other components

- **Citizen**
- **MongoDB**
- **Gemini service**

## Connections

- Citizen → Page router: opens (evidence: `frontend/src/App.jsx`)
- Page router → Home: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Login: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Scheme browser: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Scheme details: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Chat assistant: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Voice assistant: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Civic reporting: routes to (evidence: `frontend/src/App.jsx`)
- Chat assistant → Chat and NLP API: sends chat
- Voice assistant → Chat and NLP API: submits transcript
- Scheme browser → Recommendation API: requests matches
- Civic reporting → Chat and NLP API: may analyze text
- FastAPI app → Recommendation API: mounts (evidence: `backend/app/main.py`)
- FastAPI app → Chat and NLP API: mounts (evidence: `backend/app/main.py`)
- FastAPI app → Scheme repository: configures scheme loader (evidence: `backend/app/main.py`)
- Recommendation API → Scheme recommender: calls (evidence: `backend/app/routes/recommendation_routes.py`)
- Recommendation API → Citizen profile: validates input (evidence: `backend/app/routes/recommendation_routes.py`)
- Scheme recommender → Scheme repository: loads schemes (evidence: `backend/app/services/recommendation_service.py`)
- Scheme recommender → Rule repository: loads rules (evidence: `backend/app/services/recommendation_service.py`)
- Scheme recommender → Eligibility evaluator: evaluates rules (evidence: `backend/app/services/recommendation_service.py`)
- Scheme recommender → Eligibility rule: parses rule (evidence: `backend/app/services/recommendation_service.py`)
- Eligibility evaluator → Citizen profile: reads profile (evidence: `backend/app/services/eligibility_service.py`)
- Chat and NLP API → Chat orchestration: dispatches (evidence: `backend/app/routes/chatbot_routes.py`)
- Chat orchestration → Scheme repository: loads scheme context (evidence: `backend/app/main.py`)
- Scheme repository → Mongo connection: uses connection (evidence: `backend/app/database/scheme_repository.py`)
- Mongo connection → MongoDB: connects (evidence: `backend/app/database/connection.py`)
- Chat orchestration → MongoDB: stores conversations
- Chat orchestration → Gemini service: optionally generates replies
