# himanshuraj108/apna_lakshay_lms architecture

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

- Interactive diagram: https://gitdiagram.com/himanshuraj108/apna_lakshay_lms
- Repository: https://github.com/himanshuraj108/apna_lakshay_lms

## Overview

Apna Lakshay is a role-based library operations and student-learning platform. Students and administrators use the React portal to access seat and shift operations, attendance, fees, requests, and learning tools; Express routes dispatch these requests to backend controllers and persistent records. Separate branches cover AI-assisted study, messaging and live updates, and external payment, media, and email integrations. The graph follows the documented architecture and sampled routes/controllers; several feature implementations were not sampled, so their internal call wiring is shown only at documented boundaries.

Main entry points: [`backend/models`](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/models) (Domain records), [`backend/server.js`](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/server.js) (Express server), [`backend/routes/studentRoutes.js`](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/studentRoutes.js) (Student API), [`backend/controllers`](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/controllers) (Library operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portal["Role-based portal"]
  node_app["React application<br/>[App.jsx]"]
  node_student_ui["Student portal"]
  node_admin_ui["Admin portal"]
  node_api_client["API client<br/>[api.js]"]
  node_socket_client["Socket.io client<br/>[useSocket.js]"]
end

subgraph group_operations["Library operations"]
  node_student_routes["Student API<br/>[studentRoutes.js]"]
  node_admin_routes["Admin API<br/>[adminRoutes.js]"]
  node_ops_logic["Library operations"]
  node_student_logic["Student services"]
end

subgraph group_learning["Learning and engagement"]
  node_chat_routes["Chat API<br/>[chatRoutes.js]"]
  node_learning_logic["Learning tools"]
  node_mock_logic["Mock test engine"]
  node_sockets["Live messaging<br/>[socketHandler.js]"]
  node_ai_service["AI service<br/>[aiService.js]"]
  node_coin_service["Rewards service<br/>[coinService.js]"]
end

subgraph group_platform["Backend platform"]
  node_server["Express server<br/>[server.js]"]
  node_auth["Access control<br/>[auth.js]"]
  node_models["Domain records"]
  node_mongo[("MongoDB")]
  node_redis[("Redis cache<br/>[redis.js]")]
end

subgraph group_integrations["External services"]
  node_email_service["Email service<br/>[emailService.js]"]
end

node_student(("Student"))
node_staff(("Admin staff"))
node_ai_provider{{"Groq API"}}
node_payment{{"Razorpay"}}
node_media{{"Cloudinary"}}
node_smtp{{"SMTP email"}}

node_student -->|"uses portal"| node_app
node_staff -->|"uses portal"| node_app
node_app -->|"routes to"| node_student_ui
node_app -->|"routes to"| node_admin_ui
node_student_ui -->|"requests data"| node_api_client
node_admin_ui -->|"requests data"| node_api_client
node_api_client -->|"HTTPS requests"| node_server
node_server -->|"mounts API"| node_student_routes
node_server -->|"mounts API"| node_admin_routes
node_server -->|"mounts API"| node_chat_routes
node_student_routes -->|"guards access"| node_auth
node_admin_routes -->|"guards access"| node_auth
node_student_routes -->|"dispatches"| node_student_logic
node_admin_routes -->|"dispatches"| node_ops_logic
node_chat_routes -->|"reads and writes"| node_models
node_student_logic -->|"reads and writes"| node_models
node_ops_logic -->|"reads and writes"| node_models
node_learning_logic -->|"reads and writes"| node_models
node_mock_logic -->|"stores attempts"| node_models
node_models -->|"persists records"| node_mongo
node_student_routes -->|"dispatches"| node_learning_logic
node_student_routes -->|"dispatches"| node_mock_logic
node_learning_logic -->|"requests generation"| node_ai_service
node_mock_logic -->|"requests questions"| node_ai_service
node_ai_service -.->|"sends prompts"| node_ai_provider
node_student_logic -->|"awards coins"| node_coin_service
node_sockets -->|"reads and writes"| node_models
node_socket_client -->|"opens WSS"| node_server
node_server -->|"initializes"| node_sockets
node_ops_logic -.->|"sends notices"| node_email_service
node_email_service -.->|"delivers email"| node_smtp
node_student_logic -.->|"creates and verifies payments"| node_payment
node_ops_logic -.->|"stores media"| node_media
node_ops_logic -->|"caches availability"| node_redis

click node_app "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/App.jsx"
click node_student_ui "https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/frontend/src/pages/student"
click node_admin_ui "https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/frontend/src/pages/admin"
click node_api_client "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/utils/api.js"
click node_server "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/server.js"
click node_auth "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/middleware/auth.js"
click node_student_routes "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/studentRoutes.js"
click node_admin_routes "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/adminRoutes.js"
click node_chat_routes "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/chatRoutes.js"
click node_ops_logic "https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/controllers"
click node_student_logic "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/controllers/studentController.js"
click node_learning_logic "https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/controllers"
click node_mock_logic "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/controllers/mockTestController.js"
click node_models "https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/models"
click node_sockets "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/sockets/socketHandler.js"
click node_ai_service "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/aiService.js"
click node_coin_service "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/coinService.js"
click node_email_service "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/emailService.js"
click node_redis "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/utils/redis.js"
click node_socket_client "https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/hooks/useSocket.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_app,node_student_ui,node_admin_ui,node_api_client,node_socket_client toneBlue
class node_student_routes,node_admin_routes,node_ops_logic,node_student_logic toneAmber
class node_chat_routes,node_learning_logic,node_mock_logic,node_sockets,node_ai_service,node_coin_service,node_ai_provider toneMint
class node_server,node_auth,node_models,node_mongo,node_redis toneRose
class node_email_service,node_student,node_staff,node_payment,node_media,node_smtp toneIndigo
```

## Components

### Role-based portal

- [React application](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Student portal](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/frontend/src/pages/student): `frontend/src/pages/student`
- [Admin portal](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [API client](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`
- [Socket.io client](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/frontend/src/hooks/useSocket.js): `frontend/src/hooks/useSocket.js`

### Library operations

- [Student API](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/studentRoutes.js): `backend/routes/studentRoutes.js`
- [Admin API](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/adminRoutes.js): `backend/routes/adminRoutes.js`
- [Library operations](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/controllers): `backend/controllers`
- [Student services](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/controllers/studentController.js): `backend/controllers/studentController.js`

### Learning and engagement

- [Chat API](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/routes/chatRoutes.js): `backend/routes/chatRoutes.js`
- [Learning tools](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/controllers): `backend/controllers`
- [Mock test engine](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/controllers/mockTestController.js): `backend/controllers/mockTestController.js`
- [Live messaging](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/sockets/socketHandler.js): `backend/sockets/socketHandler.js`
- [AI service](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/aiService.js): `backend/services/aiService.js`
- [Rewards service](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/coinService.js): `backend/services/coinService.js`

### Backend platform

- [Express server](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/server.js): `backend/server.js`
- [Access control](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Domain records](https://github.com/himanshuraj108/apna_lakshay_lms/tree/main/backend/models): `backend/models`
- **MongoDB**
- [Redis cache](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/utils/redis.js): `backend/utils/redis.js`

### External services

- [Email service](https://github.com/himanshuraj108/apna_lakshay_lms/blob/main/backend/services/emailService.js): `backend/services/emailService.js`

### Other components

- **Student**
- **Admin staff**
- **Groq API**
- **Razorpay**
- **Cloudinary**
- **SMTP email**

## Connections

- Student → React application: uses portal
- Admin staff → React application: uses portal
- React application → Student portal: routes to
- React application → Admin portal: routes to
- Student portal → API client: requests data
- Admin portal → API client: requests data
- API client → Express server: HTTPS requests
- Express server → Student API: mounts API
- Express server → Admin API: mounts API
- Express server → Chat API: mounts API
- Student API → Access control: guards access
- Admin API → Access control: guards access
- Student API → Student services: dispatches
- Admin API → Library operations: dispatches
- Chat API → Domain records: reads and writes
- Student services → Domain records: reads and writes
- Library operations → Domain records: reads and writes
- Learning tools → Domain records: reads and writes
- Mock test engine → Domain records: stores attempts
- Domain records → MongoDB: persists records
- Student API → Learning tools: dispatches
- Student API → Mock test engine: dispatches
- Learning tools → AI service: requests generation
- Mock test engine → AI service: requests questions
- AI service → Groq API: sends prompts
- Student services → Rewards service: awards coins
- Live messaging → Domain records: reads and writes
- Socket.io client → Express server: opens WSS
- Express server → Live messaging: initializes
- Library operations → Email service: sends notices
- Email service → SMTP email: delivers email
- Student services → Razorpay: creates and verifies payments
- Library operations → Cloudinary: stores media
- Library operations → Redis cache: caches availability
