# ashikurrafi/notehub architecture

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

- Interactive diagram: https://gitdiagram.com/ashikurrafi/notehub
- Repository: https://github.com/ashikurrafi/notehub

## Overview

NoteHub is an academic question-bank platform: students browse a department/semester/subject catalog, create and activate accounts, purchase semester access, then study questions and answers; admins maintain content, users, and payments. The graph includes the sampled React web app and Express API, plus the documented database and optional integrations. The README describes a Flutter client, but its Dart source is absent from the supplied tree, so its internals are not mapped. Relationships among unsampled modules are included only where the README or SOURCE INDEX supports them.

Main entry points: [`client/src/App.jsx`](https://github.com/ashikurrafi/notehub/blob/main/client/src/App.jsx) (Web application), [`server/src/controllers/adminController.js`](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/adminController.js) (Admin controller), [`server/src/routes/index.js`](https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/index.js) (API routes), [`server/src/controllers/catalogController.js`](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/catalogController.js) (Catalog controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web client"]
  node_webapp["Web application<br/>[App.jsx]"]
  node_authpages["Account pages"]
  node_catalogpages["Catalog pages"]
  node_studycontent["Study content views<br/>[QuestionDetail.jsx]"]
  node_paymentpage["Payment page<br/>[PaymentPage.jsx]"]
  node_profilepage["Profile page<br/>[ProfilePage.jsx]"]
  node_adminpages["Admin pages"]
  node_apiclient["API client<br/>[apiClient.js]"]
end

subgraph group_server["API server"]
  node_api["Express API<br/>[app.js]"]
  node_routes["API routes<br/>[index.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_catalogroutes["Catalog routes<br/>[catalogRoutes.js]"]
  node_adminroutes["Admin routes<br/>[adminRoutes.js]"]
  node_authcontroller["Account controller<br/>[authController.js]"]
  node_authmodels[("Account and device models<br/>[userModel.js]")]
end

subgraph group_content["Catalog and access"]
  node_catalogcontroller["Catalog controller"]
  node_catalogcache["Catalog cache<br/>[catalogCache.js]"]
  node_markdown["Answer rendering<br/>[markdownRender.js]"]
  node_contentmodels[("Catalog and study models")]
end

subgraph group_operations["Payments and admin"]
  node_admincontroller["Admin controller<br/>[adminController.js]"]
  node_paymentcontroller["Payment controller"]
  node_paymentmodels[("Payment models<br/>[paymentModel.js]")]
  node_invoice["Semester receipts"]
end

node_student(("Student"))
node_administrator(("Administrator"))
node_database[("MongoDB")]
node_redis[("Redis")]
node_cloudinary["Cloudinary"]
node_email["SMTP email"]

node_student -->|"uses"| node_webapp
node_administrator -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_authpages
node_webapp -->|"routes to"| node_catalogpages
node_webapp -->|"routes to"| node_studycontent
node_webapp -->|"routes to"| node_paymentpage
node_webapp -->|"routes to"| node_profilepage
node_webapp -->|"routes to"| node_adminpages
node_webapp -.->|"calls API"| node_apiclient
node_apiclient -->|"sends requests"| node_api
node_api -->|"mounts"| node_routes
node_routes -.->|"registers"| node_authroutes
node_routes -.->|"registers"| node_catalogroutes
node_routes -.->|"registers"| node_adminroutes
node_authroutes -->|"dispatches to"| node_authcontroller
node_catalogroutes -->|"dispatches to"| node_catalogcontroller
node_adminroutes -->|"dispatches to"| node_admincontroller
node_authcontroller -->|"reads and writes"| node_authmodels
node_authcontroller -->|"sends OTP"| node_email
node_catalogcontroller -->|"reads and writes"| node_contentmodels
node_catalogcontroller -->|"gets catalog"| node_catalogcache
node_catalogcontroller -->|"enriches answers"| node_markdown
node_admincontroller -->|"manages content"| node_contentmodels
node_admincontroller -->|"manages users"| node_authmodels
node_admincontroller -.->|"manages payments"| node_paymentmodels
node_admincontroller -->|"invalidates"| node_catalogcache
node_admincontroller -->|"sends receipt"| node_invoice
node_paymentcontroller -->|"processes payments"| node_paymentmodels
node_paymentcontroller -.->|"issues receipt"| node_invoice
node_invoice -->|"sends receipt"| node_email
node_contentmodels -->|"persists"| node_database
node_authmodels -->|"persists"| node_database
node_paymentmodels -->|"persists"| node_database
node_catalogcache -.->|"uses optionally"| node_redis
node_markdown -.->|"uses optionally"| node_redis
node_admincontroller -.->|"uploads images"| node_cloudinary

click node_webapp "https://github.com/ashikurrafi/notehub/blob/main/client/src/App.jsx"
click node_authpages "https://github.com/ashikurrafi/notehub/tree/main/client/src/pages"
click node_catalogpages "https://github.com/ashikurrafi/notehub/tree/main/client/src/pages"
click node_studycontent "https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/QuestionDetail.jsx"
click node_paymentpage "https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/PaymentPage.jsx"
click node_profilepage "https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/ProfilePage.jsx"
click node_adminpages "https://github.com/ashikurrafi/notehub/tree/main/client/src/pages/admin"
click node_apiclient "https://github.com/ashikurrafi/notehub/blob/main/client/src/api/apiClient.js"
click node_api "https://github.com/ashikurrafi/notehub/blob/main/server/src/app.js"
click node_routes "https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/index.js"
click node_authroutes "https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/authRoutes.js"
click node_catalogroutes "https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/catalogRoutes.js"
click node_adminroutes "https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/adminRoutes.js"
click node_authcontroller "https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/authController.js"
click node_catalogcontroller "https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/catalogController.js"
click node_catalogcache "https://github.com/ashikurrafi/notehub/blob/main/server/src/service/catalogCache.js"
click node_markdown "https://github.com/ashikurrafi/notehub/blob/main/server/src/service/markdownRender.js"
click node_contentmodels "https://github.com/ashikurrafi/notehub/tree/main/server/src/models"
click node_authmodels "https://github.com/ashikurrafi/notehub/blob/main/server/src/models/userModel.js"
click node_admincontroller "https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/adminController.js"
click node_paymentcontroller "https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/paymentController.js"
click node_paymentmodels "https://github.com/ashikurrafi/notehub/blob/main/server/src/models/paymentModel.js"
click node_invoice "https://github.com/ashikurrafi/notehub/blob/main/server/src/service/semesterInvoiceService.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_webapp,node_authpages,node_catalogpages,node_studycontent,node_paymentpage,node_profilepage,node_adminpages,node_apiclient toneBlue
class node_api,node_routes,node_authroutes,node_catalogroutes,node_adminroutes,node_authcontroller,node_authmodels,node_database,node_redis toneAmber
class node_catalogcontroller,node_catalogcache,node_markdown,node_contentmodels toneMint
class node_admincontroller,node_paymentcontroller,node_paymentmodels,node_invoice toneRose
class node_student,node_administrator,node_cloudinary,node_email toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/ashikurrafi/notehub/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Account pages](https://github.com/ashikurrafi/notehub/tree/main/client/src/pages): `client/src/pages`
- [Catalog pages](https://github.com/ashikurrafi/notehub/tree/main/client/src/pages): `client/src/pages`
- [Study content views](https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/QuestionDetail.jsx): `client/src/pages/QuestionDetail.jsx`
- [Payment page](https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/PaymentPage.jsx): `client/src/pages/PaymentPage.jsx`
- [Profile page](https://github.com/ashikurrafi/notehub/blob/main/client/src/pages/ProfilePage.jsx): `client/src/pages/ProfilePage.jsx`
- [Admin pages](https://github.com/ashikurrafi/notehub/tree/main/client/src/pages/admin): `client/src/pages/admin`
- [API client](https://github.com/ashikurrafi/notehub/blob/main/client/src/api/apiClient.js): `client/src/api/apiClient.js`

### API server

- [Express API](https://github.com/ashikurrafi/notehub/blob/main/server/src/app.js): `server/src/app.js`
- [API routes](https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/index.js): `server/src/routes/index.js`
- [Auth routes](https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [Catalog routes](https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/catalogRoutes.js): `server/src/routes/catalogRoutes.js`
- [Admin routes](https://github.com/ashikurrafi/notehub/blob/main/server/src/routes/adminRoutes.js): `server/src/routes/adminRoutes.js`
- [Account controller](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [Account and device models](https://github.com/ashikurrafi/notehub/blob/main/server/src/models/userModel.js): `server/src/models/userModel.js`

### Catalog and access

- [Catalog controller](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/catalogController.js): `server/src/controllers/catalogController.js`
- [Catalog cache](https://github.com/ashikurrafi/notehub/blob/main/server/src/service/catalogCache.js): `server/src/service/catalogCache.js`
- [Answer rendering](https://github.com/ashikurrafi/notehub/blob/main/server/src/service/markdownRender.js): `server/src/service/markdownRender.js`
- [Catalog and study models](https://github.com/ashikurrafi/notehub/tree/main/server/src/models): `server/src/models`

### Payments and admin

- [Admin controller](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/adminController.js): `server/src/controllers/adminController.js`
- [Payment controller](https://github.com/ashikurrafi/notehub/blob/main/server/src/controllers/paymentController.js): `server/src/controllers/paymentController.js`
- [Payment models](https://github.com/ashikurrafi/notehub/blob/main/server/src/models/paymentModel.js): `server/src/models/paymentModel.js`
- [Semester receipts](https://github.com/ashikurrafi/notehub/blob/main/server/src/service/semesterInvoiceService.js): `server/src/service/semesterInvoiceService.js`

### Other components

- **Student**
- **Administrator**
- **MongoDB**
- **Redis**
- **Cloudinary**
- **SMTP email**

## Connections

- Student → Web application: uses (evidence: `README.md`)
- Administrator → Web application: uses (evidence: `README.md`)
- Web application → Account pages: routes to (evidence: `client/src/App.jsx`)
- Web application → Catalog pages: routes to (evidence: `client/src/App.jsx`)
- Web application → Study content views: routes to (evidence: `client/src/App.jsx`)
- Web application → Payment page: routes to (evidence: `client/src/App.jsx`)
- Web application → Profile page: routes to (evidence: `client/src/App.jsx`)
- Web application → Admin pages: routes to (evidence: `client/src/App.jsx`)
- Web application → API client: calls API
- API client → Express API: sends requests (evidence: `README.md`)
- Express API → API routes: mounts (evidence: `server/src/app.js`)
- API routes → Auth routes: registers
- API routes → Catalog routes: registers
- API routes → Admin routes: registers
- Auth routes → Account controller: dispatches to (evidence: `server/src/routes/authRoutes.js`)
- Catalog routes → Catalog controller: dispatches to (evidence: `server/src/routes/catalogRoutes.js`)
- Admin routes → Admin controller: dispatches to (evidence: `server/src/routes/adminRoutes.js`)
- Account controller → Account and device models: reads and writes (evidence: `server/src/controllers/authController.js`)
- Account controller → SMTP email: sends OTP (evidence: `server/src/controllers/authController.js`)
- Catalog controller → Catalog and study models: reads and writes (evidence: `server/src/controllers/catalogController.js`)
- Catalog controller → Catalog cache: gets catalog (evidence: `server/src/controllers/catalogController.js`)
- Catalog controller → Answer rendering: enriches answers (evidence: `server/src/controllers/catalogController.js`)
- Admin controller → Catalog and study models: manages content (evidence: `server/src/controllers/adminController.js`)
- Admin controller → Account and device models: manages users (evidence: `server/src/controllers/adminController.js`)
- Admin controller → Payment models: manages payments (evidence: `server/src/controllers/adminController.js`)
- Admin controller → Catalog cache: invalidates (evidence: `server/src/controllers/adminController.js`)
- Admin controller → Semester receipts: sends receipt (evidence: `server/src/controllers/adminController.js`)
- Payment controller → Payment models: processes payments (evidence: `server/src/controllers/paymentController.js`)
- Payment controller → Semester receipts: issues receipt (evidence: `server/src/controllers/paymentController.js`)
- Semester receipts → SMTP email: sends receipt (evidence: `server/src/service/semesterInvoiceService.js`)
- Catalog and study models → MongoDB: persists (evidence: `README.md`)
- Account and device models → MongoDB: persists (evidence: `README.md`)
- Payment models → MongoDB: persists (evidence: `README.md`)
- Catalog cache → Redis: uses optionally (evidence: `server/src/service/catalogCache.js`)
- Answer rendering → Redis: uses optionally (evidence: `server/src/service/markdownRender.js`)
- Admin controller → Cloudinary: uploads images
