# sarfarazahemad9205/classora architecture

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

- Interactive diagram: https://gitdiagram.com/sarfarazahemad9205/classora
- Repository: https://github.com/sarfarazahemad9205/classora

## Overview

Classora is a learning-resource platform: learners register and verify accounts, browse subjects and chapters, then access chapter materials; administrators manage the catalog and track visits. The React app routes users through these screens and shares authentication state, while Express routes requests to controllers that operate on MongoDB models. PDF resources additionally use Cloudinary. The README documents OTP email delivery; wiring for that and several unsampled controllers is represented only where the tree supports a subsystem, so uncertain internal calls are omitted.

Main entry points: [`client/src/App.jsx`](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/App.jsx) (App routing), [`server/index.js`](https://github.com/sarfarazahemad9205/classora/blob/main/server/index.js) (Express API), [`server/routes/material.js`](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/material.js) (Material routes), [`server/controllers/material.js`](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/material.js) (Material operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_account_pages["Account screens<br/>[Login.jsx]"]
  node_verify_page["OTP verification<br/>[Verify.jsx]"]
  node_subject_page["Subject browser<br/>[Subjects.jsx]"]
  node_chapter_page["Chapter browser<br/>[Chapters.jsx]"]
  node_materials_page["Materials viewer<br/>[Materials.jsx]"]
  node_admin_page["Admin console<br/>[Admin.jsx]"]
end

subgraph group_identity["Accounts and access"]
  node_user_routes["Account routes<br/>[user.js]"]
  node_user_controller["Account operations<br/>[user.js]"]
  node_user_model[("User records<br/>[user.js]")]
  node_mail_service["OTP email<br/>[sendMail.js]"]
  node_auth_middleware["JWT authentication<br/>[auth.js]"]
  node_admin_middleware["Admin authorization<br/>[admin.js]"]
end

subgraph group_catalog["Learning catalog"]
  node_subject_routes["Subject routes<br/>[subject.js]"]
  node_subject_controller["Subject operations<br/>[subject.js]"]
  node_subject_model[("Subject records<br/>[subject.js]")]
  node_chapter_routes["Chapter routes<br/>[chapter.js]"]
  node_chapter_controller["Chapter operations<br/>[chapter.js]"]
  node_chapter_model[("Chapter records<br/>[chapter.js]")]
end

subgraph group_resources["Learning materials"]
  node_material_routes["Material routes<br/>[material.js]"]
  node_material_controller["Material operations<br/>[material.js]"]
  node_material_model[("Material records<br/>[material.js]")]
  node_cloudinary["Cloudinary files<br/>[cloudinary.js]"]
end

subgraph group_platform["Persistence and metrics"]
  node_stats_routes["Visit routes<br/>[stats.js]"]
  node_stats_controller["Visit tracking<br/>[stats.js]"]
  node_stats_model[("Visit records<br/>[stats.js]")]
  node_server["Express API<br/>[index.js]"]
  node_database[("MongoDB connection<br/>[db.js]")]
end

node_learner(("Learner"))
node_administrator(("Administrator"))

node_learner -->|"uses"| node_app
node_administrator -->|"uses"| node_app
node_app -->|"routes"| node_account_pages
node_app -->|"routes"| node_verify_page
node_app -->|"routes"| node_subject_page
node_app -->|"routes"| node_chapter_page
node_app -->|"routes"| node_materials_page
node_app -->|"routes"| node_admin_page
node_app -->|"records visits"| node_stats_routes
node_account_pages -->|"uses auth"| node_auth_context
node_verify_page -->|"uses auth"| node_auth_context
node_auth_context -->|"requests account API"| node_user_routes
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_subject_routes
node_server -->|"mounts"| node_chapter_routes
node_server -->|"mounts"| node_material_routes
node_server -->|"mounts"| node_stats_routes
node_server -->|"connects"| node_database
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"checks tokens"| node_auth_middleware
node_user_controller -->|"reads and writes"| node_user_model
node_subject_page -->|"requests subjects"| node_subject_routes
node_subject_routes -->|"dispatches"| node_subject_controller
node_subject_controller -->|"reads and writes"| node_subject_model
node_chapter_page -->|"requests chapters"| node_chapter_routes
node_chapter_routes -->|"dispatches"| node_chapter_controller
node_chapter_controller -->|"reads and writes"| node_chapter_model
node_admin_page -->|"creates chapters"| node_chapter_routes
node_materials_page -->|"requests materials"| node_material_routes
node_admin_page -->|"manages materials"| node_material_routes
node_material_routes -->|"checks tokens"| node_auth_middleware
node_material_routes -->|"checks role"| node_admin_middleware
node_material_routes -->|"dispatches"| node_material_controller
node_material_controller -->|"reads and writes"| node_material_model
node_material_controller -->|"checks chapter"| node_chapter_model
node_material_controller -.->|"uploads or deletes PDFs"| node_cloudinary
node_stats_routes -->|"dispatches"| node_stats_controller
node_stats_controller -->|"records visits"| node_stats_model
node_user_controller -.->|"sends OTP email"| node_mail_service

click node_app "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/App.jsx"
click node_auth_context "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/context/AuthContext.jsx"
click node_account_pages "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Login.jsx"
click node_verify_page "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Verify.jsx"
click node_subject_page "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Subjects.jsx"
click node_chapter_page "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Chapters.jsx"
click node_materials_page "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Materials.jsx"
click node_admin_page "https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Admin.jsx"
click node_user_routes "https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/user.js"
click node_user_controller "https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/user.js"
click node_user_model "https://github.com/sarfarazahemad9205/classora/blob/main/server/models/user.js"
click node_mail_service "https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/sendMail.js"
click node_subject_routes "https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/subject.js"
click node_subject_controller "https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/subject.js"
click node_subject_model "https://github.com/sarfarazahemad9205/classora/blob/main/server/models/subject.js"
click node_chapter_routes "https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/chapter.js"
click node_chapter_controller "https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/chapter.js"
click node_chapter_model "https://github.com/sarfarazahemad9205/classora/blob/main/server/models/chapter.js"
click node_material_routes "https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/material.js"
click node_material_controller "https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/material.js"
click node_material_model "https://github.com/sarfarazahemad9205/classora/blob/main/server/models/material.js"
click node_cloudinary "https://github.com/sarfarazahemad9205/classora/blob/main/server/config/cloudinary.js"
click node_stats_routes "https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/stats.js"
click node_stats_controller "https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/stats.js"
click node_stats_model "https://github.com/sarfarazahemad9205/classora/blob/main/server/models/stats.js"
click node_server "https://github.com/sarfarazahemad9205/classora/blob/main/server/index.js"
click node_database "https://github.com/sarfarazahemad9205/classora/blob/main/server/database/db.js"
click node_auth_middleware "https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/auth.js"
click node_admin_middleware "https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/admin.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_auth_context,node_account_pages,node_verify_page,node_subject_page,node_chapter_page,node_materials_page,node_admin_page toneBlue
class node_user_routes,node_user_controller,node_user_model,node_mail_service,node_auth_middleware,node_admin_middleware toneAmber
class node_subject_routes,node_subject_controller,node_subject_model,node_chapter_routes,node_chapter_controller,node_chapter_model toneMint
class node_material_routes,node_material_controller,node_material_model,node_cloudinary toneRose
class node_stats_routes,node_stats_controller,node_stats_model,node_server,node_database,node_learner,node_administrator toneIndigo
```

## Components

### Web experience

- [App routing](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth state](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Account screens](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [OTP verification](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Verify.jsx): `client/src/pages/Verify.jsx`
- [Subject browser](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Subjects.jsx): `client/src/pages/Subjects.jsx`
- [Chapter browser](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Chapters.jsx): `client/src/pages/Chapters.jsx`
- [Materials viewer](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Materials.jsx): `client/src/pages/Materials.jsx`
- [Admin console](https://github.com/sarfarazahemad9205/classora/blob/main/client/src/pages/Admin.jsx): `client/src/pages/Admin.jsx`

### Accounts and access

- [Account routes](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/user.js): `server/routes/user.js`
- [Account operations](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/user.js): `server/controllers/user.js`
- [User records](https://github.com/sarfarazahemad9205/classora/blob/main/server/models/user.js): `server/models/user.js`
- [OTP email](https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/sendMail.js): `server/middlewares/sendMail.js`
- [JWT authentication](https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/auth.js): `server/middlewares/auth.js`
- [Admin authorization](https://github.com/sarfarazahemad9205/classora/blob/main/server/middlewares/admin.js): `server/middlewares/admin.js`

### Learning catalog

- [Subject routes](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/subject.js): `server/routes/subject.js`
- [Subject operations](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/subject.js): `server/controllers/subject.js`
- [Subject records](https://github.com/sarfarazahemad9205/classora/blob/main/server/models/subject.js): `server/models/subject.js`
- [Chapter routes](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/chapter.js): `server/routes/chapter.js`
- [Chapter operations](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/chapter.js): `server/controllers/chapter.js`
- [Chapter records](https://github.com/sarfarazahemad9205/classora/blob/main/server/models/chapter.js): `server/models/chapter.js`

### Learning materials

- [Material routes](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/material.js): `server/routes/material.js`
- [Material operations](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/material.js): `server/controllers/material.js`
- [Material records](https://github.com/sarfarazahemad9205/classora/blob/main/server/models/material.js): `server/models/material.js`
- [Cloudinary files](https://github.com/sarfarazahemad9205/classora/blob/main/server/config/cloudinary.js): `server/config/cloudinary.js`

### Persistence and metrics

- [Visit routes](https://github.com/sarfarazahemad9205/classora/blob/main/server/routes/stats.js): `server/routes/stats.js`
- [Visit tracking](https://github.com/sarfarazahemad9205/classora/blob/main/server/controllers/stats.js): `server/controllers/stats.js`
- [Visit records](https://github.com/sarfarazahemad9205/classora/blob/main/server/models/stats.js): `server/models/stats.js`
- [Express API](https://github.com/sarfarazahemad9205/classora/blob/main/server/index.js): `server/index.js`
- [MongoDB connection](https://github.com/sarfarazahemad9205/classora/blob/main/server/database/db.js): `server/database/db.js`

### Other components

- **Learner**
- **Administrator**

## Connections

- Learner → App routing: uses
- Administrator → App routing: uses
- App routing → Account screens: routes
- App routing → OTP verification: routes
- App routing → Subject browser: routes
- App routing → Chapter browser: routes
- App routing → Materials viewer: routes
- App routing → Admin console: routes
- App routing → Visit routes: records visits
- Account screens → Auth state: uses auth
- OTP verification → Auth state: uses auth
- Auth state → Account routes: requests account API
- Express API → Account routes: mounts
- Express API → Subject routes: mounts
- Express API → Chapter routes: mounts
- Express API → Material routes: mounts
- Express API → Visit routes: mounts
- Express API → MongoDB connection: connects
- Account routes → Account operations: dispatches
- Account routes → JWT authentication: checks tokens
- Account operations → User records: reads and writes
- Subject browser → Subject routes: requests subjects
- Subject routes → Subject operations: dispatches
- Subject operations → Subject records: reads and writes
- Chapter browser → Chapter routes: requests chapters
- Chapter routes → Chapter operations: dispatches
- Chapter operations → Chapter records: reads and writes
- Admin console → Chapter routes: creates chapters
- Materials viewer → Material routes: requests materials
- Admin console → Material routes: manages materials
- Material routes → JWT authentication: checks tokens
- Material routes → Admin authorization: checks role
- Material routes → Material operations: dispatches
- Material operations → Material records: reads and writes
- Material operations → Chapter records: checks chapter
- Material operations → Cloudinary files: uploads or deletes PDFs
- Visit routes → Visit tracking: dispatches
- Visit tracking → Visit records: records visits
- Account operations → OTP email: sends OTP email
