How 5rahim/seanime works
Purpose and deployable surfaces
Seanime is a local-first media server for anime libraries, manga, downloads, streams, and playback, exposed through a browser UI, Electron desktop client, and mobile-facing server surface. The Go server starts at main.go; mobile embedding is mobile/mobile.go. The React client starts at seanime-web/src/main.tsx; Electron/Denshi starts at seanime-denshi/src/main/index.ts.
Application composition and API boundary
Core bootstrap owns configuration, module wiring, migrations, security, background watchers, and server lifecycle: internal/core/app.go, internal/core/modules.go, internal/server/server.go. HTTP handlers form the explicit UI/API boundary and route requests into domain repositories: internal/handlers/routes.go, internal/handlers/request_boundary.go, internal/handlers/response.go. WebSockets publish server-side changes to connected clients: internal/events/websocket.go, internal/handlers/websocket.go.
Persistent library and metadata pipeline
Database models and persistence cover accounts, settings, tokens, media, local files, torrent/debrid state, playlists, and scan records: internal/database/db/db.go, internal/database/models/models.go, internal/database/db/localfiles.go. Library scanning walks and normalizes arbitrary filesystem layouts, matches files to media, hydrates metadata, and can watch for changes: internal/library/scanner/scan.go, internal/library/scanner/matcher.go, internal/library/scanner/watcher.go. Anime domain collections and episode/file state are represented in internal/library/anime/collection.go, internal/library/anime/entry.go.
External content and tracker integrations
AniList is the principal tracker/metadata source, implemented as a generated GraphQL client plus queries and cache layer: internal/api/anilist/client.go, internal/api/anilist/queries/anime.graphql, internal/api/anilist/localcache.go. Metadata providers and alternative APIs sit behind provider abstractions: internal/api/metadata_provider/provider.go, internal/api/mal/wrapper.go. Offline/shared platform variants isolate availability and caching behavior: internal/platforms/platform/platform.go, internal/platforms/offline_platform/offline_platform.go.
Acquisition, streaming, and playback
Torrent search/selection feeds supported torrent clients or direct torrent streaming: internal/torrents/torrent/search.go, internal/torrent_clients/torrent_client/repository.go, internal/torrentstream/stream.go. Debrid providers abstract AllDebrid, Real-Debrid, Premiumize, and Torbox; direct-stream orchestration also supports local files and URLs: internal/debrid/client/repository.go, internal/directstream/manager.go, internal/directstream/serve.go. Browser playback selects direct play or transcoding/HLS-style streaming: internal/mediastream/playback.go, internal/mediastream/transcode.go, internal/mediastream/cassette/pipeline.go. External desktop players integrate through MPV/VLC/MPC-HC adapters: internal/mediaplayers/mpv/mpv.go, internal/mediaplayers/vlc/vlc.go.
Extensions and plugin runtime
Extensions provide torrent, online-stream, manga, custom-source, and plugin capabilities. The extension repository installs/configures sources and executes JavaScript through Goja: internal/extension_repo/repository.go, internal/extension_repo/goja.go, internal/goja/goja_runtime/goja_runtime_manager.go. Plugin-facing server APIs and UI capabilities are exposed through a separate plugin layer: internal/plugin/plugin_app.go, internal/plugin/ui/ui.go. Generated endpoint and hook contracts keep Go handlers and TypeScript API clients aligned: codegen/main.go, codegen/generated/handlers.json, seanime-web/src/api/generated/endpoints.ts.
Clients, desktop boundary, and infrastructure
The React/Rsbuild client uses generated request hooks and route modules to call the local/server API: seanime-web/src/api/client/requests.ts, seanime-web/src/api/hooks/anime.hooks.ts, seanime-web/src/routes/__root.tsx. Denshi is an Electron host that manages desktop runtime and embedded MPV core, while loading the web UI: seanime-denshi/src/main/desktop-runtime.ts, seanime-denshi/src/main/mpv-core.ts, seanime-denshi/src/preload.mjs. External services include AniList, optional Discord RPC, torrent clients (qBittorrent/Transmission), debrid services, extension-provided sources, and optional Chromecast support.
Main entry points: routes.go HTTP API boundary · app.go Application bootstrap · scan.go Library scanner · main.tsx React web client
Components 21
Server Core
- Go server entry
main.go - Mobile embedding
mobile/mobile.go - Application bootstrap · Owns modules, migrations, security, watchers, and lifecycle.
internal/core/app.go - HTTP API boundary · Routes UI requests into domain repositories.
internal/handlers/routes.go - Change WebSockets
internal/events/websocket.go
Library & Metadata
- Library database · Stores accounts, media, files, downloads, playlists, and scan state.
internal/database/db/db.go - Library scanner · Normalizes layouts, matches files, hydrates metadata, and watches changes.
internal/library/scanner/scan.go - Anime collections
internal/library/anime/collection.go - AniList integration · Principal tracker and metadata source with local cache.
internal/api/anilist/client.go - Metadata providers
internal/api/metadata_provider/provider.go - Platform variants · Encapsulates offline and shared-platform behavior.
internal/platforms/platform/platform.go
Acquisition & Playback
- Torrent search
internal/torrents/torrent/search.go - Torrent clients · Connects supported clients such as qBittorrent and Transmission.
internal/torrent_clients/torrent_client/repository.go - Direct stream manager · Orchestrates local files, URLs, debrid, and torrent streams.
internal/directstream/manager.go - Debrid providers
internal/debrid/client/repository.go - Browser playback · Selects direct play or transcoding/HLS delivery.
internal/mediastream/playback.go
Clients & Extensions
- Extension runtime · Installs sources and runs torrent, stream, manga, and custom extensions.
internal/extension_repo/repository.go - Plugin API & UI
internal/plugin/plugin_app.go - React web client · Uses generated API hooks and route modules.
seanime-web/src/main.tsx - Denshi desktop host · Loads the web UI and manages embedded MPV.
seanime-denshi/src/main/index.ts - API contract generation · Keeps Go handlers and TypeScript endpoint clients aligned.
codegen/main.go
Connections 28
- Go server entry → Application bootstrap: starts
- Mobile embedding → Application bootstrap: embeds
- Application bootstrap → HTTP API boundary: serves
- Application bootstrap → Library scanner: runs scans/watchers
- Application bootstrap → Library database: migrates
- HTTP API boundary → Library database: reads and writes
- HTTP API boundary → Anime collections: queries
- HTTP API boundary → Torrent search: searches
- HTTP API boundary → Direct stream manager: requests streams
- HTTP API boundary → Browser playback: starts playback
- Library scanner → Library database: persists files and scans
- Library scanner → Anime collections: matches entries
- Anime collections → AniList integration: hydrates metadata
- Metadata providers → AniList integration: includes
- Platform variants → Metadata providers: controls availability
- Torrent search → Extension runtime: uses source extensions
- Torrent search → Torrent clients: sends downloads
- Direct stream manager → Debrid providers: resolves debrid streams
- Direct stream manager → Browser playback: provides media
- Library scanner → Change WebSockets: publishes changes
- Change WebSockets → React web client: pushes updates
- React web client → HTTP API boundary: API requests
- Denshi desktop host → React web client: loads UI
- Denshi desktop host → Browser playback: embedded MPV playback
- Extension runtime → Plugin API & UI: exposes capabilities
- Plugin API & UI → HTTP API boundary: plugin endpoints
- API contract generation → HTTP API boundary: handler contracts
- API contract generation → React web client: generated endpoints