# ansil-bayan/zerodrive architecture

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

- Interactive diagram: https://gitdiagram.com/ansil-bayan/zerodrive
- Repository: https://github.com/ansil-bayan/zerodrive

## Overview

ZeroDrive is a browser-encrypted cloud storage and private file-sharing product. Users authenticate, establish or recover vault access, then manage encrypted files and sharing through the web app; the API coordinates identity, metadata, storage access, and lifecycle work. A separate local-only Studio supports database inspection and queries. The README documents the zero-knowledge boundary and product capabilities; several route-level implementation links are not visible in the sampled source, so those links are omitted or marked unverified.

Main entry points: [`apps/api/src/server.ts`](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/server.ts) (Express API), [`apps/web/src/app.tsx`](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/app.tsx) (Web app routes), [`apps/web/src/pages/private-storage.tsx`](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/private-storage.tsx) (Private storage), [`apps/studio/src/client/App.tsx`](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/App.tsx) (Studio interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web app routes<br/>[app.tsx]"]
  node_storagepage["Private storage"]
  node_filelist["File explorer<br/>[file-list.tsx]"]
  node_sharingpage["File sharing<br/>[share-files.tsx]"]
  node_sharedpage["Shared with me<br/>[shared-with-me.tsx]"]
  node_authstate["Authentication state<br/>[app-context.tsx]"]
  node_authclient["Auth service<br/>[authService.ts]"]
end

subgraph group_crypto["Vault and sharing"]
  node_vaultcontext["Vault data context"]
  node_cryptoutils["Vault cryptography<br/>[cryptoUtils.ts]"]
  node_fileops["File operations<br/>[fileOperations.ts]"]
  node_keyrecovery["Key recovery<br/>[rsaKeyRecovery.ts]"]
  node_browserdb[("Browser metadata cache<br/>[dexieDB.ts]")]
end

subgraph group_api["API services"]
  node_api["Express API<br/>[server.ts]"]
  node_authroutes["Authentication routes<br/>[auth.ts]"]
  node_shareroutes["Sharing routes<br/>[sharedFiles.ts]"]
  node_analytics["Analytics service<br/>[analytics.ts]"]
  node_email["Email service<br/>[emailService.ts]"]
end

subgraph group_data["Persistence and storage"]
  node_pg[("PostgreSQL")]
  node_objectstore[("Object storage")]
end

subgraph group_studio["Operations studio"]
  node_studioapp["Studio interface<br/>[App.tsx]"]
  node_studioquery["Query workspace<br/>[QueryWorkspace.tsx]"]
  node_studioapi["Studio API client<br/>[api.ts]"]
  node_studioserver["Studio server<br/>[app.ts]"]
  node_studiodb["Studio database access<br/>[database.ts]"]
end

node_user(("User"))

node_user -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_storagepage
node_webapp -->|"routes to"| node_sharingpage
node_webapp -->|"routes to"| node_sharedpage
node_webapp -->|"provides"| node_authstate
node_storagepage -->|"renders"| node_filelist
node_storagepage -->|"checks key"| node_cryptoutils
node_storagepage -->|"fetches metadata"| node_browserdb
node_storagepage -->|"uses"| node_fileops
node_authstate -->|"uses"| node_authclient
node_vaultcontext -->|"reads and writes"| node_browserdb
node_vaultcontext -->|"uses"| node_cryptoutils
node_authclient -.->|"requests auth"| node_api
node_api -->|"connects"| node_pg
node_api -->|"schedules cleanup"| node_analytics
node_api -->|"mounts routes"| node_authroutes
node_api -.->|"coordinates storage"| node_objectstore
node_sharingpage -.->|"uses sharing API"| node_shareroutes
node_api -->|"sends webhook email"| node_email
node_user -.->|"inspects database"| node_studioapp
node_studioapp -->|"loads session and relations"| node_studioapi
node_studioapp -->|"renders"| node_studioquery
node_studioquery -->|"executes queries"| node_studioapi
node_studioapi -.->|"calls"| node_studioserver
node_studioserver -->|"uses"| node_studiodb
node_studiodb -->|"queries"| node_pg

click node_webapp "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/app.tsx"
click node_storagepage "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/private-storage.tsx"
click node_filelist "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/components/storage/file-list.tsx"
click node_sharingpage "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/share-files.tsx"
click node_sharedpage "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/shared-with-me.tsx"
click node_authstate "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/contexts/app-context.tsx"
click node_authclient "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/authService.ts"
click node_vaultcontext "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/contexts/vault-data-context.tsx"
click node_cryptoutils "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/cryptoUtils.ts"
click node_fileops "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/fileOperations.ts"
click node_keyrecovery "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/rsaKeyRecovery.ts"
click node_browserdb "https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/dexieDB.ts"
click node_api "https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/server.ts"
click node_authroutes "https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/routes/auth.ts"
click node_shareroutes "https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/routes/sharedFiles.ts"
click node_analytics "https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/services/analytics.ts"
click node_email "https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/services/emailService.ts"
click node_studioapp "https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/App.tsx"
click node_studioquery "https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/components/QueryWorkspace.tsx"
click node_studioapi "https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/api.ts"
click node_studioserver "https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/server/app.ts"
click node_studiodb "https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/server/database.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_webapp,node_storagepage,node_filelist,node_sharingpage,node_sharedpage,node_authstate,node_authclient,node_user toneBlue
class node_vaultcontext,node_cryptoutils,node_fileops,node_keyrecovery,node_browserdb toneAmber
class node_api,node_authroutes,node_shareroutes,node_analytics,node_email toneMint
class node_pg,node_objectstore toneRose
class node_studioapp,node_studioquery,node_studioapi,node_studioserver,node_studiodb toneIndigo
```

## Components

### Web application

- [Web app routes](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/app.tsx): `apps/web/src/app.tsx`
- [Private storage](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/private-storage.tsx): `apps/web/src/pages/private-storage.tsx`
- [File explorer](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/components/storage/file-list.tsx): `apps/web/src/components/storage/file-list.tsx`
- [File sharing](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/share-files.tsx): `apps/web/src/pages/share-files.tsx`
- [Shared with me](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/pages/shared-with-me.tsx): `apps/web/src/pages/shared-with-me.tsx`
- [Authentication state](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/contexts/app-context.tsx): `apps/web/src/contexts/app-context.tsx`
- [Auth service](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/authService.ts): `apps/web/src/utils/authService.ts`

### Vault and sharing

- [Vault data context](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/contexts/vault-data-context.tsx): `apps/web/src/contexts/vault-data-context.tsx`
- [Vault cryptography](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/cryptoUtils.ts): `apps/web/src/utils/cryptoUtils.ts`
- [File operations](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/fileOperations.ts): `apps/web/src/utils/fileOperations.ts`
- [Key recovery](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/rsaKeyRecovery.ts): `apps/web/src/utils/rsaKeyRecovery.ts`
- [Browser metadata cache](https://github.com/ansil-bayan/zerodrive/blob/main/apps/web/src/utils/dexieDB.ts): `apps/web/src/utils/dexieDB.ts`

### API services

- [Express API](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/server.ts): `apps/api/src/server.ts`
- [Authentication routes](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/routes/auth.ts): `apps/api/src/routes/auth.ts`
- [Sharing routes](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/routes/sharedFiles.ts): `apps/api/src/routes/sharedFiles.ts`
- [Analytics service](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/services/analytics.ts): `apps/api/src/services/analytics.ts`
- [Email service](https://github.com/ansil-bayan/zerodrive/blob/main/apps/api/src/services/emailService.ts): `apps/api/src/services/emailService.ts`

### Persistence and storage

- **PostgreSQL**
- **Object storage**

### Operations studio

- [Studio interface](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/App.tsx): `apps/studio/src/client/App.tsx`
- [Query workspace](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/components/QueryWorkspace.tsx): `apps/studio/src/client/components/QueryWorkspace.tsx`
- [Studio API client](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/client/api.ts): `apps/studio/src/client/api.ts`
- [Studio server](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/server/app.ts): `apps/studio/src/server/app.ts`
- [Studio database access](https://github.com/ansil-bayan/zerodrive/blob/main/apps/studio/src/server/database.ts): `apps/studio/src/server/database.ts`

### Other components

- **User**

## Connections

- User → Web app routes: uses (evidence: `apps/web/src/app.tsx`)
- Web app routes → Private storage: routes to (evidence: `apps/web/src/app.tsx`)
- Web app routes → File sharing: routes to (evidence: `apps/web/src/app.tsx`)
- Web app routes → Shared with me: routes to (evidence: `apps/web/src/app.tsx`)
- Web app routes → Authentication state: provides (evidence: `apps/web/src/app.tsx`)
- Private storage → File explorer: renders (evidence: `apps/web/src/pages/private-storage.tsx`)
- Private storage → Vault cryptography: checks key (evidence: `apps/web/src/pages/private-storage.tsx`)
- Private storage → Browser metadata cache: fetches metadata (evidence: `apps/web/src/pages/private-storage.tsx`)
- Private storage → File operations: uses (evidence: `apps/web/src/pages/private-storage.tsx`)
- Authentication state → Auth service: uses (evidence: `apps/web/src/contexts/app-context.tsx`)
- Vault data context → Browser metadata cache: reads and writes (evidence: `apps/web/src/contexts/vault-data-context.tsx`)
- Vault data context → Vault cryptography: uses (evidence: `apps/web/src/contexts/vault-data-context.tsx`)
- Auth service → Express API: requests auth (evidence: `README.md`)
- Express API → PostgreSQL: connects (evidence: `apps/api/src/server.ts`)
- Express API → Analytics service: schedules cleanup (evidence: `apps/api/src/server.ts`)
- Express API → Authentication routes: mounts routes (evidence: `apps/api/src/server.ts`)
- Express API → Object storage: coordinates storage (evidence: `README.md`)
- File sharing → Sharing routes: uses sharing API (evidence: `README.md`)
- Express API → Email service: sends webhook email
- User → Studio interface: inspects database (evidence: `README.md`)
- Studio interface → Studio API client: loads session and relations (evidence: `apps/studio/src/client/App.tsx`)
- Studio interface → Query workspace: renders (evidence: `apps/studio/src/client/App.tsx`)
- Query workspace → Studio API client: executes queries (evidence: `apps/studio/src/client/components/QueryWorkspace.tsx`)
- Studio API client → Studio server: calls
- Studio server → Studio database access: uses (evidence: `apps/studio/src/server/app.ts`)
- Studio database access → PostgreSQL: queries (evidence: `apps/studio/src/server/database.ts`)
