# iamakashtechie/nexus architecture

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

- Interactive diagram: https://gitdiagram.com/iamakashtechie/nexus
- Repository: https://github.com/iamakashtechie/nexus

## Overview

Nexus is a private, self-hosted knowledge base. Users authenticate, then create, organize, search, edit, and export notes through the notes workspace. The main editing stage supports Markdown and rich text, with linked-note, outline, diagram, and formatting features. API routes validate requests and operate on Prisma-backed PostgreSQL; authentication and route protection form a separate security branch. The README documents PWA support and export formats, but some feature wiring is unsampled, so those links are marked unverified.

Main entry points: [`src/lib/db.ts`](https://github.com/iamakashtechie/nexus/blob/main/src/lib/db.ts) (Prisma Client), [`src/app/(app)/notes/page.tsx`](https://github.com/iamakashtechie/nexus/blob/main/src/app/(app)/notes/page.tsx) (Notes Workspace), [`src/app/api/notes`](https://github.com/iamakashtechie/nexus/tree/main/src/app/api/notes) (Notes Endpoints), [`src/app/api/notes/download/route.ts`](https://github.com/iamakashtechie/nexus/blob/main/src/app/api/notes/download/route.ts) (Export Endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_security["Authentication"]
  node_login["Login Page<br/>[page.tsx]"]
  node_auth_route["Login Endpoint<br/>[route.ts]"]
  node_auth_lib["JWT Auth<br/>[auth.ts]"]
  node_rate_limit["Login Rate Limit<br/>[rateLimiter.ts]"]
  node_proxy["Route Protection<br/>[proxy.ts]"]
end

subgraph group_workspace["Notes Workspace"]
  node_notes_page["Notes Workspace<br/>[page.tsx]"]
  node_notes_hook["Note State<br/>[useNotes.ts]"]
  node_notebooks_hook["Notebook State<br/>[useNotebooks.ts]"]
  node_note_editor["Note Editor<br/>[NoteEditor.tsx]"]
  node_rich_editor["Rich Editor<br/>[Editor.tsx]"]
  node_editor_features["Editor Features"]
  node_sidebar["Note Sidebar<br/>[Sidebar.tsx]"]
  node_pwa["PWA Support<br/>[sw.js]"]
end

subgraph group_api["Application API"]
  node_api_client["API Client<br/>[useApi.ts]"]
  node_notes_api["Notes Endpoints"]
  node_notebooks_api["Notebook Endpoints"]
  node_tags_api["Tag Endpoint<br/>[route.ts]"]
  node_backlinks_api["Backlink Endpoint<br/>[route.ts]"]
  node_exports["Export Endpoints<br/>[route.ts]"]
end

subgraph group_persistence["Persistence"]
  node_validation["Request Validation<br/>[validations.ts]"]
  node_file_types["File Type Handling<br/>[fileType.ts]"]
  node_backup["Backup Formatting<br/>[backup.ts]"]
  node_zip["ZIP Packaging<br/>[zip.ts]"]
  node_db_client["Prisma Client<br/>[db.ts]"]
end

node_user(("User"))
node_database[("Neon PostgreSQL")]

node_user -->|"opens"| node_login
node_login -.->|"submits credentials"| node_auth_route
node_auth_route -->|"checks attempts"| node_rate_limit
node_auth_route -->|"signs token"| node_auth_lib
node_proxy -->|"verifies token"| node_auth_lib
node_user -->|"uses workspace"| node_notes_page
node_notes_page -->|"manages notes"| node_notes_hook
node_notes_page -->|"manages notebooks"| node_notebooks_hook
node_notes_page -->|"renders editor"| node_note_editor
node_notes_page -->|"renders sidebar"| node_sidebar
node_note_editor -->|"loads rich editor"| node_rich_editor
node_note_editor -->|"uses features"| node_editor_features
node_notes_hook -->|"requests data"| node_api_client
node_notebooks_hook -->|"requests data"| node_api_client
node_api_client -->|"calls endpoints"| node_notes_api
node_notes_api -->|"validates input"| node_validation
node_notes_api -->|"normalizes files"| node_file_types
node_notebooks_api -.->|"validates input"| node_validation
node_notes_api -->|"reads and writes"| node_db_client
node_notebooks_api -->|"reads and writes"| node_db_client
node_tags_api -->|"queries tags"| node_db_client
node_backlinks_api -->|"queries links"| node_db_client
node_exports -->|"formats exports"| node_backup
node_exports -->|"packages ZIP"| node_zip
node_exports -->|"reads notes"| node_db_client
node_db_client -.->|"persists records"| node_database
node_user -.->|"uses offline app"| node_pwa

click node_login "https://github.com/iamakashtechie/nexus/blob/main/src/app/(auth)/login/page.tsx"
click node_auth_route "https://github.com/iamakashtechie/nexus/blob/main/src/app/api/auth/route.ts"
click node_auth_lib "https://github.com/iamakashtechie/nexus/blob/main/src/lib/auth.ts"
click node_rate_limit "https://github.com/iamakashtechie/nexus/blob/main/src/lib/rateLimiter.ts"
click node_proxy "https://github.com/iamakashtechie/nexus/blob/main/src/proxy.ts"
click node_notes_page "https://github.com/iamakashtechie/nexus/blob/main/src/app/(app)/notes/page.tsx"
click node_notes_hook "https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useNotes.ts"
click node_notebooks_hook "https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useNotebooks.ts"
click node_note_editor "https://github.com/iamakashtechie/nexus/blob/main/src/components/notes/NoteEditor.tsx"
click node_rich_editor "https://github.com/iamakashtechie/nexus/blob/main/src/components/editor/Editor.tsx"
click node_editor_features "https://github.com/iamakashtechie/nexus/tree/main/src/components/editor"
click node_sidebar "https://github.com/iamakashtechie/nexus/blob/main/src/components/notes/Sidebar.tsx"
click node_api_client "https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useApi.ts"
click node_notes_api "https://github.com/iamakashtechie/nexus/tree/main/src/app/api/notes"
click node_notebooks_api "https://github.com/iamakashtechie/nexus/tree/main/src/app/api/notebooks"
click node_tags_api "https://github.com/iamakashtechie/nexus/blob/main/src/app/api/tags/route.ts"
click node_backlinks_api "https://github.com/iamakashtechie/nexus/blob/main/src/app/api/notes/%5Bid%5D/backlinks/route.ts"
click node_exports "https://github.com/iamakashtechie/nexus/blob/main/src/app/api/notes/download/route.ts"
click node_validation "https://github.com/iamakashtechie/nexus/blob/main/src/lib/validations.ts"
click node_file_types "https://github.com/iamakashtechie/nexus/blob/main/src/lib/fileType.ts"
click node_backup "https://github.com/iamakashtechie/nexus/blob/main/src/lib/backup.ts"
click node_zip "https://github.com/iamakashtechie/nexus/blob/main/src/lib/zip.ts"
click node_db_client "https://github.com/iamakashtechie/nexus/blob/main/src/lib/db.ts"
click node_pwa "https://github.com/iamakashtechie/nexus/blob/main/public/sw.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_login,node_auth_route,node_auth_lib,node_rate_limit,node_proxy,node_user toneBlue
class node_notes_page,node_notes_hook,node_notebooks_hook,node_note_editor,node_rich_editor,node_editor_features,node_sidebar,node_pwa,node_database toneAmber
class node_api_client,node_notes_api,node_notebooks_api,node_tags_api,node_backlinks_api,node_exports toneMint
class node_validation,node_file_types,node_backup,node_zip,node_db_client toneRose
```

## Components

### Authentication

- [Login Page](https://github.com/iamakashtechie/nexus/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Login Endpoint](https://github.com/iamakashtechie/nexus/blob/main/src/app/api/auth/route.ts): `src/app/api/auth/route.ts`
- [JWT Auth](https://github.com/iamakashtechie/nexus/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Login Rate Limit](https://github.com/iamakashtechie/nexus/blob/main/src/lib/rateLimiter.ts): `src/lib/rateLimiter.ts`
- [Route Protection](https://github.com/iamakashtechie/nexus/blob/main/src/proxy.ts): `src/proxy.ts`

### Notes Workspace

- [Notes Workspace](https://github.com/iamakashtechie/nexus/blob/main/src/app/(app)/notes/page.tsx): `src/app/(app)/notes/page.tsx`
- [Note State](https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useNotes.ts): `src/hooks/useNotes.ts`
- [Notebook State](https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useNotebooks.ts): `src/hooks/useNotebooks.ts`
- [Note Editor](https://github.com/iamakashtechie/nexus/blob/main/src/components/notes/NoteEditor.tsx): `src/components/notes/NoteEditor.tsx`
- [Rich Editor](https://github.com/iamakashtechie/nexus/blob/main/src/components/editor/Editor.tsx): `src/components/editor/Editor.tsx`
- [Editor Features](https://github.com/iamakashtechie/nexus/tree/main/src/components/editor): `src/components/editor`
- [Note Sidebar](https://github.com/iamakashtechie/nexus/blob/main/src/components/notes/Sidebar.tsx): `src/components/notes/Sidebar.tsx`
- [PWA Support](https://github.com/iamakashtechie/nexus/blob/main/public/sw.js): `public/sw.js`

### Application API

- [API Client](https://github.com/iamakashtechie/nexus/blob/main/src/hooks/useApi.ts): `src/hooks/useApi.ts`
- [Notes Endpoints](https://github.com/iamakashtechie/nexus/tree/main/src/app/api/notes): `src/app/api/notes`
- [Notebook Endpoints](https://github.com/iamakashtechie/nexus/tree/main/src/app/api/notebooks): `src/app/api/notebooks`
- [Tag Endpoint](https://github.com/iamakashtechie/nexus/blob/main/src/app/api/tags/route.ts): `src/app/api/tags/route.ts`
- [Backlink Endpoint](https://github.com/iamakashtechie/nexus/blob/main/src/app/api/notes/%5Bid%5D/backlinks/route.ts): `src/app/api/notes/[id]/backlinks/route.ts`
- [Export Endpoints](https://github.com/iamakashtechie/nexus/blob/main/src/app/api/notes/download/route.ts): `src/app/api/notes/download/route.ts`

### Persistence

- [Request Validation](https://github.com/iamakashtechie/nexus/blob/main/src/lib/validations.ts): `src/lib/validations.ts`
- [File Type Handling](https://github.com/iamakashtechie/nexus/blob/main/src/lib/fileType.ts): `src/lib/fileType.ts`
- [Backup Formatting](https://github.com/iamakashtechie/nexus/blob/main/src/lib/backup.ts): `src/lib/backup.ts`
- [ZIP Packaging](https://github.com/iamakashtechie/nexus/blob/main/src/lib/zip.ts): `src/lib/zip.ts`
- [Prisma Client](https://github.com/iamakashtechie/nexus/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Other components

- **User**
- **Neon PostgreSQL**

## Connections

- User → Login Page: opens (evidence: `README.md`)
- Login Page → Login Endpoint: submits credentials
- Login Endpoint → Login Rate Limit: checks attempts (evidence: `src/app/api/auth/route.ts`)
- Login Endpoint → JWT Auth: signs token (evidence: `src/app/api/auth/route.ts`)
- Route Protection → JWT Auth: verifies token (evidence: `src/proxy.ts`)
- User → Notes Workspace: uses workspace (evidence: `README.md`)
- Notes Workspace → Note State: manages notes (evidence: `src/app/(app)/notes/page.tsx`)
- Notes Workspace → Notebook State: manages notebooks (evidence: `src/app/(app)/notes/page.tsx`)
- Notes Workspace → Note Editor: renders editor (evidence: `src/app/(app)/notes/page.tsx`)
- Notes Workspace → Note Sidebar: renders sidebar (evidence: `src/app/(app)/notes/page.tsx`)
- Note Editor → Rich Editor: loads rich editor (evidence: `src/components/notes/NoteEditor.tsx`)
- Note Editor → Editor Features: uses features (evidence: `src/components/notes/NoteEditor.tsx`)
- Note State → API Client: requests data (evidence: `src/hooks/useNotes.ts`)
- Notebook State → API Client: requests data (evidence: `src/hooks/useNotebooks.ts`)
- API Client → Notes Endpoints: calls endpoints (evidence: `src/hooks/useApi.ts`)
- Notes Endpoints → Request Validation: validates input (evidence: `src/app/api/notes/route.ts`)
- Notes Endpoints → File Type Handling: normalizes files (evidence: `src/app/api/notes/route.ts`)
- Notebook Endpoints → Request Validation: validates input (evidence: `src/app/api/notebooks/route.ts`)
- Notes Endpoints → Prisma Client: reads and writes (evidence: `src/app/api/notes/route.ts`)
- Notebook Endpoints → Prisma Client: reads and writes (evidence: `src/app/api/notebooks/route.ts`)
- Tag Endpoint → Prisma Client: queries tags (evidence: `src/app/api/tags/route.ts`)
- Backlink Endpoint → Prisma Client: queries links (evidence: `src/app/api/notes/[id]/backlinks/route.ts`)
- Export Endpoints → Backup Formatting: formats exports (evidence: `src/app/api/notes/download/route.ts`)
- Export Endpoints → ZIP Packaging: packages ZIP (evidence: `src/app/api/notes/download/route.ts`)
- Export Endpoints → Prisma Client: reads notes (evidence: `src/app/api/notes/download/route.ts`)
- Prisma Client → Neon PostgreSQL: persists records
- User → PWA Support: uses offline app
