# dogecn/infoto architecture

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

- Interactive diagram: https://gitdiagram.com/dogecn/infoto
- Repository: https://github.com/dogecn/infoto

## Overview

Infoto is a collaborative photo gallery with uploads, reactions, announcements, feedback, and administrative data management. The main flow runs from browser edits and uploads through a persistent operation log and sync client to the Worker’s /sync handler, which updates the database and returns a gallery snapshot for the UI. Separate paths handle media delivery and admin/migration endpoints. Several subsystem links are based on SOURCE INDEX references; unsampled route and upload details are not expanded into unverified call chains.

Main entry points: [`src/worker/routes/sync.ts`](https://github.com/dogecn/infoto/blob/main/src/worker/routes/sync.ts) (Sync endpoint), [`web/src/App.svelte`](https://github.com/dogecn/infoto/blob/main/web/src/App.svelte) (Gallery UI), [`src/worker/app.ts`](https://github.com/dogecn/infoto/blob/main/src/worker/app.ts) (HTTP app), [`src/worker/routes/media.ts`](https://github.com/dogecn/infoto/blob/main/src/worker/routes/media.ts) (Media endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Gallery web app"]
  node_app["Gallery UI<br/>[App.svelte]"]
  node_store["App state<br/>[appStore.svelte.ts]"]
  node_settings["Gallery settings<br/>[settings.ts]"]
  node_engine["Sync engine<br/>[engine.ts]"]
  node_oplog[("Operation log<br/>[oplog.ts]")]
  node_syncclient["Sync client<br/>[syncClient.ts]"]
  node_identity["Identity flow<br/>[identity.ts]"]
end

subgraph group_upload["Media uploads"]
  node_uploadui["Upload state"]
  node_transcode["Upload pipeline<br/>[pipeline.ts]"]
  node_uploadclient["Upload client<br/>[uploadClient.ts]"]
end

subgraph group_worker["Worker API"]
  node_workerapp["HTTP app<br/>[app.ts]"]
  node_syncroute["Sync endpoint<br/>[sync.ts]"]
  node_mediaroute["Media endpoint<br/>[media.ts]"]
  node_adminroute["Admin routes<br/>[admin.ts]"]
  node_migrateroute["Migration routes<br/>[migrate.ts]"]
  node_identitysvc["Identity service<br/>[identity.ts]"]
  node_dbcontract["Database contract<br/>[db.ts]"]
  node_d1["D1 adapter<br/>[db-d1.ts]"]
  node_turnstile["Turnstile verifier<br/>[turnstile.ts]"]
end

subgraph group_shared["Shared contracts"]
  node_types["Domain contracts<br/>[types.ts]"]
  node_mediaids["Media IDs<br/>[media.ts]"]
  node_copy["Locale copy<br/>[copy.ts]"]
end

node_visitor(("Gallery visitor"))
node_mediahost["Media host"]
node_challenge["Turnstile"]
node_gallerydb[("Application database")]

node_visitor -->|"uses"| node_app
node_app -->|"reads state"| node_store
node_app -->|"loads"| node_settings
node_app -->|"starts identity"| node_identity
node_app -->|"requests sync"| node_syncclient
node_store -->|"uses"| node_engine
node_engine -->|"persists operations"| node_oplog
node_engine -->|"posts batches"| node_syncclient
node_identity -->|"posts identity"| node_syncclient
node_app -->|"uses"| node_uploadui
node_uploadui -.->|"coordinates upload"| node_transcode
node_transcode -->|"records upload op"| node_oplog
node_uploadui -.->|"uploads media"| node_uploadclient
node_workerapp -->|"routes /sync"| node_syncroute
node_workerapp -->|"routes /l/:id36"| node_mediaroute
node_workerapp -->|"mounts admin"| node_adminroute
node_workerapp -->|"routes migration"| node_migrateroute
node_syncroute -->|"reads and writes"| node_dbcontract
node_syncroute -->|"resolves identity"| node_identitysvc
node_syncroute -->|"verifies challenge"| node_turnstile
node_syncroute -->|"validates media URL"| node_mediaroute
node_mediaroute -->|"looks up media"| node_dbcontract
node_mediaroute -->|"decodes ID"| node_mediaids
node_dbcontract -->|"implemented by"| node_d1
node_d1 -.->|"accesses"| node_gallerydb
node_turnstile -.->|"verifies token"| node_challenge
node_transcode -.->|"sends media"| node_mediahost
node_syncroute -->|"uses payload contract"| node_types
node_syncclient -->|"POST /sync"| node_syncroute

click node_app "https://github.com/dogecn/infoto/blob/main/web/src/App.svelte"
click node_store "https://github.com/dogecn/infoto/blob/main/web/src/state/appStore.svelte.ts"
click node_settings "https://github.com/dogecn/infoto/blob/main/web/src/settings.ts"
click node_engine "https://github.com/dogecn/infoto/blob/main/web/src/core/engine.ts"
click node_oplog "https://github.com/dogecn/infoto/blob/main/web/src/core/oplog.ts"
click node_syncclient "https://github.com/dogecn/infoto/blob/main/web/src/core/api/syncClient.ts"
click node_identity "https://github.com/dogecn/infoto/blob/main/web/src/core/identity.ts"
click node_uploadui "https://github.com/dogecn/infoto/blob/main/web/src/state/uploadStore.svelte.ts"
click node_transcode "https://github.com/dogecn/infoto/blob/main/web/src/transcode/pipeline.ts"
click node_uploadclient "https://github.com/dogecn/infoto/blob/main/web/src/core/api/uploadClient.ts"
click node_workerapp "https://github.com/dogecn/infoto/blob/main/src/worker/app.ts"
click node_syncroute "https://github.com/dogecn/infoto/blob/main/src/worker/routes/sync.ts"
click node_mediaroute "https://github.com/dogecn/infoto/blob/main/src/worker/routes/media.ts"
click node_adminroute "https://github.com/dogecn/infoto/blob/main/src/worker/routes/admin.ts"
click node_migrateroute "https://github.com/dogecn/infoto/blob/main/src/worker/routes/migrate.ts"
click node_identitysvc "https://github.com/dogecn/infoto/blob/main/src/worker/identity.ts"
click node_dbcontract "https://github.com/dogecn/infoto/blob/main/src/worker/db.ts"
click node_d1 "https://github.com/dogecn/infoto/blob/main/src/worker/db-d1.ts"
click node_turnstile "https://github.com/dogecn/infoto/blob/main/src/worker/turnstile.ts"
click node_types "https://github.com/dogecn/infoto/blob/main/src/shared/types.ts"
click node_mediaids "https://github.com/dogecn/infoto/blob/main/src/shared/media.ts"
click node_copy "https://github.com/dogecn/infoto/blob/main/src/shared/copy.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_app,node_store,node_settings,node_engine,node_oplog,node_syncclient,node_identity toneBlue
class node_uploadui,node_transcode,node_uploadclient,node_gallerydb toneAmber
class node_workerapp,node_syncroute,node_mediaroute,node_adminroute,node_migrateroute,node_identitysvc,node_dbcontract,node_d1,node_turnstile toneMint
class node_types,node_mediaids,node_copy toneRose
class node_visitor,node_mediahost,node_challenge toneIndigo
```

## Components

### Gallery web app

- [Gallery UI](https://github.com/dogecn/infoto/blob/main/web/src/App.svelte): `web/src/App.svelte`
- [App state](https://github.com/dogecn/infoto/blob/main/web/src/state/appStore.svelte.ts): `web/src/state/appStore.svelte.ts`
- [Gallery settings](https://github.com/dogecn/infoto/blob/main/web/src/settings.ts): `web/src/settings.ts`
- [Sync engine](https://github.com/dogecn/infoto/blob/main/web/src/core/engine.ts): `web/src/core/engine.ts`
- [Operation log](https://github.com/dogecn/infoto/blob/main/web/src/core/oplog.ts): `web/src/core/oplog.ts`
- [Sync client](https://github.com/dogecn/infoto/blob/main/web/src/core/api/syncClient.ts): `web/src/core/api/syncClient.ts`
- [Identity flow](https://github.com/dogecn/infoto/blob/main/web/src/core/identity.ts): `web/src/core/identity.ts`

### Media uploads

- [Upload state](https://github.com/dogecn/infoto/blob/main/web/src/state/uploadStore.svelte.ts): `web/src/state/uploadStore.svelte.ts`
- [Upload pipeline](https://github.com/dogecn/infoto/blob/main/web/src/transcode/pipeline.ts): `web/src/transcode/pipeline.ts`
- [Upload client](https://github.com/dogecn/infoto/blob/main/web/src/core/api/uploadClient.ts): `web/src/core/api/uploadClient.ts`

### Worker API

- [HTTP app](https://github.com/dogecn/infoto/blob/main/src/worker/app.ts): `src/worker/app.ts`
- [Sync endpoint](https://github.com/dogecn/infoto/blob/main/src/worker/routes/sync.ts): `src/worker/routes/sync.ts`
- [Media endpoint](https://github.com/dogecn/infoto/blob/main/src/worker/routes/media.ts): `src/worker/routes/media.ts`
- [Admin routes](https://github.com/dogecn/infoto/blob/main/src/worker/routes/admin.ts): `src/worker/routes/admin.ts`
- [Migration routes](https://github.com/dogecn/infoto/blob/main/src/worker/routes/migrate.ts): `src/worker/routes/migrate.ts`
- [Identity service](https://github.com/dogecn/infoto/blob/main/src/worker/identity.ts): `src/worker/identity.ts`
- [Database contract](https://github.com/dogecn/infoto/blob/main/src/worker/db.ts): `src/worker/db.ts`
- [D1 adapter](https://github.com/dogecn/infoto/blob/main/src/worker/db-d1.ts): `src/worker/db-d1.ts`
- [Turnstile verifier](https://github.com/dogecn/infoto/blob/main/src/worker/turnstile.ts): `src/worker/turnstile.ts`

### Shared contracts

- [Domain contracts](https://github.com/dogecn/infoto/blob/main/src/shared/types.ts): `src/shared/types.ts`
- [Media IDs](https://github.com/dogecn/infoto/blob/main/src/shared/media.ts): `src/shared/media.ts`
- [Locale copy](https://github.com/dogecn/infoto/blob/main/src/shared/copy.ts): `src/shared/copy.ts`

### Other components

- **Gallery visitor**
- **Media host**
- **Turnstile**
- **Application database**

## Connections

- Gallery visitor → Gallery UI: uses (evidence: `web/src/App.svelte`)
- Gallery UI → App state: reads state (evidence: `web/src/App.svelte`)
- Gallery UI → Gallery settings: loads (evidence: `web/src/App.svelte`)
- Gallery UI → Identity flow: starts identity (evidence: `web/src/App.svelte`)
- Gallery UI → Sync client: requests sync (evidence: `web/src/App.svelte`)
- App state → Sync engine: uses (evidence: `web/src/state/appStore.svelte.ts`)
- Sync engine → Operation log: persists operations (evidence: `web/src/core/engine.ts`)
- Sync engine → Sync client: posts batches (evidence: `web/src/core/engine.ts`)
- Identity flow → Sync client: posts identity (evidence: `web/src/core/identity.ts`)
- Gallery UI → Upload state: uses (evidence: `web/src/App.svelte`)
- Upload state → Upload pipeline: coordinates upload
- Upload pipeline → Operation log: records upload op (evidence: `web/src/transcode/pipeline.ts`)
- Upload state → Upload client: uploads media
- HTTP app → Sync endpoint: routes /sync (evidence: `src/worker/app.ts`)
- HTTP app → Media endpoint: routes /l/:id36 (evidence: `src/worker/app.ts`)
- HTTP app → Admin routes: mounts admin (evidence: `src/worker/app.ts`)
- HTTP app → Migration routes: routes migration (evidence: `src/worker/app.ts`)
- Sync endpoint → Database contract: reads and writes (evidence: `src/worker/routes/sync.ts`)
- Sync endpoint → Identity service: resolves identity (evidence: `src/worker/routes/sync.ts`)
- Sync endpoint → Turnstile verifier: verifies challenge (evidence: `src/worker/routes/sync.ts`)
- Sync endpoint → Media endpoint: validates media URL (evidence: `src/worker/routes/sync.ts`)
- Media endpoint → Database contract: looks up media (evidence: `src/worker/routes/media.ts`)
- Media endpoint → Media IDs: decodes ID (evidence: `src/worker/routes/media.ts`)
- Database contract → D1 adapter: implemented by (evidence: `src/worker/db-d1.ts`)
- D1 adapter → Application database: accesses
- Turnstile verifier → Turnstile: verifies token
- Upload pipeline → Media host: sends media
- Sync endpoint → Domain contracts: uses payload contract (evidence: `src/worker/routes/sync.ts`)
- Sync client → Sync endpoint: POST /sync (evidence: `web/src/core/api/syncClient.ts`)
