# ayaz-11257/lms-backend architecture

> Architecture diagram of the GitHub repository ayaz-11257/lms-backend, 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/ayaz-11257/lms-backend
- Repository: https://github.com/ayaz-11257/lms-backend

## Overview

This is an Express backend for an LMS. Its main user workflow covers registration and sign-in, course discovery and lecture access, then subscription purchase and verification for paid access. The backend also supports course and lecture management, profile/password maintenance, and administrative statistics. The graph reflects the sampled controller/model calls and app wiring; route and model files for courses, payments, and miscellaneous features exist in the tree, but their implementations were not sampled, so uncertain internal links are omitted.

Main entry points: [`app.js`](https://github.com/ayaz-11257/lms-backend/blob/main/app.js) (Express app), [`controller/payment.controller.js`](https://github.com/ayaz-11257/lms-backend/blob/main/controller/payment.controller.js) (Subscription workflows), [`controller/user.controller.js`](https://github.com/ayaz-11257/lms-backend/blob/main/controller/user.controller.js) (User workflows), [`routes/user.routes.js`](https://github.com/ayaz-11257/lms-backend/blob/main/routes/user.routes.js) (User routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry"]
  node_app["Express app<br/>[app.js]"]
  node_server["Server startup<br/>[server.js]"]
  node_user_routes["User routes<br/>[user.routes.js]"]
  node_course_routes["Course routes<br/>[course.route.js]"]
  node_payment_routes["Payment routes<br/>[payment.route.js]"]
  node_misc_routes["Misc routes"]
  node_error_handler["Error handling"]
  node_database[("MongoDB connection<br/>[dbConnection.js]")]
end

subgraph group_accounts["Accounts"]
  node_auth["Authentication<br/>[auth.middleware.js]"]
  node_user_controller["User workflows<br/>[user.controller.js]"]
  node_user_model[("User records<br/>[user.model.js]")]
  node_email["Email delivery<br/>[sendEmail.js]"]
end

subgraph group_learning["Learning content"]
  node_course_controller["Course workflows"]
  node_course_model[("Course records<br/>[course.model.js]")]
  node_media["Cloudinary media"]
end

subgraph group_billing["Subscriptions and admin"]
  node_payment_controller["Subscription workflows"]
  node_payment_model[("Payment records<br/>[payment.model.js]")]
  node_razorpay["Razorpay"]
  node_misc_controller["Contact and stats"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_user_routes
node_app -->|"mounts routes"| node_course_routes
node_app -->|"mounts routes"| node_payment_routes
node_app -->|"mounts routes"| node_misc_routes
node_app -->|"forwards errors"| node_error_handler
node_server -->|"starts"| node_app
node_server -->|"connects"| node_database
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"guards requests"| node_auth
node_user_controller -->|"reads and writes"| node_user_model
node_user_controller -->|"sends reset email"| node_email
node_user_controller -.->|"uploads avatars"| node_media
node_course_controller -->|"reads and writes"| node_course_model
node_course_controller -.->|"uploads course media"| node_media
node_payment_controller -->|"reads and updates"| node_user_model
node_payment_controller -->|"creates payment record"| node_payment_model
node_payment_controller -->|"manages subscriptions"| node_razorpay
node_payment_controller -->|"gets client"| node_server
node_misc_controller -->|"counts users"| node_user_model
node_misc_controller -->|"sends contact email"| node_email

click node_app "https://github.com/ayaz-11257/lms-backend/blob/main/app.js"
click node_server "https://github.com/ayaz-11257/lms-backend/blob/main/server.js"
click node_user_routes "https://github.com/ayaz-11257/lms-backend/blob/main/routes/user.routes.js"
click node_course_routes "https://github.com/ayaz-11257/lms-backend/blob/main/routes/course.route.js"
click node_payment_routes "https://github.com/ayaz-11257/lms-backend/blob/main/routes/payment.route.js"
click node_misc_routes "https://github.com/ayaz-11257/lms-backend/blob/main/routes/miscellaneous.route.js"
click node_auth "https://github.com/ayaz-11257/lms-backend/blob/main/middleware/auth.middleware.js"
click node_user_controller "https://github.com/ayaz-11257/lms-backend/blob/main/controller/user.controller.js"
click node_user_model "https://github.com/ayaz-11257/lms-backend/blob/main/models/user.model.js"
click node_email "https://github.com/ayaz-11257/lms-backend/blob/main/utils/sendEmail.js"
click node_course_controller "https://github.com/ayaz-11257/lms-backend/blob/main/controller/course.controller.js"
click node_course_model "https://github.com/ayaz-11257/lms-backend/blob/main/models/course.model.js"
click node_payment_controller "https://github.com/ayaz-11257/lms-backend/blob/main/controller/payment.controller.js"
click node_payment_model "https://github.com/ayaz-11257/lms-backend/blob/main/models/payment.model.js"
click node_misc_controller "https://github.com/ayaz-11257/lms-backend/blob/main/controller/miscellaneous.controller.js"
click node_error_handler "https://github.com/ayaz-11257/lms-backend/blob/main/middleware/error.middleware.js"
click node_database "https://github.com/ayaz-11257/lms-backend/blob/main/config/dbConnection.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_server,node_user_routes,node_course_routes,node_payment_routes,node_misc_routes,node_error_handler,node_database,node_client toneBlue
class node_auth,node_user_controller,node_user_model,node_email toneAmber
class node_course_controller,node_course_model,node_media toneMint
class node_payment_controller,node_payment_model,node_razorpay,node_misc_controller toneRose
```

## Components

### HTTP entry

- [Express app](https://github.com/ayaz-11257/lms-backend/blob/main/app.js): `app.js`
- [Server startup](https://github.com/ayaz-11257/lms-backend/blob/main/server.js): `server.js`
- [User routes](https://github.com/ayaz-11257/lms-backend/blob/main/routes/user.routes.js): `routes/user.routes.js`
- [Course routes](https://github.com/ayaz-11257/lms-backend/blob/main/routes/course.route.js): `routes/course.route.js`
- [Payment routes](https://github.com/ayaz-11257/lms-backend/blob/main/routes/payment.route.js): `routes/payment.route.js`
- [Misc routes](https://github.com/ayaz-11257/lms-backend/blob/main/routes/miscellaneous.route.js): `routes/miscellaneous.route.js`
- [Error handling](https://github.com/ayaz-11257/lms-backend/blob/main/middleware/error.middleware.js): `middleware/error.middleware.js`
- [MongoDB connection](https://github.com/ayaz-11257/lms-backend/blob/main/config/dbConnection.js): `config/dbConnection.js`

### Accounts

- [Authentication](https://github.com/ayaz-11257/lms-backend/blob/main/middleware/auth.middleware.js): `middleware/auth.middleware.js`
- [User workflows](https://github.com/ayaz-11257/lms-backend/blob/main/controller/user.controller.js): `controller/user.controller.js`
- [User records](https://github.com/ayaz-11257/lms-backend/blob/main/models/user.model.js): `models/user.model.js`
- [Email delivery](https://github.com/ayaz-11257/lms-backend/blob/main/utils/sendEmail.js): `utils/sendEmail.js`

### Learning content

- [Course workflows](https://github.com/ayaz-11257/lms-backend/blob/main/controller/course.controller.js): `controller/course.controller.js`
- [Course records](https://github.com/ayaz-11257/lms-backend/blob/main/models/course.model.js): `models/course.model.js`
- **Cloudinary media**

### Subscriptions and admin

- [Subscription workflows](https://github.com/ayaz-11257/lms-backend/blob/main/controller/payment.controller.js): `controller/payment.controller.js`
- [Payment records](https://github.com/ayaz-11257/lms-backend/blob/main/models/payment.model.js): `models/payment.model.js`
- **Razorpay**
- [Contact and stats](https://github.com/ayaz-11257/lms-backend/blob/main/controller/miscellaneous.controller.js): `controller/miscellaneous.controller.js`

### Other components

- **API client**

## Connections

- API client → Express app: sends requests
- Express app → User routes: mounts routes
- Express app → Course routes: mounts routes
- Express app → Payment routes: mounts routes
- Express app → Misc routes: mounts routes
- Express app → Error handling: forwards errors
- Server startup → Express app: starts
- Server startup → MongoDB connection: connects
- User routes → User workflows: dispatches
- User routes → Authentication: guards requests
- User workflows → User records: reads and writes
- User workflows → Email delivery: sends reset email
- User workflows → Cloudinary media: uploads avatars
- Course workflows → Course records: reads and writes
- Course workflows → Cloudinary media: uploads course media
- Subscription workflows → User records: reads and updates
- Subscription workflows → Payment records: creates payment record
- Subscription workflows → Razorpay: manages subscriptions
- Subscription workflows → Server startup: gets client
- Contact and stats → User records: counts users
- Contact and stats → Email delivery: sends contact email
