# sarwpati/note-hub architecture

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

- Interactive diagram: https://gitdiagram.com/sarwpati/note-hub
- Repository: https://github.com/sarwpati/note-hub

## Overview

NoteHub is a full-stack personal notes workspace. Users register or log in, then browse, search, create, edit, pin, archive, restore, and delete their notes; settings support profile and password updates. The client routes pages and keeps session state, service modules call the Express API, and backend routes dispatch through validation and authentication to controllers and MongoDB models. The README documents capabilities beyond the sampled excerpts; those subsystems are represented at their page or directory paths, with only documented or excerpt-supported links.

Main entry points: [`client/src/App.jsx`](https://github.com/sarwpati/note-hub/blob/main/client/src/App.jsx) (Application routes), [`server/src/routes/auth.routes.js`](https://github.com/sarwpati/note-hub/blob/main/server/src/routes/auth.routes.js) (Auth routes), [`server/src/routes/note.routes.js`](https://github.com/sarwpati/note-hub/blob/main/server/src/routes/note.routes.js) (Notes routes), [`client/src/pages/DashboardPage.jsx`](https://github.com/sarwpati/note-hub/blob/main/client/src/pages/DashboardPage.jsx) (Notes dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["Application routes<br/>[App.jsx]"]
  node_authpages["Sign in and register"]
  node_dashboard["Notes dashboard<br/>[DashboardPage.jsx]"]
  node_detail["Note detail<br/>[NoteDetailPage.jsx]"]
  node_archive["Archive view<br/>[ArchivePage.jsx]"]
  node_settings["Account settings<br/>[SettingsPage.jsx]"]
  node_layout["Navigation layout"]
  node_notecard["Note cards<br/>[NoteCard.jsx]"]
end

subgraph group_clientstate["Client state and API"]
  node_authstate["Session state<br/>[AuthContext.jsx]"]
  node_confirm["Confirm dialogs<br/>[ConfirmContext.jsx]"]
  node_theme["Theme state<br/>[ThemeContext.jsx]"]
  node_authservice["Auth service<br/>[authService.js]"]
  node_noteservice["Notes service<br/>[noteService.js]"]
  node_http["HTTP client<br/>[api.js]"]
end

subgraph group_api["API and security"]
  node_serverapp["Express API<br/>[app.js]"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_noteroutes["Notes routes<br/>[note.routes.js]"]
  node_validation["Request validation"]
  node_validators["Request schemas"]
  node_protection["Session protection<br/>[auth.middleware.js]"]
end

subgraph group_domain["Domain and persistence"]
  node_authcontroller["Account operations<br/>[auth.controller.js]"]
  node_notecontroller["Note operations<br/>[note.controller.js]"]
  node_users[("User records<br/>[User.js]")]
  node_notes[("Note records<br/>[Note.js]")]
end

node_person(("User"))
node_mongodb[("MongoDB")]

node_person -->|"uses"| node_app
node_app -->|"routes"| node_authpages
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_detail
node_app -->|"routes"| node_archive
node_app -->|"routes"| node_settings
node_app -->|"provides"| node_authstate
node_app -->|"provides"| node_theme
node_authstate -->|"calls"| node_authservice
node_authservice -->|"requests"| node_http
node_dashboard -->|"requests"| node_noteservice
node_detail -->|"requests"| node_noteservice
node_archive -->|"requests"| node_noteservice
node_settings -->|"requests"| node_authservice
node_dashboard -->|"renders"| node_layout
node_dashboard -->|"renders"| node_notecard
node_archive -->|"renders"| node_layout
node_serverapp -->|"mounts"| node_authroutes
node_serverapp -->|"mounts"| node_noteroutes
node_authroutes -->|"validates"| node_validation
node_noteroutes -->|"validates"| node_validation
node_authroutes -->|"uses schemas"| node_validators
node_noteroutes -->|"uses schemas"| node_validators
node_authroutes -->|"dispatches"| node_authcontroller
node_noteroutes -->|"dispatches"| node_notecontroller
node_authroutes -->|"protects"| node_protection
node_noteroutes -->|"protects"| node_protection
node_authcontroller -->|"reads and writes"| node_users
node_notecontroller -->|"reads and writes"| node_notes
node_protection -->|"loads user"| node_users
node_users -.->|"persists"| node_mongodb
node_notes -.->|"persists"| node_mongodb
node_http -.->|"API requests"| node_serverapp

click node_app "https://github.com/sarwpati/note-hub/blob/main/client/src/App.jsx"
click node_authpages "https://github.com/sarwpati/note-hub/tree/main/client/src/pages"
click node_dashboard "https://github.com/sarwpati/note-hub/blob/main/client/src/pages/DashboardPage.jsx"
click node_detail "https://github.com/sarwpati/note-hub/blob/main/client/src/pages/NoteDetailPage.jsx"
click node_archive "https://github.com/sarwpati/note-hub/blob/main/client/src/pages/ArchivePage.jsx"
click node_settings "https://github.com/sarwpati/note-hub/blob/main/client/src/pages/SettingsPage.jsx"
click node_layout "https://github.com/sarwpati/note-hub/tree/main/client/src/components/layout"
click node_notecard "https://github.com/sarwpati/note-hub/blob/main/client/src/components/notes/NoteCard.jsx"
click node_authstate "https://github.com/sarwpati/note-hub/blob/main/client/src/context/AuthContext.jsx"
click node_confirm "https://github.com/sarwpati/note-hub/blob/main/client/src/context/ConfirmContext.jsx"
click node_theme "https://github.com/sarwpati/note-hub/blob/main/client/src/context/ThemeContext.jsx"
click node_authservice "https://github.com/sarwpati/note-hub/blob/main/client/src/services/authService.js"
click node_noteservice "https://github.com/sarwpati/note-hub/blob/main/client/src/services/noteService.js"
click node_http "https://github.com/sarwpati/note-hub/blob/main/client/src/services/api.js"
click node_serverapp "https://github.com/sarwpati/note-hub/blob/main/server/src/app.js"
click node_authroutes "https://github.com/sarwpati/note-hub/blob/main/server/src/routes/auth.routes.js"
click node_noteroutes "https://github.com/sarwpati/note-hub/blob/main/server/src/routes/note.routes.js"
click node_validation "https://github.com/sarwpati/note-hub/blob/main/server/src/middleware/validate.middleware.js"
click node_validators "https://github.com/sarwpati/note-hub/tree/main/server/src/validators"
click node_protection "https://github.com/sarwpati/note-hub/blob/main/server/src/middleware/auth.middleware.js"
click node_authcontroller "https://github.com/sarwpati/note-hub/blob/main/server/src/controllers/auth.controller.js"
click node_notecontroller "https://github.com/sarwpati/note-hub/blob/main/server/src/controllers/note.controller.js"
click node_users "https://github.com/sarwpati/note-hub/blob/main/server/src/models/User.js"
click node_notes "https://github.com/sarwpati/note-hub/blob/main/server/src/models/Note.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_authpages,node_dashboard,node_detail,node_archive,node_settings,node_layout,node_notecard,node_person toneBlue
class node_authstate,node_confirm,node_theme,node_authservice,node_noteservice,node_http,node_mongodb toneAmber
class node_serverapp,node_authroutes,node_noteroutes,node_validation,node_validators,node_protection toneMint
class node_authcontroller,node_notecontroller,node_users,node_notes toneRose
```

## Components

### Client experience

- [Application routes](https://github.com/sarwpati/note-hub/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Sign in and register](https://github.com/sarwpati/note-hub/tree/main/client/src/pages): `client/src/pages`
- [Notes dashboard](https://github.com/sarwpati/note-hub/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Note detail](https://github.com/sarwpati/note-hub/blob/main/client/src/pages/NoteDetailPage.jsx): `client/src/pages/NoteDetailPage.jsx`
- [Archive view](https://github.com/sarwpati/note-hub/blob/main/client/src/pages/ArchivePage.jsx): `client/src/pages/ArchivePage.jsx`
- [Account settings](https://github.com/sarwpati/note-hub/blob/main/client/src/pages/SettingsPage.jsx): `client/src/pages/SettingsPage.jsx`
- [Navigation layout](https://github.com/sarwpati/note-hub/tree/main/client/src/components/layout): `client/src/components/layout`
- [Note cards](https://github.com/sarwpati/note-hub/blob/main/client/src/components/notes/NoteCard.jsx): `client/src/components/notes/NoteCard.jsx`

### Client state and API

- [Session state](https://github.com/sarwpati/note-hub/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Confirm dialogs](https://github.com/sarwpati/note-hub/blob/main/client/src/context/ConfirmContext.jsx): `client/src/context/ConfirmContext.jsx`
- [Theme state](https://github.com/sarwpati/note-hub/blob/main/client/src/context/ThemeContext.jsx): `client/src/context/ThemeContext.jsx`
- [Auth service](https://github.com/sarwpati/note-hub/blob/main/client/src/services/authService.js): `client/src/services/authService.js`
- [Notes service](https://github.com/sarwpati/note-hub/blob/main/client/src/services/noteService.js): `client/src/services/noteService.js`
- [HTTP client](https://github.com/sarwpati/note-hub/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API and security

- [Express API](https://github.com/sarwpati/note-hub/blob/main/server/src/app.js): `server/src/app.js`
- [Auth routes](https://github.com/sarwpati/note-hub/blob/main/server/src/routes/auth.routes.js): `server/src/routes/auth.routes.js`
- [Notes routes](https://github.com/sarwpati/note-hub/blob/main/server/src/routes/note.routes.js): `server/src/routes/note.routes.js`
- [Request validation](https://github.com/sarwpati/note-hub/blob/main/server/src/middleware/validate.middleware.js): `server/src/middleware/validate.middleware.js`
- [Request schemas](https://github.com/sarwpati/note-hub/tree/main/server/src/validators): `server/src/validators`
- [Session protection](https://github.com/sarwpati/note-hub/blob/main/server/src/middleware/auth.middleware.js): `server/src/middleware/auth.middleware.js`

### Domain and persistence

- [Account operations](https://github.com/sarwpati/note-hub/blob/main/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [Note operations](https://github.com/sarwpati/note-hub/blob/main/server/src/controllers/note.controller.js): `server/src/controllers/note.controller.js`
- [User records](https://github.com/sarwpati/note-hub/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Note records](https://github.com/sarwpati/note-hub/blob/main/server/src/models/Note.js): `server/src/models/Note.js`

### Other components

- **User**
- **MongoDB**

## Connections

- User → Application routes: uses (evidence: `README.md`)
- Application routes → Sign in and register: routes (evidence: `client/src/App.jsx`)
- Application routes → Notes dashboard: routes (evidence: `client/src/App.jsx`)
- Application routes → Note detail: routes (evidence: `client/src/App.jsx`)
- Application routes → Archive view: routes (evidence: `client/src/App.jsx`)
- Application routes → Account settings: routes (evidence: `client/src/App.jsx`)
- Application routes → Session state: provides (evidence: `client/src/App.jsx`)
- Application routes → Theme state: provides (evidence: `client/src/App.jsx`)
- Session state → Auth service: calls (evidence: `client/src/context/AuthContext.jsx`)
- Auth service → HTTP client: requests (evidence: `client/src/services/authService.js`)
- Notes dashboard → Notes service: requests (evidence: `client/src/pages/DashboardPage.jsx`)
- Note detail → Notes service: requests (evidence: `client/src/pages/NoteDetailPage.jsx`)
- Archive view → Notes service: requests (evidence: `client/src/pages/ArchivePage.jsx`)
- Account settings → Auth service: requests (evidence: `client/src/pages/SettingsPage.jsx`)
- Notes dashboard → Navigation layout: renders (evidence: `client/src/pages/DashboardPage.jsx`)
- Notes dashboard → Note cards: renders (evidence: `client/src/pages/DashboardPage.jsx`)
- Archive view → Navigation layout: renders (evidence: `client/src/pages/ArchivePage.jsx`)
- Express API → Auth routes: mounts (evidence: `server/src/app.js`)
- Express API → Notes routes: mounts (evidence: `server/src/app.js`)
- Auth routes → Request validation: validates (evidence: `server/src/routes/auth.routes.js`)
- Notes routes → Request validation: validates (evidence: `server/src/routes/note.routes.js`)
- Auth routes → Request schemas: uses schemas (evidence: `server/src/routes/auth.routes.js`)
- Notes routes → Request schemas: uses schemas (evidence: `server/src/routes/note.routes.js`)
- Auth routes → Account operations: dispatches (evidence: `server/src/routes/auth.routes.js`)
- Notes routes → Note operations: dispatches (evidence: `server/src/routes/note.routes.js`)
- Auth routes → Session protection: protects (evidence: `server/src/routes/auth.routes.js`)
- Notes routes → Session protection: protects (evidence: `server/src/routes/note.routes.js`)
- Account operations → User records: reads and writes (evidence: `server/src/controllers/auth.controller.js`)
- Note operations → Note records: reads and writes (evidence: `server/src/controllers/note.controller.js`)
- Session protection → User records: loads user (evidence: `server/src/middleware/auth.middleware.js`)
- User records → MongoDB: persists (evidence: `README.md`)
- Note records → MongoDB: persists (evidence: `README.md`)
- HTTP client → Express API: API requests (evidence: `README.md`)
