# encrize/anime architecture

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

- Interactive diagram: https://gitdiagram.com/encrize/anime
- Repository: https://github.com/encrize/anime

## Overview

AniWired is an anime discovery and streaming SPA with account-based watch-history sync and social features, backed by a Cloudflare Worker and D1. The main user journey is browse or search for a title, open it, choose a playback source, and sync viewing progress; users can also manage accounts, comments, profiles, and follows. The source excerpts show frontend discovery, player behavior, progress handling, API calls, and Worker logic. Other capabilities and links between frontend and backend are included where the README documents them; unsampled implementation details are not assumed.

Main entry points: [`public/app.js`](https://github.com/encrize/anime/blob/main/public/app.js) (SPA Discovery), [`public/account.js`](https://github.com/encrize/anime/blob/main/public/account.js) (Account and History UI), [`worker/worker.js`](https://github.com/encrize/anime/blob/main/worker/worker.js) (Kodik Proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Discovery"]
  node_app["SPA Discovery<br/>[app.js]"]
  node_anime_sources["AniLibria Catalog"]
  node_anilist["AniList GraphQL"]
end

subgraph group_playback["Playback"]
  node_title_player["Title Player<br/>[app.js]"]
  node_kodik_embed["Kodik Embed<br/>[app.js]"]
end

subgraph group_accounts["Accounts and Sync"]
  node_account_ui["Account and History UI<br/>[account.js]"]
end

subgraph group_social["Social"]
  node_social_ui["Social UI<br/>[account.js]"]
end

subgraph group_backend["Worker Backend"]
  node_kodik_proxy["Kodik Proxy<br/>[worker.js]"]
  node_auth_api["Auth API<br/>[worker.js]"]
  node_progress_api["Progress API<br/>[worker.js]"]
  node_social_api["Social API<br/>[worker.js]"]
  node_comments_api["Comments API<br/>[worker.js]"]
  node_settings_api["Settings API<br/>[worker.js]"]
  node_worker_entry["Worker and Asset Routing<br/>[worker.js]"]
end

node_viewer(("Viewer"))
node_kodik_service["Kodik Service"]
node_d1[("Cloudflare D1")]
node_tmdb["TMDB"]

node_viewer -->|"browses"| node_app
node_app -->|"searches catalog"| node_anime_sources
node_app -->|"queries titles"| node_anilist
node_app -->|"fetches artwork"| node_tmdb
node_app -->|"opens titles"| node_title_player
node_title_player -->|"selects source"| node_kodik_embed
node_kodik_embed -->|"requests search"| node_kodik_proxy
node_kodik_proxy -->|"proxies requests"| node_kodik_service
node_viewer -->|"manages account"| node_account_ui
node_account_ui -->|"sends auth requests"| node_auth_api
node_account_ui -->|"syncs progress"| node_progress_api
node_viewer -->|"uses social features"| node_social_ui
node_social_ui -->|"manages follows"| node_social_api
node_social_ui -->|"posts comments"| node_comments_api
node_account_ui -->|"updates privacy"| node_settings_api
node_app -->|"loads SPA assets"| node_worker_entry
node_auth_api -->|"reads and writes"| node_d1
node_progress_api -->|"merges progress"| node_d1
node_social_api -->|"reads and writes"| node_d1
node_comments_api -->|"reads and writes"| node_d1
node_settings_api -->|"reads and writes"| node_d1
node_kodik_proxy -->|"checks rate limits"| node_d1

click node_app "https://github.com/encrize/anime/blob/main/public/app.js"
click node_title_player "https://github.com/encrize/anime/blob/main/public/app.js"
click node_kodik_embed "https://github.com/encrize/anime/blob/main/public/app.js"
click node_kodik_proxy "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_account_ui "https://github.com/encrize/anime/blob/main/public/account.js"
click node_auth_api "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_progress_api "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_social_ui "https://github.com/encrize/anime/blob/main/public/account.js"
click node_social_api "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_comments_api "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_settings_api "https://github.com/encrize/anime/blob/main/worker/worker.js"
click node_worker_entry "https://github.com/encrize/anime/blob/main/worker/worker.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_anime_sources,node_anilist,node_viewer toneBlue
class node_title_player,node_kodik_embed,node_d1 toneAmber
class node_account_ui toneMint
class node_social_ui toneRose
class node_kodik_proxy,node_auth_api,node_progress_api,node_social_api,node_comments_api,node_settings_api,node_worker_entry,node_kodik_service,node_tmdb toneIndigo
```

## Components

### Discovery

- [SPA Discovery](https://github.com/encrize/anime/blob/main/public/app.js): `public/app.js`
- **AniLibria Catalog**
- **AniList GraphQL**

### Playback

- [Title Player](https://github.com/encrize/anime/blob/main/public/app.js): `public/app.js`
- [Kodik Embed](https://github.com/encrize/anime/blob/main/public/app.js): `public/app.js`

### Accounts and Sync

- [Account and History UI](https://github.com/encrize/anime/blob/main/public/account.js): `public/account.js`

### Social

- [Social UI](https://github.com/encrize/anime/blob/main/public/account.js): `public/account.js`

### Worker Backend

- [Kodik Proxy](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Auth API](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Progress API](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Social API](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Comments API](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Settings API](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`
- [Worker and Asset Routing](https://github.com/encrize/anime/blob/main/worker/worker.js): `worker/worker.js`

### Other components

- **Viewer**
- **Kodik Service**
- **Cloudflare D1**
- **TMDB**

## Connections

- Viewer → SPA Discovery: browses (evidence: `README.md`)
- SPA Discovery → AniLibria Catalog: searches catalog (evidence: `README.md`)
- SPA Discovery → AniList GraphQL: queries titles (evidence: `public/app.js`)
- SPA Discovery → TMDB: fetches artwork (evidence: `public/app.js`)
- SPA Discovery → Title Player: opens titles (evidence: `public/app.js`)
- Title Player → Kodik Embed: selects source (evidence: `public/app.js`)
- Kodik Embed → Kodik Proxy: requests search (evidence: `public/app.js`)
- Kodik Proxy → Kodik Service: proxies requests (evidence: `README.md`)
- Viewer → Account and History UI: manages account (evidence: `README.md`)
- Account and History UI → Auth API: sends auth requests (evidence: `README.md`)
- Account and History UI → Progress API: syncs progress (evidence: `README.md`)
- Viewer → Social UI: uses social features (evidence: `README.md`)
- Social UI → Social API: manages follows (evidence: `README.md`)
- Social UI → Comments API: posts comments (evidence: `public/account.js`)
- Account and History UI → Settings API: updates privacy (evidence: `README.md`)
- SPA Discovery → Worker and Asset Routing: loads SPA assets (evidence: `README.md`)
- Auth API → Cloudflare D1: reads and writes (evidence: `README.md`)
- Progress API → Cloudflare D1: merges progress (evidence: `README.md`)
- Social API → Cloudflare D1: reads and writes (evidence: `README.md`)
- Comments API → Cloudflare D1: reads and writes (evidence: `README.md`)
- Settings API → Cloudflare D1: reads and writes (evidence: `README.md`)
- Kodik Proxy → Cloudflare D1: checks rate limits (evidence: `README.md`)
