# shuvro86/mahabharat architecture

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

- Interactive diagram: https://gitdiagram.com/shuvro86/mahabharat
- Repository: https://github.com/shuvro86/mahabharat

## Overview

Mahabharat is a vocabulary, character, and Bhagavad Gita study application. Learners use the browser interface to authenticate, explore vocabulary and characters, practise quizzes and spaced-repetition reviews, and read or search the full Gita; results and study history are served by the Express API and backed by MongoDB or process-local memory. The map preserves documented study and content branches. Several controllers and routes are represented from the source index; their internal implementation was not fully sampled, so only indexed or explicit relationships are shown.

Main entry points: [`src/app.ts`](https://github.com/shuvro86/mahabharat/blob/main/src/app.ts) (Web app and API), [`src/middlewares/authMiddleware.ts`](https://github.com/shuvro86/mahabharat/blob/main/src/middlewares/authMiddleware.ts) (JWT authentication), [`src/models`](https://github.com/shuvro86/mahabharat/tree/main/src/models) (Study models), [`src/routes/wordRoutes.ts`](https://github.com/shuvro86/mahabharat/blob/main/src/routes/wordRoutes.ts) (Vocabulary routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App entry"]
  node_app["Web app and API<br/>[app.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth_routes["Auth routes<br/>[authRoutes.ts]"]
  node_auth["Authentication<br/>[authController.ts]"]
  node_auth_mw["JWT authentication<br/>[authMiddleware.ts]"]
  node_role_mw["Role checks<br/>[roleMiddleware.ts]"]
end

subgraph group_study["Vocabulary study"]
  node_words["Vocabulary API<br/>[wordController.ts]"]
  node_word_routes["Vocabulary routes<br/>[wordRoutes.ts]"]
  node_progress["Spaced repetition"]
  node_progress_routes["Progress routes<br/>[progressRoutes.ts]"]
  node_quiz["Quiz practice<br/>[quizController.ts]"]
  node_quiz_routes["Quiz routes<br/>[quizRoutes.ts]"]
  node_search_history["Search history"]
  node_search_routes["Search routes"]
end

subgraph group_content["Epic content"]
  node_characters["Character directory"]
  node_character_routes["Character routes<br/>[characterRoutes.ts]"]
  node_shlokas["Shloka API"]
  node_shloka_routes["Shloka routes<br/>[shlokaRoutes.ts]"]
  node_gita_api["Full Gita API<br/>[routes.ts]"]
  node_gita_page["Gita reader<br/>[page.ts]"]
  node_hall["Hall of Frame<br/>[page.ts]"]
end

subgraph group_storage["Persistence"]
  node_models["Study models"]
  node_memory[("Memory adapter<br/>[inMemoryDb.ts]")]
  node_db_config["Database setup<br/>[db.ts]"]
end

node_learner(("Learner"))
node_mongo[("MongoDB")]

node_learner -->|"uses"| node_app
node_app -->|"mounts routes"| node_auth_routes
node_app -->|"mounts routes"| node_word_routes
node_app -->|"mounts routes"| node_progress_routes
node_app -->|"mounts routes"| node_quiz_routes
node_app -->|"mounts routes"| node_search_routes
node_app -->|"mounts routes"| node_character_routes
node_app -->|"mounts routes"| node_shloka_routes
node_app -->|"mounts routes"| node_gita_api
node_app -->|"serves page"| node_gita_page
node_app -->|"renders page"| node_hall
node_auth_routes -->|"routes to"| node_auth
node_auth -->|"uses request type"| node_auth_mw
node_auth_routes -->|"authenticates"| node_auth_mw
node_word_routes -->|"routes to"| node_words
node_word_routes -->|"authenticates"| node_auth_mw
node_word_routes -->|"checks role"| node_role_mw
node_character_routes -->|"routes to"| node_characters
node_character_routes -->|"authenticates"| node_auth_mw
node_character_routes -->|"checks role"| node_role_mw
node_shloka_routes -->|"routes to"| node_shlokas
node_shloka_routes -->|"authenticates"| node_auth_mw
node_shloka_routes -->|"checks role"| node_role_mw
node_progress_routes -->|"routes to"| node_progress
node_progress_routes -->|"authenticates"| node_auth_mw
node_quiz_routes -->|"routes to"| node_quiz
node_quiz_routes -->|"authenticates"| node_auth_mw
node_search_routes -->|"routes to"| node_search_history
node_search_routes -->|"authenticates"| node_auth_mw
node_words -->|"uses vocabulary model"| node_models
node_progress -->|"reads and writes"| node_models
node_quiz -->|"reads and writes"| node_models
node_search_history -->|"uses history model"| node_models
node_characters -->|"uses character model"| node_models
node_shlokas -->|"uses shloka model"| node_models
node_auth -->|"uses user model"| node_models
node_db_config -->|"connects"| node_mongo
node_db_config -->|"fallback storage"| node_memory
node_memory -->|"patches models"| node_models
node_gita_api -.->|"serves Gita data"| node_gita_page

click node_app "https://github.com/shuvro86/mahabharat/blob/main/src/app.ts"
click node_auth_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/authRoutes.ts"
click node_auth "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/authController.ts"
click node_auth_mw "https://github.com/shuvro86/mahabharat/blob/main/src/middlewares/authMiddleware.ts"
click node_role_mw "https://github.com/shuvro86/mahabharat/blob/main/src/middlewares/roleMiddleware.ts"
click node_words "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/wordController.ts"
click node_word_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/wordRoutes.ts"
click node_progress "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/progressController.ts"
click node_progress_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/progressRoutes.ts"
click node_quiz "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/quizController.ts"
click node_quiz_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/quizRoutes.ts"
click node_search_history "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/searchHistoryController.ts"
click node_search_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/searchHistoryRoutes.ts"
click node_characters "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/characterController.ts"
click node_character_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/characterRoutes.ts"
click node_shlokas "https://github.com/shuvro86/mahabharat/blob/main/src/controllers/shlokaController.ts"
click node_shloka_routes "https://github.com/shuvro86/mahabharat/blob/main/src/routes/shlokaRoutes.ts"
click node_gita_api "https://github.com/shuvro86/mahabharat/blob/main/src/modules/fullGita/routes.ts"
click node_gita_page "https://github.com/shuvro86/mahabharat/blob/main/src/modules/fullGita/page.ts"
click node_hall "https://github.com/shuvro86/mahabharat/blob/main/src/modules/hallOfFrame/page.ts"
click node_models "https://github.com/shuvro86/mahabharat/tree/main/src/models"
click node_memory "https://github.com/shuvro86/mahabharat/blob/main/src/config/inMemoryDb.ts"
click node_db_config "https://github.com/shuvro86/mahabharat/blob/main/src/config/db.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_app toneBlue
class node_auth_routes,node_auth,node_auth_mw,node_role_mw,node_mongo toneAmber
class node_words,node_word_routes,node_progress,node_progress_routes,node_quiz,node_quiz_routes,node_search_history,node_search_routes toneMint
class node_characters,node_character_routes,node_shlokas,node_shloka_routes,node_gita_api,node_gita_page,node_hall toneRose
class node_models,node_memory,node_db_config,node_learner toneIndigo
```

## Components

### App entry

- [Web app and API](https://github.com/shuvro86/mahabharat/blob/main/src/app.ts): `src/app.ts`

### Identity and access

- [Auth routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/authRoutes.ts): `src/routes/authRoutes.ts`
- [Authentication](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/authController.ts): `src/controllers/authController.ts`
- [JWT authentication](https://github.com/shuvro86/mahabharat/blob/main/src/middlewares/authMiddleware.ts): `src/middlewares/authMiddleware.ts`
- [Role checks](https://github.com/shuvro86/mahabharat/blob/main/src/middlewares/roleMiddleware.ts): `src/middlewares/roleMiddleware.ts`

### Vocabulary study

- [Vocabulary API](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/wordController.ts): `src/controllers/wordController.ts`
- [Vocabulary routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/wordRoutes.ts): `src/routes/wordRoutes.ts`
- [Spaced repetition](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/progressController.ts): `src/controllers/progressController.ts`
- [Progress routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/progressRoutes.ts): `src/routes/progressRoutes.ts`
- [Quiz practice](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/quizController.ts): `src/controllers/quizController.ts`
- [Quiz routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/quizRoutes.ts): `src/routes/quizRoutes.ts`
- [Search history](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/searchHistoryController.ts): `src/controllers/searchHistoryController.ts`
- [Search routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/searchHistoryRoutes.ts): `src/routes/searchHistoryRoutes.ts`

### Epic content

- [Character directory](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/characterController.ts): `src/controllers/characterController.ts`
- [Character routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/characterRoutes.ts): `src/routes/characterRoutes.ts`
- [Shloka API](https://github.com/shuvro86/mahabharat/blob/main/src/controllers/shlokaController.ts): `src/controllers/shlokaController.ts`
- [Shloka routes](https://github.com/shuvro86/mahabharat/blob/main/src/routes/shlokaRoutes.ts): `src/routes/shlokaRoutes.ts`
- [Full Gita API](https://github.com/shuvro86/mahabharat/blob/main/src/modules/fullGita/routes.ts): `src/modules/fullGita/routes.ts`
- [Gita reader](https://github.com/shuvro86/mahabharat/blob/main/src/modules/fullGita/page.ts): `src/modules/fullGita/page.ts`
- [Hall of Frame](https://github.com/shuvro86/mahabharat/blob/main/src/modules/hallOfFrame/page.ts): `src/modules/hallOfFrame/page.ts`

### Persistence

- [Study models](https://github.com/shuvro86/mahabharat/tree/main/src/models): `src/models`
- [Memory adapter](https://github.com/shuvro86/mahabharat/blob/main/src/config/inMemoryDb.ts): `src/config/inMemoryDb.ts`
- [Database setup](https://github.com/shuvro86/mahabharat/blob/main/src/config/db.ts): `src/config/db.ts`

### Other components

- **Learner**
- **MongoDB**

## Connections

- Learner → Web app and API: uses (evidence: `README.md`)
- Web app and API → Auth routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Vocabulary routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Progress routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Quiz routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Search routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Character routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Shloka routes: mounts routes (evidence: `src/app.ts`)
- Web app and API → Full Gita API: mounts routes (evidence: `src/app.ts`)
- Web app and API → Gita reader: serves page (evidence: `src/app.ts`)
- Web app and API → Hall of Frame: renders page (evidence: `src/app.ts`)
- Auth routes → Authentication: routes to (evidence: `src/routes/authRoutes.ts`)
- Authentication → JWT authentication: uses request type (evidence: `src/controllers/authController.ts`)
- Auth routes → JWT authentication: authenticates (evidence: `src/routes/authRoutes.ts`)
- Vocabulary routes → Vocabulary API: routes to (evidence: `src/routes/wordRoutes.ts`)
- Vocabulary routes → JWT authentication: authenticates (evidence: `src/routes/wordRoutes.ts`)
- Vocabulary routes → Role checks: checks role (evidence: `src/routes/wordRoutes.ts`)
- Character routes → Character directory: routes to (evidence: `src/routes/characterRoutes.ts`)
- Character routes → JWT authentication: authenticates (evidence: `src/routes/characterRoutes.ts`)
- Character routes → Role checks: checks role (evidence: `src/routes/characterRoutes.ts`)
- Shloka routes → Shloka API: routes to (evidence: `src/routes/shlokaRoutes.ts`)
- Shloka routes → JWT authentication: authenticates (evidence: `src/routes/shlokaRoutes.ts`)
- Shloka routes → Role checks: checks role (evidence: `src/routes/shlokaRoutes.ts`)
- Progress routes → Spaced repetition: routes to (evidence: `src/routes/progressRoutes.ts`)
- Progress routes → JWT authentication: authenticates (evidence: `src/routes/progressRoutes.ts`)
- Quiz routes → Quiz practice: routes to (evidence: `src/routes/quizRoutes.ts`)
- Quiz routes → JWT authentication: authenticates (evidence: `src/routes/quizRoutes.ts`)
- Search routes → Search history: routes to (evidence: `src/routes/searchHistoryRoutes.ts`)
- Search routes → JWT authentication: authenticates (evidence: `src/routes/searchHistoryRoutes.ts`)
- Vocabulary API → Study models: uses vocabulary model (evidence: `src/controllers/wordController.ts`)
- Spaced repetition → Study models: reads and writes (evidence: `src/controllers/progressController.ts`)
- Quiz practice → Study models: reads and writes (evidence: `src/controllers/quizController.ts`)
- Search history → Study models: uses history model (evidence: `src/controllers/searchHistoryController.ts`)
- Character directory → Study models: uses character model (evidence: `src/controllers/characterController.ts`)
- Shloka API → Study models: uses shloka model (evidence: `src/controllers/shlokaController.ts`)
- Authentication → Study models: uses user model (evidence: `src/controllers/authController.ts`)
- Database setup → MongoDB: connects (evidence: `src/config/db.ts`)
- Database setup → Memory adapter: fallback storage (evidence: `src/config/db.ts`)
- Memory adapter → Study models: patches models (evidence: `src/config/inMemoryDb.ts`)
- Full Gita API → Gita reader: serves Gita data
