# ayushsen83/vaultix architecture

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

- Interactive diagram: https://gitdiagram.com/ayushsen83/vaultix
- Repository: https://github.com/ayushsen83/vaultix

## Overview

Vaultix is a secure digital locker with a React client and Express API. Users register or log in (optionally completing TOTP verification), then manage notes, files, search, and account settings. The client routes public and protected screens and sends credentialed API requests; the server routes requests through authentication and CSRF controls to domain handlers backed by PostgreSQL and file storage. The graph preserves documented-by-code capabilities from the route and screen structure; several controller and page implementations were not sampled, so their internal calls are omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/App.jsx) (Route shell), [`backend/server.js`](https://github.com/ayushsen83/vaultix/blob/main/backend/server.js) (API server), [`frontend/src/services/api.js`](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/services/api.js) (API client), [`backend/middleware/auth.middleware.js`](https://github.com/ayushsen83/vaultix/blob/main/backend/middleware/auth.middleware.js) (Token authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["Route shell<br/>[App.jsx]"]
  node_landing["Landing<br/>[Landing.jsx]"]
  node_login["Login screen<br/>[Login.jsx]"]
  node_register["Registration screen<br/>[Register.jsx]"]
  node_protected["Protected layout"]
  node_home["Home dashboard<br/>[Home.jsx]"]
  node_notes["Notes screen<br/>[Notes.jsx]"]
  node_documents["Documents screen<br/>[Documents.jsx]"]
  node_profile["Profile settings<br/>[Profile.jsx]"]
  node_sidebar["Navigation sidebar<br/>[sidebar.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_identity["Identity and security"]
  node_authroutes["Auth routes<br/>[login.js]"]
  node_registerroutes["Registration routes<br/>[register.js]"]
  node_loginhandler["Login handler<br/>[login.js]"]
  node_registerhandler["Registration handler<br/>[register.js]"]
  node_registration2fa["Enrollment 2FA"]
  node_twofaroutes["Account 2FA routes"]
  node_twofahandler["2FA handler"]
  node_totpcrypto["TOTP encryption<br/>[totpEncryption.js]"]
  node_authmw["Token authentication<br/>[auth.middleware.js]"]
  node_csrf["CSRF protection<br/>[csrf.middleware.js]"]
end

subgraph group_locker["Locker features"]
  node_notesapi["Notes API"]
  node_notescrypto["Notes encryption<br/>[notesEncryption.js]"]
  node_filesapi["File management"]
  node_filesroutes["File routes<br/>[files.routes.js]"]
  node_storage["Object storage<br/>[storage.service.js]"]
  node_searchapi["Search"]
  node_usersapi["User settings"]
end

subgraph group_platform["API and persistence"]
  node_server["API server<br/>[server.js]"]
  node_db[("PostgreSQL pool<br/>[db.js]")]
  node_searchroutes["Search routes<br/>[search.routes.js]"]
  node_notesroutes["Notes routes<br/>[notes.routes.js]"]
  node_usersroutes["User routes<br/>[users.routes.js]"]
end

node_visitor(("User"))

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_register
node_app -->|"protects routes"| node_protected
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_notes
node_app -->|"routes to"| node_documents
node_app -->|"routes to"| node_profile
node_protected -->|"renders"| node_sidebar
node_login -->|"requests"| node_api
node_register -->|"requests"| node_api
node_home -->|"requests"| node_api
node_notes -->|"requests"| node_api
node_documents -->|"requests"| node_api
node_profile -->|"requests"| node_api
node_sidebar -->|"requests logout"| node_api
node_api -.->|"sends API requests"| node_server
node_server -->|"mounts"| node_registerroutes
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_twofaroutes
node_server -->|"mounts"| node_notesroutes
node_server -->|"mounts"| node_filesroutes
node_server -->|"mounts"| node_searchroutes
node_server -->|"mounts"| node_usersroutes
node_authroutes -->|"dispatches"| node_loginhandler
node_registerroutes -->|"dispatches"| node_registerhandler
node_registerroutes -->|"dispatches"| node_registration2fa
node_server -->|"dispatches login verification"| node_twofahandler
node_twofaroutes -->|"authenticates"| node_authmw
node_twofaroutes -->|"checks CSRF"| node_csrf
node_twofaroutes -->|"dispatches"| node_twofahandler
node_filesroutes -->|"authenticates"| node_authmw
node_filesroutes -->|"checks CSRF"| node_csrf
node_filesroutes -->|"dispatches"| node_filesapi
node_notesroutes -->|"authenticates"| node_authmw
node_notesroutes -->|"dispatches"| node_notesapi
node_searchroutes -->|"authenticates"| node_authmw
node_searchroutes -->|"checks CSRF"| node_csrf
node_searchroutes -->|"dispatches"| node_searchapi
node_usersroutes -->|"authenticates"| node_authmw
node_usersroutes -->|"checks CSRF"| node_csrf
node_usersroutes -->|"dispatches"| node_usersapi
node_authmw -->|"checks token version"| node_db
node_filesapi -->|"reads and writes metadata"| node_db
node_filesapi -->|"stores file objects"| node_storage
node_notesapi -->|"reads and writes notes"| node_db
node_notesapi -->|"encrypts notes"| node_notescrypto

click node_app "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Landing.jsx"
click node_login "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Login.jsx"
click node_register "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Register.jsx"
click node_protected "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/components/layouts/ProtectedLayout.jsx"
click node_home "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Home.jsx"
click node_notes "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Notes.jsx"
click node_documents "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Documents.jsx"
click node_profile "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Profile.jsx"
click node_sidebar "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/components/sidebar.jsx"
click node_api "https://github.com/ayushsen83/vaultix/blob/main/frontend/src/services/api.js"
click node_authroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/login.js"
click node_registerroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/register.js"
click node_loginhandler "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/login.js"
click node_registerhandler "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/register.js"
click node_registration2fa "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/registrationTwoFactor.controller.js"
click node_twofaroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/twoFactor.routes.js"
click node_twofahandler "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/twoFactor.controller.js"
click node_totpcrypto "https://github.com/ayushsen83/vaultix/blob/main/backend/utils/totpEncryption.js"
click node_authmw "https://github.com/ayushsen83/vaultix/blob/main/backend/middleware/auth.middleware.js"
click node_csrf "https://github.com/ayushsen83/vaultix/blob/main/backend/middleware/csrf.middleware.js"
click node_notesapi "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/notes.controller.js"
click node_notescrypto "https://github.com/ayushsen83/vaultix/blob/main/backend/utils/notesEncryption.js"
click node_filesapi "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/files.controller.js"
click node_filesroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/files.routes.js"
click node_storage "https://github.com/ayushsen83/vaultix/blob/main/backend/services/storage.service.js"
click node_searchapi "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/search.controller.js"
click node_usersapi "https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/users.controller.js"
click node_server "https://github.com/ayushsen83/vaultix/blob/main/backend/server.js"
click node_db "https://github.com/ayushsen83/vaultix/blob/main/backend/db.js"
click node_searchroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/search.routes.js"
click node_notesroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/notes.routes.js"
click node_usersroutes "https://github.com/ayushsen83/vaultix/blob/main/backend/routes/users.routes.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_landing,node_login,node_register,node_protected,node_home,node_notes,node_documents,node_profile,node_sidebar,node_api,node_visitor toneBlue
class node_authroutes,node_registerroutes,node_loginhandler,node_registerhandler,node_registration2fa,node_twofaroutes,node_twofahandler,node_totpcrypto,node_authmw,node_csrf toneAmber
class node_notesapi,node_notescrypto,node_filesapi,node_filesroutes,node_storage,node_searchapi,node_usersapi toneMint
class node_server,node_db,node_searchroutes,node_notesroutes,node_usersroutes toneRose
```

## Components

### Web client

- [Route shell](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Login screen](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Registration screen](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Protected layout](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/components/layouts/ProtectedLayout.jsx): `frontend/src/components/layouts/ProtectedLayout.jsx`
- [Home dashboard](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Notes screen](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Notes.jsx): `frontend/src/pages/Notes.jsx`
- [Documents screen](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Documents.jsx): `frontend/src/pages/Documents.jsx`
- [Profile settings](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`
- [Navigation sidebar](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/components/sidebar.jsx): `frontend/src/components/sidebar.jsx`
- [API client](https://github.com/ayushsen83/vaultix/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Identity and security

- [Auth routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/login.js): `backend/routes/login.js`
- [Registration routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/register.js): `backend/routes/register.js`
- [Login handler](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/login.js): `backend/controllers/login.js`
- [Registration handler](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/register.js): `backend/controllers/register.js`
- [Enrollment 2FA](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/registrationTwoFactor.controller.js): `backend/controllers/registrationTwoFactor.controller.js`
- [Account 2FA routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/twoFactor.routes.js): `backend/routes/twoFactor.routes.js`
- [2FA handler](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/twoFactor.controller.js): `backend/controllers/twoFactor.controller.js`
- [TOTP encryption](https://github.com/ayushsen83/vaultix/blob/main/backend/utils/totpEncryption.js): `backend/utils/totpEncryption.js`
- [Token authentication](https://github.com/ayushsen83/vaultix/blob/main/backend/middleware/auth.middleware.js): `backend/middleware/auth.middleware.js`
- [CSRF protection](https://github.com/ayushsen83/vaultix/blob/main/backend/middleware/csrf.middleware.js): `backend/middleware/csrf.middleware.js`

### Locker features

- [Notes API](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/notes.controller.js): `backend/controllers/notes.controller.js`
- [Notes encryption](https://github.com/ayushsen83/vaultix/blob/main/backend/utils/notesEncryption.js): `backend/utils/notesEncryption.js`
- [File management](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/files.controller.js): `backend/controllers/files.controller.js`
- [File routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/files.routes.js): `backend/routes/files.routes.js`
- [Object storage](https://github.com/ayushsen83/vaultix/blob/main/backend/services/storage.service.js): `backend/services/storage.service.js`
- [Search](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/search.controller.js): `backend/controllers/search.controller.js`
- [User settings](https://github.com/ayushsen83/vaultix/blob/main/backend/controllers/users.controller.js): `backend/controllers/users.controller.js`

### API and persistence

- [API server](https://github.com/ayushsen83/vaultix/blob/main/backend/server.js): `backend/server.js`
- [PostgreSQL pool](https://github.com/ayushsen83/vaultix/blob/main/backend/db.js): `backend/db.js`
- [Search routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/search.routes.js): `backend/routes/search.routes.js`
- [Notes routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/notes.routes.js): `backend/routes/notes.routes.js`
- [User routes](https://github.com/ayushsen83/vaultix/blob/main/backend/routes/users.routes.js): `backend/routes/users.routes.js`

### Other components

- **User**

## Connections

- User → Route shell: uses (evidence: `frontend/src/App.jsx`)
- Route shell → Landing: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Login screen: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Registration screen: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Protected layout: protects routes (evidence: `frontend/src/App.jsx`)
- Route shell → Home dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Notes screen: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Documents screen: routes to (evidence: `frontend/src/App.jsx`)
- Route shell → Profile settings: routes to (evidence: `frontend/src/App.jsx`)
- Protected layout → Navigation sidebar: renders (evidence: `frontend/src/components/layouts/ProtectedLayout.jsx`)
- Login screen → API client: requests (evidence: `frontend/src/pages/Login.jsx`)
- Registration screen → API client: requests (evidence: `frontend/src/pages/Register.jsx`)
- Home dashboard → API client: requests (evidence: `frontend/src/pages/Home.jsx`)
- Notes screen → API client: requests (evidence: `frontend/src/pages/Notes.jsx`)
- Documents screen → API client: requests (evidence: `frontend/src/pages/Documents.jsx`)
- Profile settings → API client: requests (evidence: `frontend/src/pages/Profile.jsx`)
- Navigation sidebar → API client: requests logout (evidence: `frontend/src/components/sidebar.jsx`)
- API client → API server: sends API requests
- API server → Registration routes: mounts (evidence: `backend/server.js`)
- API server → Auth routes: mounts (evidence: `backend/server.js`)
- API server → Account 2FA routes: mounts (evidence: `backend/server.js`)
- API server → Notes routes: mounts (evidence: `backend/server.js`)
- API server → File routes: mounts (evidence: `backend/server.js`)
- API server → Search routes: mounts (evidence: `backend/server.js`)
- API server → User routes: mounts (evidence: `backend/server.js`)
- Auth routes → Login handler: dispatches (evidence: `backend/routes/login.js`)
- Registration routes → Registration handler: dispatches (evidence: `backend/routes/register.js`)
- Registration routes → Enrollment 2FA: dispatches (evidence: `backend/routes/register.js`)
- API server → 2FA handler: dispatches login verification (evidence: `backend/server.js`)
- Account 2FA routes → Token authentication: authenticates (evidence: `backend/routes/twoFactor.routes.js`)
- Account 2FA routes → CSRF protection: checks CSRF (evidence: `backend/routes/twoFactor.routes.js`)
- Account 2FA routes → 2FA handler: dispatches (evidence: `backend/routes/twoFactor.routes.js`)
- File routes → Token authentication: authenticates (evidence: `backend/routes/files.routes.js`)
- File routes → CSRF protection: checks CSRF (evidence: `backend/routes/files.routes.js`)
- File routes → File management: dispatches (evidence: `backend/routes/files.routes.js`)
- Notes routes → Token authentication: authenticates (evidence: `backend/routes/notes.routes.js`)
- Notes routes → Notes API: dispatches (evidence: `backend/routes/notes.routes.js`)
- Search routes → Token authentication: authenticates (evidence: `backend/routes/search.routes.js`)
- Search routes → CSRF protection: checks CSRF (evidence: `backend/routes/search.routes.js`)
- Search routes → Search: dispatches (evidence: `backend/routes/search.routes.js`)
- User routes → Token authentication: authenticates (evidence: `backend/routes/users.routes.js`)
- User routes → CSRF protection: checks CSRF (evidence: `backend/routes/users.routes.js`)
- User routes → User settings: dispatches (evidence: `backend/routes/users.routes.js`)
- Token authentication → PostgreSQL pool: checks token version (evidence: `backend/middleware/auth.middleware.js`)
- File management → PostgreSQL pool: reads and writes metadata (evidence: `backend/controllers/files.controller.js`)
- File management → Object storage: stores file objects (evidence: `backend/controllers/files.controller.js`)
- Notes API → PostgreSQL pool: reads and writes notes (evidence: `backend/controllers/notes.controller.js`)
- Notes API → Notes encryption: encrypts notes (evidence: `backend/controllers/notes.controller.js`)
