# minhmc2007/otakuhub architecture

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

- Interactive diagram: https://gitdiagram.com/minhmc2007/otakuhub
- Repository: https://github.com/minhmc2007/otakuhub

## Overview

OtakuHub is a self-hosted anime browsing and streaming web app. A user signs in, searches or browses the provider, selects an episode and server, then plays the source stream or requests a background conversion; playlists and watch progress are stored per user. The graph preserves the documented account, library, settings, caching, metrics, and transcoding capabilities. Some wiring is based on README documentation because the sampled excerpts do not include all handler, state, proxy, or job implementations.

Main entry points: [`src/web/pages.rs`](https://github.com/minhmc2007/otakuhub/blob/dev/src/web/pages.rs) (Page workflows), [`src/db/mod.rs`](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/mod.rs) (SQLite database), [`src/media/jobs.rs`](https://github.com/minhmc2007/otakuhub/blob/dev/src/media/jobs.rs) (Conversion jobs), [`src/web/mod.rs`](https://github.com/minhmc2007/otakuhub/blob/dev/src/web/mod.rs) (Routes and handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_router["Routes and handlers<br/>[mod.rs]"]
  node_pages["Page workflows<br/>[pages.rs]"]
  node_views["View models<br/>[views.rs]"]
  node_browser["Browser UI<br/>[app.js]"]
end

subgraph group_provider["Anime provider"]
  node_source["Provider interface<br/>[mod.rs]"]
  node_hianime["HiAnime adapter<br/>[hianime.rs]"]
end

subgraph group_playback["Playback pipeline"]
  node_media_jobs["Conversion jobs<br/>[jobs.rs]"]
  node_transcode["Transcoding<br/>[transcode.rs]"]
  node_proxy["Media proxy<br/>[proxy.rs]"]
  node_cache[("Media cache<br/>[cache.rs]")]
end

subgraph group_accounts["Accounts and library"]
  node_auth["Authentication<br/>[auth.rs]"]
  node_sessions["Sessions<br/>[sessions.rs]"]
  node_users["User accounts<br/>[users.rs]"]
  node_db[("SQLite database<br/>[mod.rs]")]
  node_library["Library data<br/>[playlists.rs]"]
  node_history["Watch progress<br/>[progress.rs]"]
  node_settings["User settings<br/>[settings.rs]"]
end

subgraph group_runtime["Runtime services"]
  node_server["HTTP server<br/>[main.rs]"]
  node_metrics["System metrics<br/>[metrics.rs]"]
  node_state["Application state<br/>[state.rs]"]
end

node_viewer(("Viewer"))
node_provider_service{{"Anime provider"}}
node_encoder{{"FFmpeg encoders"}}

node_viewer -->|"sends requests"| node_router
node_browser -->|"requests updates"| node_router
node_server -->|"serves routes"| node_router
node_router -->|"dispatches"| node_pages
node_pages -->|"renders"| node_views
node_pages -->|"requires identity"| node_auth
node_auth -->|"resolves token"| node_sessions
node_sessions -->|"reads and writes"| node_db
node_auth -->|"checks passwords"| node_users
node_users -->|"reads and writes"| node_db
node_pages -->|"searches and fetches"| node_source
node_source -->|"delegates provider calls"| node_hianime
node_hianime -->|"fetches anime data"| node_provider_service
node_pages -->|"manages playlists"| node_library
node_library -->|"reads and writes"| node_db
node_pages -->|"records progress"| node_history
node_history -->|"reads and writes"| node_db
node_pages -->|"loads preferences"| node_settings
node_settings -->|"reads and writes"| node_db
node_pages -->|"requests conversion"| node_media_jobs
node_media_jobs -->|"runs conversion"| node_transcode
node_transcode -->|"encodes HLS"| node_encoder
node_media_jobs -->|"stores output"| node_cache
node_pages -->|"serves media"| node_proxy
node_proxy -->|"reads and writes"| node_cache
node_proxy -->|"fetches upstream media"| node_provider_service
node_pages -->|"samples usage"| node_metrics
node_server -->|"builds state"| node_state
node_server -->|"reaps stalled jobs"| node_media_jobs

click node_server "https://github.com/minhmc2007/otakuhub/blob/dev/src/main.rs"
click node_router "https://github.com/minhmc2007/otakuhub/blob/dev/src/web/mod.rs"
click node_pages "https://github.com/minhmc2007/otakuhub/blob/dev/src/web/pages.rs"
click node_views "https://github.com/minhmc2007/otakuhub/blob/dev/src/web/views.rs"
click node_browser "https://github.com/minhmc2007/otakuhub/blob/dev/static/app.js"
click node_auth "https://github.com/minhmc2007/otakuhub/blob/dev/src/auth.rs"
click node_sessions "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/sessions.rs"
click node_users "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/users.rs"
click node_db "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/mod.rs"
click node_library "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/playlists.rs"
click node_history "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/progress.rs"
click node_settings "https://github.com/minhmc2007/otakuhub/blob/dev/src/db/settings.rs"
click node_source "https://github.com/minhmc2007/otakuhub/blob/dev/src/source/mod.rs"
click node_hianime "https://github.com/minhmc2007/otakuhub/blob/dev/src/source/hianime.rs"
click node_media_jobs "https://github.com/minhmc2007/otakuhub/blob/dev/src/media/jobs.rs"
click node_transcode "https://github.com/minhmc2007/otakuhub/blob/dev/src/media/transcode.rs"
click node_proxy "https://github.com/minhmc2007/otakuhub/blob/dev/src/proxy.rs"
click node_cache "https://github.com/minhmc2007/otakuhub/blob/dev/src/cache.rs"
click node_metrics "https://github.com/minhmc2007/otakuhub/blob/dev/src/metrics.rs"
click node_state "https://github.com/minhmc2007/otakuhub/blob/dev/src/state.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_router,node_pages,node_views,node_browser,node_viewer toneBlue
class node_source,node_hianime toneAmber
class node_media_jobs,node_transcode,node_proxy,node_cache toneMint
class node_auth,node_sessions,node_users,node_db,node_library,node_history,node_settings toneRose
class node_server,node_metrics,node_state,node_provider_service,node_encoder toneIndigo
```

## Components

### Web experience

- [Routes and handlers](https://github.com/minhmc2007/otakuhub/blob/dev/src/web/mod.rs): `src/web/mod.rs`
- [Page workflows](https://github.com/minhmc2007/otakuhub/blob/dev/src/web/pages.rs): `src/web/pages.rs`
- [View models](https://github.com/minhmc2007/otakuhub/blob/dev/src/web/views.rs): `src/web/views.rs`
- [Browser UI](https://github.com/minhmc2007/otakuhub/blob/dev/static/app.js): `static/app.js`

### Anime provider

- [Provider interface](https://github.com/minhmc2007/otakuhub/blob/dev/src/source/mod.rs): `src/source/mod.rs`
- [HiAnime adapter](https://github.com/minhmc2007/otakuhub/blob/dev/src/source/hianime.rs): `src/source/hianime.rs`

### Playback pipeline

- [Conversion jobs](https://github.com/minhmc2007/otakuhub/blob/dev/src/media/jobs.rs): `src/media/jobs.rs`
- [Transcoding](https://github.com/minhmc2007/otakuhub/blob/dev/src/media/transcode.rs): `src/media/transcode.rs`
- [Media proxy](https://github.com/minhmc2007/otakuhub/blob/dev/src/proxy.rs): `src/proxy.rs`
- [Media cache](https://github.com/minhmc2007/otakuhub/blob/dev/src/cache.rs): `src/cache.rs`

### Accounts and library

- [Authentication](https://github.com/minhmc2007/otakuhub/blob/dev/src/auth.rs): `src/auth.rs`
- [Sessions](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/sessions.rs): `src/db/sessions.rs`
- [User accounts](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/users.rs): `src/db/users.rs`
- [SQLite database](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/mod.rs): `src/db/mod.rs`
- [Library data](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/playlists.rs): `src/db/playlists.rs`
- [Watch progress](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/progress.rs): `src/db/progress.rs`
- [User settings](https://github.com/minhmc2007/otakuhub/blob/dev/src/db/settings.rs): `src/db/settings.rs`

### Runtime services

- [HTTP server](https://github.com/minhmc2007/otakuhub/blob/dev/src/main.rs): `src/main.rs`
- [System metrics](https://github.com/minhmc2007/otakuhub/blob/dev/src/metrics.rs): `src/metrics.rs`
- [Application state](https://github.com/minhmc2007/otakuhub/blob/dev/src/state.rs): `src/state.rs`

### Other components

- **Viewer**
- **Anime provider**
- **FFmpeg encoders**

## Connections

- Viewer → Routes and handlers: sends requests
- Browser UI → Routes and handlers: requests updates
- HTTP server → Routes and handlers: serves routes
- Routes and handlers → Page workflows: dispatches
- Page workflows → View models: renders
- Page workflows → Authentication: requires identity
- Authentication → Sessions: resolves token
- Sessions → SQLite database: reads and writes
- Authentication → User accounts: checks passwords
- User accounts → SQLite database: reads and writes
- Page workflows → Provider interface: searches and fetches
- Provider interface → HiAnime adapter: delegates provider calls
- HiAnime adapter → Anime provider: fetches anime data
- Page workflows → Library data: manages playlists
- Library data → SQLite database: reads and writes
- Page workflows → Watch progress: records progress
- Watch progress → SQLite database: reads and writes
- Page workflows → User settings: loads preferences
- User settings → SQLite database: reads and writes
- Page workflows → Conversion jobs: requests conversion
- Conversion jobs → Transcoding: runs conversion
- Transcoding → FFmpeg encoders: encodes HLS
- Conversion jobs → Media cache: stores output
- Page workflows → Media proxy: serves media
- Media proxy → Media cache: reads and writes
- Media proxy → Anime provider: fetches upstream media
- Page workflows → System metrics: samples usage
- HTTP server → Application state: builds state
- HTTP server → Conversion jobs: reaps stalled jobs
