# vignesh01-afk/cipher architecture

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

- Interactive diagram: https://gitdiagram.com/vignesh01-afk/cipher
- Repository: https://github.com/vignesh01-afk/cipher

## Overview

CipherNote is a browser-first encrypted notes application: users authenticate and unlock local key material, then create, decrypt, search, share, revoke, and inspect notes while the API stores ciphertext and metadata. The graph preserves the documented secure-file, activity-log, and recovery capabilities alongside notes and sharing. Some route and page implementations were not sampled; those relationships are included only where documented in the README or supported by the SOURCE INDEX.

Main entry points: [`client/src/lib/api.ts`](https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/api.ts) (Typed API client), [`server/src/db.ts`](https://github.com/vignesh01-afk/cipher/blob/main/server/src/db.ts) (Application database), [`server/src/routes/auth.ts`](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/auth.ts) (Authentication), [`client/src/hooks/useNotes.ts`](https://github.com/vignesh01-afk/cipher/blob/main/client/src/hooks/useNotes.ts) (Notes and search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser app"]
  node_routes["App routes<br/>[App.tsx]"]
  node_auth["Session and unlock<br/>[AuthContext.tsx]"]
  node_notes_ui["Notes and search<br/>[useNotes.ts]"]
  node_note_pages["Note pages<br/>[NoteEditorPage.tsx]"]
  node_shared_ui["Shared notes"]
  node_share_dialog["Share and revoke<br/>[ShareNoteModal.tsx]"]
  node_files_ui["Secure files<br/>[files.ts]"]
  node_activity_ui["Activity log"]
  node_inspector["Security inspector"]
  node_privacy["Privacy settings<br/>[PrivacyContext.tsx]"]
  node_api_client["Typed API client<br/>[api.ts]"]
end

subgraph group_security["Client security"]
  node_crypto["Browser cryptography<br/>[crypto.ts]"]
  node_note_helpers["Decrypt and search<br/>[notes.ts]"]
end

subgraph group_api["API services"]
  node_http_api["HTTP API<br/>[app.ts]"]
  node_auth_routes["Authentication<br/>[auth.ts]"]
  node_note_routes["Notes and sharing<br/>[notes.ts]"]
  node_shared_routes["Shared-note listing<br/>[shared.ts]"]
  node_user_routes["User lookup<br/>[users.ts]"]
  node_file_routes["File access<br/>[files.ts]"]
  node_audit_routes["Audit access<br/>[audit.ts]"]
  node_authorization["Authentication and access<br/>[auth.ts]"]
  node_audit_writer["Audit writer<br/>[audit.ts]"]
end

subgraph group_data["Persistent data"]
  node_database[("Application database<br/>[db.ts]")]
  node_file_storage[("Encrypted file storage<br/>[storage.ts]")]
end

node_user(("User"))
node_api_service["CipherNote API"]

node_user -->|"uses"| node_routes
node_routes -->|"guards routes"| node_auth
node_auth -->|"unlocks keys"| node_crypto
node_auth -->|"authenticates"| node_api_client
node_user -->|"creates and edits"| node_note_pages
node_note_pages -->|"encrypts locally"| node_crypto
node_notes_ui -->|"loads notes"| node_api_client
node_notes_ui -->|"decrypts locally"| node_note_helpers
node_note_helpers -->|"decrypts content"| node_crypto
node_user -->|"searches locally"| node_notes_ui
node_user -->|"shares or revokes"| node_share_dialog
node_share_dialog -->|"submits sharing"| node_api_client
node_user -->|"opens shared notes"| node_shared_ui
node_shared_ui -->|"fetches shares"| node_api_client
node_user -->|"manages files"| node_files_ui
node_files_ui -->|"requests file data"| node_api_client
node_files_ui -->|"decrypts files"| node_crypto
node_user -->|"views activity"| node_activity_ui
node_activity_ui -->|"requests audit logs"| node_api_client
node_user -->|"inspects note metadata"| node_inspector
node_inspector -->|"reads loaded notes"| node_notes_ui
node_user -->|"sets privacy controls"| node_privacy
node_api_client -->|"sends API requests"| node_api_service
node_api_service -->|"routes requests"| node_http_api
node_http_api -->|"mounts API routes"| node_auth_routes
node_auth_routes -->|"reads and writes users"| node_database
node_note_routes -->|"reads and writes notes"| node_database
node_shared_routes -.->|"lists shared notes"| node_database
node_user_routes -.->|"looks up users"| node_database
node_file_routes -->|"tracks file metadata"| node_database
node_file_routes -->|"stores encrypted blobs"| node_file_storage
node_audit_routes -.->|"reads audit records"| node_database
node_auth_routes -->|"protects endpoints"| node_authorization
node_note_routes -->|"protects endpoints"| node_authorization
node_file_routes -->|"protects endpoints"| node_authorization
node_auth_routes -->|"records events"| node_audit_writer
node_note_routes -->|"records events"| node_audit_writer
node_audit_writer -->|"writes audit records"| node_database

click node_routes "https://github.com/vignesh01-afk/cipher/blob/main/client/src/App.tsx"
click node_auth "https://github.com/vignesh01-afk/cipher/blob/main/client/src/context/AuthContext.tsx"
click node_notes_ui "https://github.com/vignesh01-afk/cipher/blob/main/client/src/hooks/useNotes.ts"
click node_note_pages "https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/NoteEditorPage.tsx"
click node_shared_ui "https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/SharedWithMePage.tsx"
click node_share_dialog "https://github.com/vignesh01-afk/cipher/blob/main/client/src/components/ShareNoteModal.tsx"
click node_files_ui "https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/files.ts"
click node_activity_ui "https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/ActivityLogPage.tsx"
click node_inspector "https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/SecurityInspectorPage.tsx"
click node_privacy "https://github.com/vignesh01-afk/cipher/blob/main/client/src/context/PrivacyContext.tsx"
click node_crypto "https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/crypto.ts"
click node_note_helpers "https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/notes.ts"
click node_api_client "https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/api.ts"
click node_http_api "https://github.com/vignesh01-afk/cipher/blob/main/server/src/app.ts"
click node_auth_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/auth.ts"
click node_note_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/notes.ts"
click node_shared_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/shared.ts"
click node_user_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/users.ts"
click node_file_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/files.ts"
click node_audit_routes "https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/audit.ts"
click node_authorization "https://github.com/vignesh01-afk/cipher/blob/main/server/src/middleware/auth.ts"
click node_audit_writer "https://github.com/vignesh01-afk/cipher/blob/main/server/src/lib/audit.ts"
click node_database "https://github.com/vignesh01-afk/cipher/blob/main/server/src/db.ts"
click node_file_storage "https://github.com/vignesh01-afk/cipher/blob/main/server/src/lib/storage.ts"

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_routes,node_auth,node_notes_ui,node_note_pages,node_shared_ui,node_share_dialog,node_files_ui,node_activity_ui,node_inspector,node_privacy,node_api_client,node_user toneBlue
class node_crypto,node_note_helpers toneAmber
class node_http_api,node_auth_routes,node_note_routes,node_shared_routes,node_user_routes,node_file_routes,node_audit_routes,node_authorization,node_audit_writer,node_api_service toneMint
class node_database,node_file_storage toneRose
```

## Components

### Browser app

- [App routes](https://github.com/vignesh01-afk/cipher/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Session and unlock](https://github.com/vignesh01-afk/cipher/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`
- [Notes and search](https://github.com/vignesh01-afk/cipher/blob/main/client/src/hooks/useNotes.ts): `client/src/hooks/useNotes.ts`
- [Note pages](https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/NoteEditorPage.tsx): `client/src/pages/NoteEditorPage.tsx`
- [Shared notes](https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/SharedWithMePage.tsx): `client/src/pages/SharedWithMePage.tsx`
- [Share and revoke](https://github.com/vignesh01-afk/cipher/blob/main/client/src/components/ShareNoteModal.tsx): `client/src/components/ShareNoteModal.tsx`
- [Secure files](https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/files.ts): `client/src/lib/files.ts`
- [Activity log](https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/ActivityLogPage.tsx): `client/src/pages/ActivityLogPage.tsx`
- [Security inspector](https://github.com/vignesh01-afk/cipher/blob/main/client/src/pages/SecurityInspectorPage.tsx): `client/src/pages/SecurityInspectorPage.tsx`
- [Privacy settings](https://github.com/vignesh01-afk/cipher/blob/main/client/src/context/PrivacyContext.tsx): `client/src/context/PrivacyContext.tsx`
- [Typed API client](https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/api.ts): `client/src/lib/api.ts`

### Client security

- [Browser cryptography](https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/crypto.ts): `client/src/lib/crypto.ts`
- [Decrypt and search](https://github.com/vignesh01-afk/cipher/blob/main/client/src/lib/notes.ts): `client/src/lib/notes.ts`

### API services

- [HTTP API](https://github.com/vignesh01-afk/cipher/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/auth.ts): `server/src/routes/auth.ts`
- [Notes and sharing](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/notes.ts): `server/src/routes/notes.ts`
- [Shared-note listing](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/shared.ts): `server/src/routes/shared.ts`
- [User lookup](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/users.ts): `server/src/routes/users.ts`
- [File access](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/files.ts): `server/src/routes/files.ts`
- [Audit access](https://github.com/vignesh01-afk/cipher/blob/main/server/src/routes/audit.ts): `server/src/routes/audit.ts`
- [Authentication and access](https://github.com/vignesh01-afk/cipher/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [Audit writer](https://github.com/vignesh01-afk/cipher/blob/main/server/src/lib/audit.ts): `server/src/lib/audit.ts`

### Persistent data

- [Application database](https://github.com/vignesh01-afk/cipher/blob/main/server/src/db.ts): `server/src/db.ts`
- [Encrypted file storage](https://github.com/vignesh01-afk/cipher/blob/main/server/src/lib/storage.ts): `server/src/lib/storage.ts`

### Other components

- **User**
- **CipherNote API**

## Connections

- User → App routes: uses (evidence: `README.md`)
- App routes → Session and unlock: guards routes (evidence: `client/src/App.tsx`)
- Session and unlock → Browser cryptography: unlocks keys (evidence: `client/src/context/AuthContext.tsx`)
- Session and unlock → Typed API client: authenticates (evidence: `client/src/context/AuthContext.tsx`)
- User → Note pages: creates and edits (evidence: `README.md`)
- Note pages → Browser cryptography: encrypts locally (evidence: `README.md`)
- Notes and search → Typed API client: loads notes (evidence: `client/src/hooks/useNotes.ts`)
- Notes and search → Decrypt and search: decrypts locally (evidence: `client/src/hooks/useNotes.ts`)
- Decrypt and search → Browser cryptography: decrypts content (evidence: `client/src/lib/notes.ts`)
- User → Notes and search: searches locally (evidence: `README.md`)
- User → Share and revoke: shares or revokes (evidence: `README.md`)
- Share and revoke → Typed API client: submits sharing (evidence: `client/src/components/ShareNoteModal.tsx`)
- User → Shared notes: opens shared notes (evidence: `README.md`)
- Shared notes → Typed API client: fetches shares (evidence: `client/src/lib/api.ts`)
- User → Secure files: manages files (evidence: `README.md`)
- Secure files → Typed API client: requests file data (evidence: `client/src/lib/files.ts`)
- Secure files → Browser cryptography: decrypts files (evidence: `client/src/lib/files.ts`)
- User → Activity log: views activity (evidence: `README.md`)
- Activity log → Typed API client: requests audit logs (evidence: `client/src/lib/api.ts`)
- User → Security inspector: inspects note metadata (evidence: `README.md`)
- Security inspector → Notes and search: reads loaded notes (evidence: `client/src/pages/SecurityInspectorPage.tsx`)
- User → Privacy settings: sets privacy controls (evidence: `README.md`)
- Typed API client → CipherNote API: sends API requests (evidence: `client/src/lib/api.ts`)
- CipherNote API → HTTP API: routes requests (evidence: `server/src/app.ts`)
- HTTP API → Authentication: mounts API routes (evidence: `server/src/app.ts`)
- Authentication → Application database: reads and writes users (evidence: `server/src/routes/auth.ts`)
- Notes and sharing → Application database: reads and writes notes (evidence: `server/src/routes/notes.ts`)
- Shared-note listing → Application database: lists shared notes
- User lookup → Application database: looks up users
- File access → Application database: tracks file metadata (evidence: `server/src/routes/files.ts`)
- File access → Encrypted file storage: stores encrypted blobs (evidence: `server/src/routes/files.ts`)
- Audit access → Application database: reads audit records
- Authentication → Authentication and access: protects endpoints (evidence: `server/src/routes/auth.ts`)
- Notes and sharing → Authentication and access: protects endpoints (evidence: `server/src/routes/notes.ts`)
- File access → Authentication and access: protects endpoints (evidence: `server/src/routes/files.ts`)
- Authentication → Audit writer: records events (evidence: `server/src/routes/auth.ts`)
- Notes and sharing → Audit writer: records events (evidence: `server/src/routes/notes.ts`)
- Audit writer → Application database: writes audit records (evidence: `server/src/lib/audit.ts`)
