# myrosama/daemonclient architecture

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

- Interactive diagram: https://gitdiagram.com/myrosama/daemonclient
- Repository: https://github.com/myrosama/daemonclient

## Overview

DaemonClient is a personal-cloud product: accounts setup provisions a per-user backend, while Photos and Drive let users manage files on their own isolated infrastructure. The README documents browser-direct encrypted Drive bytes to Telegram, metadata APIs through the user worker, Photos library features, and a self-hosting CLI. Edges reflect only README statements or shown imports/calls; many Photos internals and integrations are unsampled, so their links are omitted or marked unverified.

Main entry points: [`apps/drive-web/src/App.jsx`](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/App.jsx) (Drive app), [`workers/user-worker/src/server.ts`](https://github.com/myrosama/daemonclient/blob/main/workers/user-worker/src/server.ts) (User API worker), [`apps/accounts-web/src/hooks/useWorkerSetup.ts`](https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/hooks/useWorkerSetup.ts) (Setup state hook), [`selfhost/bin/daemonclient.mjs`](https://github.com/myrosama/daemonclient/blob/main/selfhost/bin/daemonclient.mjs) (Self-host CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Account and Provisioning"]
  node_accounts["Accounts portal<br/>[App.jsx]"]
  node_setupui["Worker setup<br/>[SetupWorker.jsx]"]
  node_setupflow["Setup state hook<br/>[useWorkerSetup.ts]"]
  node_deploy["Deployment service<br/>[index.ts]"]
  node_auth["Login service<br/>[index.ts]"]
end

subgraph group_clients["Web Clients"]
  node_photos["Photos app"]
  node_drive["Drive app<br/>[App.jsx]"]
  node_drivecrypto["Drive encryption<br/>[crypto.js]"]
  node_driveapi["Drive API client<br/>[api.js]"]
  node_drivecache[("Upload sessions<br/>[idb-store.js]")]
  node_sw["Drive service worker<br/>[sw.js]"]
  node_rustcore["Rust client core<br/>[worker.rs]"]
  node_session["Session handling<br/>[session.rs]"]
end

subgraph group_userstack["Per-user Cloud"]
  node_userworker["User API worker<br/>[server.ts]"]
  node_d1[("Metadata index<br/>[d1-adapter.ts]")]
  node_telegram[("Telegram storage")]
end

subgraph group_selfhost["Self-hosting"]
  node_selfcli["Self-host CLI<br/>[daemonclient.mjs]"]
  node_selfsetup["Install setup<br/>[setup.mjs]"]
  node_selfweb["Web deployment command<br/>[web.mjs]"]
  node_firebase["Firebase hosting"]
end

node_user(("Cloud user"))

node_user -->|"uses"| node_accounts
node_accounts -->|"opens setup"| node_setupui
node_setupui -->|"uses setup state"| node_setupflow
node_setupflow -->|"requests provisioning"| node_deploy
node_setupflow -.->|"gets identity token"| node_auth
node_deploy -->|"provisions worker"| node_userworker
node_user -->|"browses library"| node_photos
node_user -->|"manages files"| node_drive
node_drive -->|"encrypts and decrypts"| node_drivecrypto
node_drive -->|"calls API"| node_driveapi
node_drive -->|"stores sessions"| node_drivecache
node_drive -->|"sends metadata"| node_userworker
node_drive -->|"sends encrypted chunks"| node_telegram
node_sw -->|"reads file bytes"| node_telegram
node_drive -->|"registers service worker"| node_sw
node_photos -.->|"uses metadata API"| node_userworker
node_userworker -->|"reads and writes index"| node_d1
node_userworker -->|"uses bot storage"| node_telegram
node_user -->|"runs setup"| node_selfcli
node_selfcli -->|"dispatches setup"| node_selfsetup
node_selfcli -->|"dispatches web deploy"| node_selfweb
node_selfsetup -->|"configures storage"| node_telegram
node_selfsetup -.->|"configures Cloudflare"| node_deploy
node_selfweb -->|"deploys web apps"| node_firebase
node_rustcore -->|"calls metadata routes"| node_userworker
node_session -->|"signs in"| node_auth
node_rustcore -->|"uses session"| node_session

click node_accounts "https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/App.jsx"
click node_setupui "https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/pages/SetupWorker.jsx"
click node_setupflow "https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/hooks/useWorkerSetup.ts"
click node_deploy "https://github.com/myrosama/daemonclient/blob/main/workers/deployment/src/index.ts"
click node_auth "https://github.com/myrosama/daemonclient/blob/main/workers/auth/src/index.ts"
click node_photos "https://github.com/myrosama/daemonclient/tree/main/apps/photos-web/web/src/lib"
click node_drive "https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/App.jsx"
click node_drivecrypto "https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/crypto.js"
click node_driveapi "https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/api.js"
click node_drivecache "https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/idb-store.js"
click node_sw "https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/public/sw.js"
click node_userworker "https://github.com/myrosama/daemonclient/blob/main/workers/user-worker/src/server.ts"
click node_d1 "https://github.com/myrosama/daemonclient/blob/main/workers/user-worker/src/d1-adapter.ts"
click node_selfcli "https://github.com/myrosama/daemonclient/blob/main/selfhost/bin/daemonclient.mjs"
click node_selfsetup "https://github.com/myrosama/daemonclient/blob/main/selfhost/src/commands/setup.mjs"
click node_selfweb "https://github.com/myrosama/daemonclient/blob/main/selfhost/src/commands/web.mjs"
click node_rustcore "https://github.com/myrosama/daemonclient/blob/main/core/dc-core/src/worker.rs"
click node_session "https://github.com/myrosama/daemonclient/blob/main/core/dc-core/src/session.rs"

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_accounts,node_setupui,node_setupflow,node_deploy,node_auth,node_user toneBlue
class node_photos,node_drive,node_drivecrypto,node_driveapi,node_drivecache,node_sw,node_rustcore,node_session toneAmber
class node_userworker,node_d1,node_telegram toneMint
class node_selfcli,node_selfsetup,node_selfweb,node_firebase toneRose
```

## Components

### Account and Provisioning

- [Accounts portal](https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/App.jsx): `apps/accounts-web/src/App.jsx`
- [Worker setup](https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/pages/SetupWorker.jsx): `apps/accounts-web/src/pages/SetupWorker.jsx`
- [Setup state hook](https://github.com/myrosama/daemonclient/blob/main/apps/accounts-web/src/hooks/useWorkerSetup.ts): `apps/accounts-web/src/hooks/useWorkerSetup.ts`
- [Deployment service](https://github.com/myrosama/daemonclient/blob/main/workers/deployment/src/index.ts): `workers/deployment/src/index.ts`
- [Login service](https://github.com/myrosama/daemonclient/blob/main/workers/auth/src/index.ts): `workers/auth/src/index.ts`

### Web Clients

- [Photos app](https://github.com/myrosama/daemonclient/tree/main/apps/photos-web/web/src/lib): `apps/photos-web/web/src/lib`
- [Drive app](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/App.jsx): `apps/drive-web/src/App.jsx`
- [Drive encryption](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/crypto.js): `apps/drive-web/src/crypto.js`
- [Drive API client](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/api.js): `apps/drive-web/src/api.js`
- [Upload sessions](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/src/idb-store.js): `apps/drive-web/src/idb-store.js`
- [Drive service worker](https://github.com/myrosama/daemonclient/blob/main/apps/drive-web/public/sw.js): `apps/drive-web/public/sw.js`
- [Rust client core](https://github.com/myrosama/daemonclient/blob/main/core/dc-core/src/worker.rs): `core/dc-core/src/worker.rs`
- [Session handling](https://github.com/myrosama/daemonclient/blob/main/core/dc-core/src/session.rs): `core/dc-core/src/session.rs`

### Per-user Cloud

- [User API worker](https://github.com/myrosama/daemonclient/blob/main/workers/user-worker/src/server.ts): `workers/user-worker/src/server.ts`
- [Metadata index](https://github.com/myrosama/daemonclient/blob/main/workers/user-worker/src/d1-adapter.ts): `workers/user-worker/src/d1-adapter.ts`
- **Telegram storage**

### Self-hosting

- [Self-host CLI](https://github.com/myrosama/daemonclient/blob/main/selfhost/bin/daemonclient.mjs): `selfhost/bin/daemonclient.mjs`
- [Install setup](https://github.com/myrosama/daemonclient/blob/main/selfhost/src/commands/setup.mjs): `selfhost/src/commands/setup.mjs`
- [Web deployment command](https://github.com/myrosama/daemonclient/blob/main/selfhost/src/commands/web.mjs): `selfhost/src/commands/web.mjs`
- **Firebase hosting**

### Other components

- **Cloud user**

## Connections

- Cloud user → Accounts portal: uses
- Accounts portal → Worker setup: opens setup (evidence: `apps/accounts-web/src/App.jsx`)
- Worker setup → Setup state hook: uses setup state (evidence: `apps/accounts-web/src/pages/SetupWorker.jsx`)
- Setup state hook → Deployment service: requests provisioning (evidence: `apps/accounts-web/src/hooks/useWorkerSetup.ts`)
- Setup state hook → Login service: gets identity token
- Deployment service → User API worker: provisions worker
- Cloud user → Photos app: browses library
- Cloud user → Drive app: manages files
- Drive app → Drive encryption: encrypts and decrypts (evidence: `apps/drive-web/src/App.jsx`)
- Drive app → Drive API client: calls API (evidence: `apps/drive-web/src/App.jsx`)
- Drive app → Upload sessions: stores sessions (evidence: `apps/drive-web/src/App.jsx`)
- Drive app → User API worker: sends metadata
- Drive app → Telegram storage: sends encrypted chunks
- Drive service worker → Telegram storage: reads file bytes
- Drive app → Drive service worker: registers service worker
- Photos app → User API worker: uses metadata API
- User API worker → Metadata index: reads and writes index (evidence: `workers/user-worker/src/server.ts`)
- User API worker → Telegram storage: uses bot storage
- Cloud user → Self-host CLI: runs setup
- Self-host CLI → Install setup: dispatches setup (evidence: `selfhost/bin/daemonclient.mjs`)
- Self-host CLI → Web deployment command: dispatches web deploy (evidence: `selfhost/bin/daemonclient.mjs`)
- Install setup → Telegram storage: configures storage (evidence: `selfhost/src/commands/setup.mjs`)
- Install setup → Deployment service: configures Cloudflare
- Web deployment command → Firebase hosting: deploys web apps
- Rust client core → User API worker: calls metadata routes
- Session handling → Login service: signs in (evidence: `core/dc-core/src/session.rs`)
- Rust client core → Session handling: uses session (evidence: `core/dc-core/src/worker.rs`)
