# maelmoreau21/jellytrack architecture

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

- Interactive diagram: https://gitdiagram.com/maelmoreau21/jellytrack
- Repository: https://github.com/maelmoreau21/jellytrack

## Overview

JellyTrack is a self-hosted Jellyfin analytics and monitoring application. A browser reaches its embedded Go HTTP application; users authenticate, then explore playback, media, user, and analytics views. Jellyfin API data and plugin events supply the underlying activity, which the application stores and serves from SQLite or PostgreSQL. Administration adds server/settings management, backups, cleanup, and scheduled work. The README documents several capabilities beyond the sampled implementation excerpts, so those branches are included at subsystem level; their internal wiring is not asserted where source evidence is unavailable.

Main entry points: [`internal/database/open.go`](https://github.com/maelmoreau21/jellytrack/blob/main/internal/database/open.go) (SQL database), [`internal/api/handlers.go`](https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/handlers.go) (HTTP API), [`web/static.go`](https://github.com/maelmoreau21/jellytrack/blob/main/web/static.go) (HTTP application), [`internal/jellyfin/sync.go`](https://github.com/maelmoreau21/jellytrack/blob/main/internal/jellyfin/sync.go) (Server sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_application["HTTP application<br/>[static.go]"]
  node_api["HTTP API<br/>[handlers.go]"]
  node_database[("SQL database<br/>[open.go]")]
end

subgraph group_ingest["Jellyfin ingestion"]
  node_plugin["Plugin events<br/>[events.go]"]
  node_sync["Server sync<br/>[sync.go]"]
  node_catalogue["Media catalogue"]
end

subgraph group_insights["Analytics and activity"]
  node_history["Playback history<br/>[history.go]"]
  node_history_api["History endpoints"]
  node_analytics["Analytics<br/>[dashboard.go]"]
  node_parity["Insights parity<br/>[parity.go]"]
  node_media["Media browsing<br/>[media.go]"]
  node_users["User profiles<br/>[users.go]"]
end

subgraph group_identity["Access and configuration"]
  node_auth["Authentication<br/>[auth.go]"]
  node_login_policy["Login policy<br/>[login_policy.go]"]
  node_settings["Settings and servers<br/>[settings.go]"]
end

subgraph group_operations["Administration"]
  node_admin["Administration API<br/>[admin_handlers.go]"]
  node_backup["Backup and restore<br/>[backup.go]"]
  node_cleanup["Data cleanup<br/>[cleanup.go]"]
  node_scheduler["Background scheduler<br/>[scheduler.go]"]
end

node_browser(("Browser"))
node_jellyfin["Jellyfin server"]

node_browser -->|"requests"| node_application
node_application -->|"routes"| node_api
node_jellyfin -->|"sends events"| node_plugin
node_plugin -->|"records events"| node_database
node_api -->|"starts sync"| node_sync
node_sync -->|"updates records"| node_database
node_sync -.->|"reconciles catalogue"| node_catalogue
node_api -->|"queries history"| node_history
node_history_api -->|"queries sessions"| node_history
node_history_api -->|"reads sessions"| node_database
node_api -->|"serves insights"| node_analytics
node_analytics -->|"reads activity"| node_database
node_parity -->|"reads activity"| node_database
node_api -->|"serves media"| node_media
node_api -->|"serves profiles"| node_users
node_application -->|"uses authentication"| node_auth
node_auth -->|"checks policy"| node_login_policy
node_auth -->|"reads sessions"| node_database
node_admin -.->|"manages settings"| node_settings
node_admin -->|"handles backups"| node_backup
node_admin -->|"runs cleanup"| node_cleanup
node_scheduler -->|"schedules backups"| node_backup
node_scheduler -->|"schedules cleanup"| node_cleanup
node_scheduler -->|"schedules sync"| node_sync
node_application -.->|"uses Jellyfin API"| node_jellyfin
node_database -.->|"stores server data"| node_jellyfin

click node_application "https://github.com/maelmoreau21/jellytrack/blob/main/web/static.go"
click node_api "https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/handlers.go"
click node_database "https://github.com/maelmoreau21/jellytrack/blob/main/internal/database/open.go"
click node_plugin "https://github.com/maelmoreau21/jellytrack/blob/main/internal/plugin/events.go"
click node_sync "https://github.com/maelmoreau21/jellytrack/blob/main/internal/jellyfin/sync.go"
click node_catalogue "https://github.com/maelmoreau21/jellytrack/blob/main/internal/jellyfin/catalog_reconcile.go"
click node_history "https://github.com/maelmoreau21/jellytrack/blob/main/internal/history/history.go"
click node_history_api "https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/history_handlers.go"
click node_analytics "https://github.com/maelmoreau21/jellytrack/blob/main/internal/stats/dashboard.go"
click node_parity "https://github.com/maelmoreau21/jellytrack/blob/main/internal/stats/parity.go"
click node_media "https://github.com/maelmoreau21/jellytrack/blob/main/internal/media/media.go"
click node_users "https://github.com/maelmoreau21/jellytrack/blob/main/internal/users/users.go"
click node_auth "https://github.com/maelmoreau21/jellytrack/blob/main/internal/auth/auth.go"
click node_login_policy "https://github.com/maelmoreau21/jellytrack/blob/main/internal/auth/login_policy.go"
click node_settings "https://github.com/maelmoreau21/jellytrack/blob/main/internal/settings/settings.go"
click node_admin "https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/admin_handlers.go"
click node_backup "https://github.com/maelmoreau21/jellytrack/blob/main/internal/backup/backup.go"
click node_cleanup "https://github.com/maelmoreau21/jellytrack/blob/main/internal/cleanup/cleanup.go"
click node_scheduler "https://github.com/maelmoreau21/jellytrack/blob/main/internal/scheduler/scheduler.go"

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_application,node_api,node_database,node_browser toneBlue
class node_plugin,node_sync,node_catalogue toneAmber
class node_history,node_history_api,node_analytics,node_parity,node_media,node_users,node_jellyfin toneMint
class node_auth,node_login_policy,node_settings toneRose
class node_admin,node_backup,node_cleanup,node_scheduler toneIndigo
```

## Components

### Application runtime

- [HTTP application](https://github.com/maelmoreau21/jellytrack/blob/main/web/static.go): `web/static.go`
- [HTTP API](https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/handlers.go): `internal/api/handlers.go`
- [SQL database](https://github.com/maelmoreau21/jellytrack/blob/main/internal/database/open.go): `internal/database/open.go`

### Jellyfin ingestion

- [Plugin events](https://github.com/maelmoreau21/jellytrack/blob/main/internal/plugin/events.go): `internal/plugin/events.go`
- [Server sync](https://github.com/maelmoreau21/jellytrack/blob/main/internal/jellyfin/sync.go): `internal/jellyfin/sync.go`
- [Media catalogue](https://github.com/maelmoreau21/jellytrack/blob/main/internal/jellyfin/catalog_reconcile.go): `internal/jellyfin/catalog_reconcile.go`

### Analytics and activity

- [Playback history](https://github.com/maelmoreau21/jellytrack/blob/main/internal/history/history.go): `internal/history/history.go`
- [History endpoints](https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/history_handlers.go): `internal/api/history_handlers.go`
- [Analytics](https://github.com/maelmoreau21/jellytrack/blob/main/internal/stats/dashboard.go): `internal/stats/dashboard.go`
- [Insights parity](https://github.com/maelmoreau21/jellytrack/blob/main/internal/stats/parity.go): `internal/stats/parity.go`
- [Media browsing](https://github.com/maelmoreau21/jellytrack/blob/main/internal/media/media.go): `internal/media/media.go`
- [User profiles](https://github.com/maelmoreau21/jellytrack/blob/main/internal/users/users.go): `internal/users/users.go`

### Access and configuration

- [Authentication](https://github.com/maelmoreau21/jellytrack/blob/main/internal/auth/auth.go): `internal/auth/auth.go`
- [Login policy](https://github.com/maelmoreau21/jellytrack/blob/main/internal/auth/login_policy.go): `internal/auth/login_policy.go`
- [Settings and servers](https://github.com/maelmoreau21/jellytrack/blob/main/internal/settings/settings.go): `internal/settings/settings.go`

### Administration

- [Administration API](https://github.com/maelmoreau21/jellytrack/blob/main/internal/api/admin_handlers.go): `internal/api/admin_handlers.go`
- [Backup and restore](https://github.com/maelmoreau21/jellytrack/blob/main/internal/backup/backup.go): `internal/backup/backup.go`
- [Data cleanup](https://github.com/maelmoreau21/jellytrack/blob/main/internal/cleanup/cleanup.go): `internal/cleanup/cleanup.go`
- [Background scheduler](https://github.com/maelmoreau21/jellytrack/blob/main/internal/scheduler/scheduler.go): `internal/scheduler/scheduler.go`

### Other components

- **Browser**
- **Jellyfin server**

## Connections

- Browser → HTTP application: requests
- HTTP application → HTTP API: routes (evidence: `web/static.go`)
- Jellyfin server → Plugin events: sends events
- Plugin events → SQL database: records events (evidence: `internal/plugin/events.go`)
- HTTP API → Server sync: starts sync (evidence: `internal/api/handlers.go`)
- Server sync → SQL database: updates records (evidence: `internal/jellyfin/sync.go`)
- Server sync → Media catalogue: reconciles catalogue
- HTTP API → Playback history: queries history (evidence: `internal/api/handlers.go`)
- History endpoints → Playback history: queries sessions (evidence: `internal/api/history_handlers.go`)
- History endpoints → SQL database: reads sessions (evidence: `internal/api/history_handlers.go`)
- HTTP API → Analytics: serves insights (evidence: `internal/api/handlers.go`)
- Analytics → SQL database: reads activity (evidence: `internal/stats/dashboard.go`)
- Insights parity → SQL database: reads activity (evidence: `internal/stats/parity.go`)
- HTTP API → Media browsing: serves media
- HTTP API → User profiles: serves profiles (evidence: `internal/api/handlers.go`)
- HTTP application → Authentication: uses authentication (evidence: `web/static.go`)
- Authentication → Login policy: checks policy (evidence: `internal/auth/auth.go`)
- Authentication → SQL database: reads sessions (evidence: `internal/auth/auth.go`)
- Administration API → Settings and servers: manages settings
- Administration API → Backup and restore: handles backups
- Administration API → Data cleanup: runs cleanup
- Background scheduler → Backup and restore: schedules backups (evidence: `internal/scheduler/scheduler.go`)
- Background scheduler → Data cleanup: schedules cleanup (evidence: `internal/scheduler/scheduler.go`)
- Background scheduler → Server sync: schedules sync (evidence: `internal/scheduler/scheduler.go`)
- HTTP application → Jellyfin server: uses Jellyfin API
- SQL database → Jellyfin server: stores server data
