# leva-ghanavatian/edu-core-backend architecture

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

- Interactive diagram: https://gitdiagram.com/leva-ghanavatian/edu-core-backend
- Repository: https://github.com/leva-ghanavatian/edu-core-backend

## Overview

EduCore is an Express backend for an online course platform. A client request enters the versioned API, passes route-level middleware, reaches a controller, and uses resource parsers and MongoDB models to produce a response. The README documents authentication and RBAC, course lessons and enrollment with discounts, comments, notifications, contact support, uploads, and a custom parsing layer. Most route-to-controller and controller-to-model links are supported by the SOURCE INDEX; unsampled feature internals are represented at subsystem level rather than inferred in detail.

Main entry points: [`routes/v1`](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/routes/v1) (Versioned routes), [`models`](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/models) (Domain models), [`controllers/v1/session.js`](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/session.js) (Lesson management), [`controllers/v1/auth.js`](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/auth.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Versioned routes"]
  node_middleware["Request middleware"]
end

subgraph group_domain["Platform capabilities"]
  node_authctrl["Authentication<br/>[auth.js]"]
  node_coursectrl["Course management<br/>[course.js]"]
  node_sessionctrl["Lesson management<br/>[session.js]"]
  node_enrollment["Enrollment and discounts<br/>[courseUser.js]"]
  node_comments["Course comments<br/>[comment.js]"]
  node_contacts["Contact inbox<br/>[contactCont.js]"]
  node_notifications["Notifications"]
  node_catalog["Catalog and departments<br/>[departmentCont.js]"]
  node_otherfeatures["Menus and tickets"]
end

subgraph group_parsing["Data parsing"]
  node_resource_schemas["Resource schemas"]
  node_resource_parser["Resource parser<br/>[resource.js]"]
  node_compiler["Schema compiler<br/>[compile.js]"]
  node_query_parsers["Query parsers"]
  node_id_parser["ID parser<br/>[id.js]"]
end

subgraph group_storage["MongoDB persistence"]
  node_models["Domain models"]
  node_database[("MongoDB connection<br/>[database.js]")]
  node_model_init["Model initialization<br/>[index.js]"]
end

subgraph group_shared["Shared services"]
  node_auth_helpers["Token and access helpers<br/>[auth.js]"]
  node_uploads["File upload handling<br/>[upload.js]"]
  node_mailer["Email delivery<br/>[mailer.js]"]
  node_file_helpers["File cleanup<br/>[files.js]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_server -->|"installs middleware"| node_middleware
node_server -->|"initializes models"| node_model_init
node_routes -->|"attaches guards"| node_middleware
node_routes -->|"dispatches auth"| node_authctrl
node_routes -->|"dispatches courses"| node_coursectrl
node_routes -->|"dispatches lessons"| node_sessionctrl
node_routes -->|"dispatches enrollment"| node_enrollment
node_routes -->|"dispatches comments"| node_comments
node_routes -->|"dispatches contacts"| node_contacts
node_routes -->|"dispatches notifications"| node_notifications
node_routes -->|"dispatches departments"| node_catalog
node_routes -->|"dispatches features"| node_otherfeatures
node_authctrl -->|"authenticates users"| node_models
node_authctrl -->|"parses user input"| node_resource_schemas
node_authctrl -->|"parses identifiers"| node_id_parser
node_authctrl -->|"signs tokens"| node_auth_helpers
node_coursectrl -->|"manages courses"| node_models
node_coursectrl -->|"parses course data"| node_resource_schemas
node_coursectrl -->|"parses identifiers"| node_id_parser
node_coursectrl -->|"cleans files"| node_file_helpers
node_sessionctrl -->|"manages lessons"| node_models
node_sessionctrl -->|"parses lesson data"| node_resource_schemas
node_sessionctrl -->|"parses identifiers"| node_id_parser
node_sessionctrl -->|"cleans files"| node_file_helpers
node_enrollment -.->|"records enrollment"| node_models
node_comments -.->|"stores comments"| node_models
node_contacts -.->|"stores requests"| node_models
node_contacts -.->|"sends replies"| node_mailer
node_notifications -.->|"stores notifications"| node_models
node_catalog -.->|"manages catalog"| node_models
node_otherfeatures -.->|"manages records"| node_models
node_resource_schemas -->|"defines schemas"| node_resource_parser
node_resource_parser -->|"builds validators"| node_compiler
node_resource_parser -->|"builds query parsing"| node_query_parsers
node_id_parser -->|"validates IDs"| node_compiler
node_models -->|"accesses collections"| node_database
node_model_init -->|"initializes indexes"| node_models
node_middleware -->|"checks user role"| node_models
node_middleware -.->|"verifies tokens"| node_auth_helpers
node_uploads -->|"uses upload factory"| node_file_helpers
node_sessionctrl -.->|"accepts video uploads"| node_uploads

click node_server "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/server.js"
click node_routes "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/routes/v1"
click node_middleware "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/middlewares"
click node_authctrl "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/auth.js"
click node_coursectrl "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/course.js"
click node_sessionctrl "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/session.js"
click node_enrollment "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/courseUser.js"
click node_comments "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/comment.js"
click node_contacts "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/contactCont.js"
click node_notifications "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/notificationCont.js"
click node_catalog "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/departmentCont.js"
click node_otherfeatures "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/controllers/v1"
click node_resource_schemas "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/src/resources"
click node_resource_parser "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/resource.js"
click node_compiler "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/compile.js"
click node_query_parsers "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/src/parsing"
click node_id_parser "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/id.js"
click node_models "https://github.com/leva-ghanavatian/edu-core-backend/tree/main/models"
click node_database "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/configs/database.js"
click node_model_init "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/models/index.js"
click node_auth_helpers "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/auth.js"
click node_uploads "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/middlewares/upload.js"
click node_mailer "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/mailer.js"
click node_file_helpers "https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/files.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_server,node_routes,node_middleware,node_client toneBlue
class node_authctrl,node_coursectrl,node_sessionctrl,node_enrollment,node_comments,node_contacts,node_notifications,node_catalog,node_otherfeatures toneAmber
class node_resource_schemas,node_resource_parser,node_compiler,node_query_parsers,node_id_parser toneMint
class node_models,node_database,node_model_init toneRose
class node_auth_helpers,node_uploads,node_mailer,node_file_helpers toneIndigo
```

## Components

### API and access

- [Express server](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/server.js): `server.js`
- [Versioned routes](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/routes/v1): `routes/v1`
- [Request middleware](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/middlewares): `middlewares`

### Platform capabilities

- [Authentication](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/auth.js): `controllers/v1/auth.js`
- [Course management](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/course.js): `controllers/v1/course.js`
- [Lesson management](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/session.js): `controllers/v1/session.js`
- [Enrollment and discounts](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/courseUser.js): `controllers/v1/courseUser.js`
- [Course comments](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/comment.js): `controllers/v1/comment.js`
- [Contact inbox](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/contactCont.js): `controllers/v1/contactCont.js`
- [Notifications](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/notificationCont.js): `controllers/v1/notificationCont.js`
- [Catalog and departments](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/controllers/v1/departmentCont.js): `controllers/v1/departmentCont.js`
- [Menus and tickets](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/controllers/v1): `controllers/v1`

### Data parsing

- [Resource schemas](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/src/resources): `src/resources`
- [Resource parser](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/resource.js): `src/parsing/resource.js`
- [Schema compiler](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/compile.js): `src/parsing/compile.js`
- [Query parsers](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/src/parsing): `src/parsing`
- [ID parser](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/src/parsing/id.js): `src/parsing/id.js`

### MongoDB persistence

- [Domain models](https://github.com/leva-ghanavatian/edu-core-backend/tree/main/models): `models`
- [MongoDB connection](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/configs/database.js): `configs/database.js`
- [Model initialization](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/models/index.js): `models/index.js`

### Shared services

- [Token and access helpers](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/auth.js): `helpers/auth.js`
- [File upload handling](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/middlewares/upload.js): `middlewares/upload.js`
- [Email delivery](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/mailer.js): `helpers/mailer.js`
- [File cleanup](https://github.com/leva-ghanavatian/edu-core-backend/blob/main/helpers/files.js): `helpers/files.js`

### Other components

- **API client**

## Connections

- API client → Express server: sends requests
- Express server → Versioned routes: mounts routes (evidence: `server.js`)
- Express server → Request middleware: installs middleware (evidence: `server.js`)
- Express server → Model initialization: initializes models (evidence: `server.js`)
- Versioned routes → Request middleware: attaches guards (evidence: `routes/v1/auth.js`)
- Versioned routes → Authentication: dispatches auth (evidence: `routes/v1/auth.js`)
- Versioned routes → Course management: dispatches courses (evidence: `routes/v1/course.js`)
- Versioned routes → Lesson management: dispatches lessons (evidence: `routes/v1/session.js`)
- Versioned routes → Enrollment and discounts: dispatches enrollment (evidence: `routes/v1/course.js`)
- Versioned routes → Course comments: dispatches comments (evidence: `routes/v1/course.js`)
- Versioned routes → Contact inbox: dispatches contacts
- Versioned routes → Notifications: dispatches notifications
- Versioned routes → Catalog and departments: dispatches departments (evidence: `routes/v1/department.js`)
- Versioned routes → Menus and tickets: dispatches features (evidence: `routes/v1/session.js`)
- Authentication → Domain models: authenticates users (evidence: `controllers/v1/auth.js`)
- Authentication → Resource schemas: parses user input (evidence: `controllers/v1/auth.js`)
- Authentication → ID parser: parses identifiers (evidence: `controllers/v1/auth.js`)
- Authentication → Token and access helpers: signs tokens (evidence: `controllers/v1/auth.js`)
- Course management → Domain models: manages courses (evidence: `controllers/v1/course.js`)
- Course management → Resource schemas: parses course data (evidence: `controllers/v1/course.js`)
- Course management → ID parser: parses identifiers (evidence: `controllers/v1/course.js`)
- Course management → File cleanup: cleans files (evidence: `controllers/v1/course.js`)
- Lesson management → Domain models: manages lessons (evidence: `controllers/v1/session.js`)
- Lesson management → Resource schemas: parses lesson data (evidence: `controllers/v1/session.js`)
- Lesson management → ID parser: parses identifiers (evidence: `controllers/v1/session.js`)
- Lesson management → File cleanup: cleans files (evidence: `controllers/v1/session.js`)
- Enrollment and discounts → Domain models: records enrollment
- Course comments → Domain models: stores comments
- Contact inbox → Domain models: stores requests
- Contact inbox → Email delivery: sends replies
- Notifications → Domain models: stores notifications
- Catalog and departments → Domain models: manages catalog
- Menus and tickets → Domain models: manages records (evidence: `controllers/v1/session.js`)
- Resource schemas → Resource parser: defines schemas (evidence: `src/resources/course.js`)
- Resource parser → Schema compiler: builds validators (evidence: `src/parsing/resource.js`)
- Resource parser → Query parsers: builds query parsing (evidence: `src/parsing/resource.js`)
- ID parser → Schema compiler: validates IDs (evidence: `src/parsing/id.js`)
- Domain models → MongoDB connection: accesses collections (evidence: `models/Session.js`)
- Model initialization → Domain models: initializes indexes (evidence: `models/index.js`)
- Request middleware → Domain models: checks user role (evidence: `middlewares/auth.js`)
- Request middleware → Token and access helpers: verifies tokens
- File upload handling → File cleanup: uses upload factory (evidence: `middlewares/upload.js`)
- Lesson management → File upload handling: accepts video uploads
