# sinister815/acadex architecture

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

- Interactive diagram: https://gitdiagram.com/sinister815/acadex
- Repository: https://github.com/sinister815/acadex

## Overview

#### Purpose and Runtime Topology
A MERN platform for college students to upload, discover, discuss, bookmark, and report notes/PYQs. The React/Vite client calls a versioned Express API at `/api/v1`; the Node.js server persists domain data in MongoDB and stores uploaded files through Cloudinary. Primary runtime entry points are `client/src/main.jsx`, `client/src/App.jsx`, `server/src/server.js`, and `server/src/app.js`.

#### Client Application Shell and Navigation
The frontend is a React single-page application. Application routing and route protection are centralized in `client/src/routes/AppRoutes.jsx` and `client/src/routes/ProtectedRoute.jsx`. Public/authenticated UI boundaries use `client/src/layouts/AuthLayout.jsx` and `client/src/layouts/DashboardLayout.jsx`; the dashboard layout composes navigation from `client/src/components/layout/Navbar.jsx` and `client/src/components/layout/Sidebar.jsx`.

#### Client State and API Boundary
Client-server communication is isolated behind Axios configuration and endpoint definitions in `client/src/api/axios.js` and `client/src/api/endpoints.js`. Feature-specific service modules encapsulate API operations for notes, authentication, bookmarks, and comments, including `client/src/features/notes/notesService.js`, `client/src/features/auth/authService.js`, and `client/src/features/comments/commentsService.js`. Session and presentation state are held separately in Zustand stores: `client/src/store/authStore.js` and `client/src/store/themeStore.js`.

#### User-Facing Content Flows
Notes are the central resource: list/search, detail, upload, comment, bookmark, and report interactions are represented by `client/src/pages/notes/NotesPage.jsx`, `client/src/pages/notes/NoteDetailPage.jsx`, and `client/src/pages/notes/UploadPage.jsx`. Reusable note UI drives these flows through `client/src/components/notes/NoteCard.jsx`, `client/src/components/notes/CommentsSection.jsx`, and `client/src/components/notes/ReportNoteModal.jsx`. Dedicated pages expose saved content and user/admin functions at `client/src/pages/bookmarks/BookmarksPage.jsx`, `client/src/pages/profile/ProfilePage.jsx`, and `client/src/pages/admin/AdminPage.jsx`.

#### API Composition and Request Pipeline
Express application setup and API mounting occur in `server/src/app.js` and `server/src/routes/index.js`. Resource route modules define the HTTP boundary for auth, notes, comments, bookmarks, users, and administration, such as `server/src/routes/note.routes.js`, `server/src/routes/auth.routes.js`, and `server/src/routes/admin.routes.js`. Requests flow from routes to controllers, then services—for example `server/src/controllers/note.controller.js` to `server/src/services/note.service.js`—with validation, authentication, uploads, logging, and error normalization handled by middleware in `server/src/middleware/`.

#### Security, Identity, and Moderation
Authentication uses JWT access/refresh-token behavior, with refresh tokens in httpOnly cookies per the README. Token generation, auth business logic, and enforcement are separated across `server/src/utils/generateToken.js`, `server/src/services/auth.service.js`, and `server/src/middleware/auth.middleware.js`. Authorization-sensitive administration and reported-content handling are represented by `server/src/controllers/admin.controller.js`, `server/src/services/admin.service.js`, and persistence models `server/src/models/Report.model.js` and `server/src/models/Notification.model.js`.

#### Persistence and File Infrastructure
Mongoose models define the core document relationships for users, notes, comments, and bookmarks in `server/src/models/User.model.js`, `server/src/models/Note.model.js`, `server/src/models/Comment.model.js`, and `server/src/models/Bookmark.model.js`. MongoDB connectivity is configured in `server/src/config/db.js`. Upload requests pass through `server/src/middleware/upload.middleware.js`, then file-storage services and Cloudinary configuration in `server/src/services/upload.service.js`, `server/src/services/cloudinary.service.js`, and `server/src/config/cloudinary.js`.

Main entry points: [`client/src/routes/AppRoutes.jsx`](https://github.com/sinister815/acadex/blob/main/client/src/routes/AppRoutes.jsx) (Routes & guards), [`server/src/services/note.service.js`](https://github.com/sinister815/acadex/blob/main/server/src/services/note.service.js) (Domain services), [`server/src/app.js`](https://github.com/sinister815/acadex/blob/main/server/src/app.js) (Express app), [`server/src/middleware/auth.middleware.js`](https://github.com/sinister815/acadex/blob/main/server/src/middleware/auth.middleware.js) (Request middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_entry["Client entry<br/>React bootstrap<br/>[main.jsx]"]
  node_client_app["App shell<br/>React app<br/>[App.jsx]"]
  node_routing["Routes &amp; guards<br/>routing<br/>[AppRoutes.jsx]"]
  node_layouts["App layouts<br/>UI layout"]
  node_note_flows["Notes flows<br/>feature UI<br/>[NotesPage.jsx]"]
  node_account_admin_ui["Account &amp; admin UI<br/>feature UI<br/>[AdminPage.jsx]"]
  node_client_services["Feature services<br/>API client<br/>[notesService.js]"]
  node_http_boundary["Axios API boundary<br/>HTTP client<br/>[axios.js]"]
  node_client_state["Auth &amp; theme state<br/>Zustand stores<br/>[authStore.js]"]
end

subgraph group_api["Express API"]
  node_server_entry["Server entry<br/>Node bootstrap<br/>[server.js]"]
  node_express_app["Express app<br/>application setup<br/>[app.js]"]
  node_api_routes["API routes<br/>HTTP routes<br/>[index.js]"]
  node_controllers["Controllers<br/>request handlers<br/>[note.controller.js]"]
  node_services["Domain services<br/>business logic<br/>[note.service.js]"]
  node_request_middleware["Request middleware<br/>security &amp; validation<br/>[auth.middleware.js]"]
  node_token_auth["JWT token handling<br/>identity<br/>[generateToken.js]"]
end

subgraph group_data["Data &amp; Files"]
  node_models[("Mongoose models<br/>data models<br/>[Note.model.js]")]
  node_mongodb[("MongoDB<br/>database<br/>[db.js]")]
  node_upload_service["Upload pipeline<br/>file storage<br/>[upload.service.js]"]
  node_cloudinary[("Cloudinary<br/>file storage<br/>[cloudinary.js]")]
end

node_client_entry --> node_client_app
node_client_app --> node_routing
node_routing -->|"selects shell"| node_layouts
node_routing -->|"renders pages"| node_note_flows
node_routing -->|"renders pages"| node_account_admin_ui
node_layouts -->|"uses session"| node_client_state
node_note_flows -->|"content actions"| node_client_services
node_account_admin_ui -->|"account actions"| node_client_services
node_client_services -->|"API calls"| node_http_boundary
node_http_boundary -->|"/api/v1"| node_express_app
node_server_entry --> node_express_app
node_express_app -->|"applies"| node_request_middleware
node_express_app -->|"mounts"| node_api_routes
node_api_routes -->|"dispatches"| node_controllers
node_request_middleware -->|"auth enforcement"| node_token_auth
node_controllers -->|"delegates"| node_services
node_services -->|"reads and writes"| node_models
node_models -->|"persists documents"| node_mongodb
node_request_middleware -->|"multipart files"| node_upload_service
node_services -->|"stores note files"| node_upload_service
node_upload_service -->|"uploads"| node_cloudinary
node_services -->|"issues tokens"| node_token_auth

click node_client_entry "https://github.com/sinister815/acadex/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/sinister815/acadex/blob/main/client/src/App.jsx"
click node_routing "https://github.com/sinister815/acadex/blob/main/client/src/routes/AppRoutes.jsx"
click node_layouts "https://github.com/sinister815/acadex/blob/main/client/src/layouts/DashboardLayout.jsx"
click node_note_flows "https://github.com/sinister815/acadex/blob/main/client/src/pages/notes/NotesPage.jsx"
click node_account_admin_ui "https://github.com/sinister815/acadex/blob/main/client/src/pages/admin/AdminPage.jsx"
click node_client_services "https://github.com/sinister815/acadex/blob/main/client/src/features/notes/notesService.js"
click node_http_boundary "https://github.com/sinister815/acadex/blob/main/client/src/api/axios.js"
click node_client_state "https://github.com/sinister815/acadex/blob/main/client/src/store/authStore.js"
click node_server_entry "https://github.com/sinister815/acadex/blob/main/server/src/server.js"
click node_express_app "https://github.com/sinister815/acadex/blob/main/server/src/app.js"
click node_api_routes "https://github.com/sinister815/acadex/blob/main/server/src/routes/index.js"
click node_controllers "https://github.com/sinister815/acadex/blob/main/server/src/controllers/note.controller.js"
click node_services "https://github.com/sinister815/acadex/blob/main/server/src/services/note.service.js"
click node_request_middleware "https://github.com/sinister815/acadex/blob/main/server/src/middleware/auth.middleware.js"
click node_token_auth "https://github.com/sinister815/acadex/blob/main/server/src/utils/generateToken.js"
click node_models "https://github.com/sinister815/acadex/blob/main/server/src/models/Note.model.js"
click node_mongodb "https://github.com/sinister815/acadex/blob/main/server/src/config/db.js"
click node_upload_service "https://github.com/sinister815/acadex/blob/main/server/src/services/upload.service.js"
click node_cloudinary "https://github.com/sinister815/acadex/blob/main/server/src/config/cloudinary.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_client_entry,node_client_app,node_routing,node_layouts,node_note_flows,node_account_admin_ui,node_client_services,node_http_boundary,node_client_state toneBlue
class node_server_entry,node_express_app,node_api_routes,node_controllers,node_services,node_request_middleware,node_token_auth toneAmber
class node_models,node_mongodb,node_upload_service,node_cloudinary toneMint
```

## Components

### React Client

- [Client entry](https://github.com/sinister815/acadex/blob/main/client/src/main.jsx): React bootstrap · `client/src/main.jsx`
- [App shell](https://github.com/sinister815/acadex/blob/main/client/src/App.jsx): React app · `client/src/App.jsx`
- [Routes & guards](https://github.com/sinister815/acadex/blob/main/client/src/routes/AppRoutes.jsx): routing · Central routes and protected-route enforcement. · `client/src/routes/AppRoutes.jsx`
- [App layouts](https://github.com/sinister815/acadex/blob/main/client/src/layouts/DashboardLayout.jsx): UI layout · Auth and dashboard shells compose navigation. · `client/src/layouts/DashboardLayout.jsx`
- [Notes flows](https://github.com/sinister815/acadex/blob/main/client/src/pages/notes/NotesPage.jsx): feature UI · Browse, detail, upload, comments, bookmarks, and reports. · `client/src/pages/notes/NotesPage.jsx`
- [Account & admin UI](https://github.com/sinister815/acadex/blob/main/client/src/pages/admin/AdminPage.jsx): feature UI · `client/src/pages/admin/AdminPage.jsx`
- [Feature services](https://github.com/sinister815/acadex/blob/main/client/src/features/notes/notesService.js): API client · Notes, auth, and comments operations. · `client/src/features/notes/notesService.js`
- [Axios API boundary](https://github.com/sinister815/acadex/blob/main/client/src/api/axios.js): HTTP client · Versioned API configuration and endpoint definitions. · `client/src/api/axios.js`
- [Auth & theme state](https://github.com/sinister815/acadex/blob/main/client/src/store/authStore.js): Zustand stores · `client/src/store/authStore.js`

### Express API

- [Server entry](https://github.com/sinister815/acadex/blob/main/server/src/server.js): Node bootstrap · `server/src/server.js`
- [Express app](https://github.com/sinister815/acadex/blob/main/server/src/app.js): application setup · Configures middleware and mounts the API. · `server/src/app.js`
- [API routes](https://github.com/sinister815/acadex/blob/main/server/src/routes/index.js): HTTP routes · Versioned resource boundary for auth, notes, comments, bookmarks, users, and admin. · `server/src/routes/index.js`
- [Controllers](https://github.com/sinister815/acadex/blob/main/server/src/controllers/note.controller.js): request handlers · Translate HTTP requests into service calls. · `server/src/controllers/note.controller.js`
- [Domain services](https://github.com/sinister815/acadex/blob/main/server/src/services/note.service.js): business logic · Note, auth, and admin workflows. · `server/src/services/note.service.js`
- [Request middleware](https://github.com/sinister815/acadex/blob/main/server/src/middleware/auth.middleware.js): security & validation · Authentication, validation, logging, errors, and multipart handling. · `server/src/middleware/auth.middleware.js`
- [JWT token handling](https://github.com/sinister815/acadex/blob/main/server/src/utils/generateToken.js): identity · Access/refresh token generation and enforcement. · `server/src/utils/generateToken.js`

### Data & Files

- [Mongoose models](https://github.com/sinister815/acadex/blob/main/server/src/models/Note.model.js): data models · Users, notes, comments, bookmarks, reports, and notifications. · `server/src/models/Note.model.js`
- [MongoDB](https://github.com/sinister815/acadex/blob/main/server/src/config/db.js): database · Configured through the database connection module. · `server/src/config/db.js`
- [Upload pipeline](https://github.com/sinister815/acadex/blob/main/server/src/services/upload.service.js): file storage · Uploads files through Cloudinary-backed services. · `server/src/services/upload.service.js`
- [Cloudinary](https://github.com/sinister815/acadex/blob/main/server/src/config/cloudinary.js): file storage · `server/src/config/cloudinary.js`

## Connections

- Client entry → App shell
- App shell → Routes & guards
- Routes & guards → App layouts: selects shell
- Routes & guards → Notes flows: renders pages
- Routes & guards → Account & admin UI: renders pages
- App layouts → Auth & theme state: uses session
- Notes flows → Feature services: content actions
- Account & admin UI → Feature services: account actions
- Feature services → Axios API boundary: API calls
- Axios API boundary → Express app: /api/v1
- Server entry → Express app
- Express app → Request middleware: applies
- Express app → API routes: mounts
- API routes → Controllers: dispatches
- Request middleware → JWT token handling: auth enforcement
- Controllers → Domain services: delegates
- Domain services → Mongoose models: reads and writes
- Mongoose models → MongoDB: persists documents
- Request middleware → Upload pipeline: multipart files
- Domain services → Upload pipeline: stores note files
- Upload pipeline → Cloudinary: uploads
- Domain services → JWT token handling: issues tokens
