# redhox/cephalopode architecture

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

- Interactive diagram: https://gitdiagram.com/redhox/cephalopode
- Repository: https://github.com/redhox/cephalopode

## Overview

Cephalopode is a browser-based music streaming and library-management platform. Users authenticate, browse or search a music library, play tracks, and manage likes and playlists; administrators can configure libraries and initiate scans. The backend exposes the application API, validates tokens, and uses a selectable SQLite or PostgreSQL repository. Library scanning reads audio metadata from S3-compatible storage and populates the catalogue. The README documents these capabilities; several frontend/API and scanner connections are not visible in the sampled call sites, so those links are marked unverified.

Main entry points: [`vite-front/src/App.tsx`](https://github.com/redhox/cephalopode/blob/main/vite-front/src/App.tsx) (App shell), [`api/main.py`](https://github.com/redhox/cephalopode/blob/main/api/main.py) (API routes), [`api/repositories/__init__.py`](https://github.com/redhox/cephalopode/blob/main/api/repositories/__init__.py) (Repository selection), [`vite-front/src/Root.tsx`](https://github.com/redhox/cephalopode/blob/main/vite-front/src/Root.tsx) (App entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_root["App entry<br/>[Root.tsx]"]
  node_authstate["Auth state<br/>[AuthContext.tsx]"]
  node_app["App shell<br/>[App.tsx]"]
  node_admin["Library settings"]
end

subgraph group_catalog["Music discovery"]
  node_home["Home<br/>[home.tsx]"]
  node_search["Search view<br/>[recherche.tsx]"]
  node_artist["Artist view<br/>[Artist.tsx]"]
  node_playlist["Playlist editor<br/>[playlist.tsx]"]
  node_playlistview["Playlist view<br/>[playlistView.tsx]"]
  node_likes["Liked music<br/>[like.tsx]"]
  node_audio["Audio player<br/>[AudioPlayer.tsx]"]
end

subgraph group_backend["API and services"]
  node_api["API routes<br/>[main.py]"]
  node_auth["Token validation<br/>[auth.py]"]
  node_bucket_scan["Library scan orchestration<br/>[main.py]"]
  node_metadata["Audio metadata scan<br/>[bucket_scanner.py]"]
  node_image_scan["Artist image scan"]
end

subgraph group_storage["Persistence and media"]
  node_repo_select["Repository selection<br/>[__init__.py]"]
  node_repo_contract["Repository contract<br/>[base.py]"]
  node_sqlite[("SQLite repository<br/>[sqlite_repo.py]")]
  node_postgres[("PostgreSQL repository<br/>[postgres_repo.py]")]
  node_bucket_repo["S3 contact repository<br/>[bucket_repo.py]"]
end

node_listener(("Listener or admin"))
node_s3[("S3-compatible storage")]

node_listener -->|"opens app"| node_root
node_root -->|"provides auth"| node_authstate
node_root -->|"renders"| node_app
node_app -->|"reads session"| node_authstate
node_app -->|"shows view"| node_home
node_app -->|"shows view"| node_search
node_app -->|"shows view"| node_artist
node_app -->|"shows view"| node_playlistview
node_app -->|"shows view"| node_likes
node_app -->|"dispatches playback"| node_audio
node_app -.->|"opens settings"| node_admin
node_listener -.->|"listens"| node_audio
node_search -.->|"requests search"| node_api
node_home -.->|"loads catalogue"| node_api
node_artist -.->|"loads artist"| node_api
node_playlist -.->|"manages playlist"| node_api
node_playlistview -.->|"loads playlist"| node_api
node_likes -.->|"loads likes"| node_api
node_admin -.->|"configures libraries"| node_api
node_api -->|"verifies identity"| node_auth
node_auth -->|"looks up user"| node_repo_select
node_api -->|"uses repository"| node_repo_select
node_repo_select -->|"selects by config"| node_sqlite
node_repo_select -->|"selects by config"| node_postgres
node_sqlite -->|"implements"| node_repo_contract
node_postgres -->|"implements"| node_repo_contract
node_api -->|"orchestrates scan"| node_bucket_scan
node_bucket_scan -.->|"reads metadata"| node_metadata
node_bucket_scan -.->|"updates images"| node_image_scan
node_bucket_scan -->|"reads and writes catalogue"| node_repo_select
node_metadata -.->|"reads objects"| node_s3
node_bucket_repo -.->|"contacts storage"| node_s3
node_repo_select -->|"creates storage adapter"| node_bucket_repo

click node_root "https://github.com/redhox/cephalopode/blob/main/vite-front/src/Root.tsx"
click node_authstate "https://github.com/redhox/cephalopode/blob/main/vite-front/src/AuthContext.tsx"
click node_app "https://github.com/redhox/cephalopode/blob/main/vite-front/src/App.tsx"
click node_home "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/home.tsx"
click node_search "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/recherche.tsx"
click node_artist "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/Artist.tsx"
click node_playlist "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/playlist.tsx"
click node_playlistview "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/playlistView.tsx"
click node_likes "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/like.tsx"
click node_audio "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/AudioPlayer.tsx"
click node_admin "https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/AdminSettingsView.tsx"
click node_api "https://github.com/redhox/cephalopode/blob/main/api/main.py"
click node_auth "https://github.com/redhox/cephalopode/blob/main/api/auth.py"
click node_bucket_scan "https://github.com/redhox/cephalopode/blob/main/api/main.py"
click node_metadata "https://github.com/redhox/cephalopode/blob/main/api/bucket_scanner.py"
click node_image_scan "https://github.com/redhox/cephalopode/blob/main/api/artist_image_scanner.py"
click node_repo_select "https://github.com/redhox/cephalopode/blob/main/api/repositories/__init__.py"
click node_repo_contract "https://github.com/redhox/cephalopode/blob/main/api/repositories/base.py"
click node_sqlite "https://github.com/redhox/cephalopode/blob/main/api/repositories/sqlite_repo.py"
click node_postgres "https://github.com/redhox/cephalopode/blob/main/api/repositories/postgres_repo.py"
click node_bucket_repo "https://github.com/redhox/cephalopode/blob/main/api/repositories/bucket_repo.py"

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_root,node_authstate,node_app,node_admin toneBlue
class node_home,node_search,node_artist,node_playlist,node_playlistview,node_likes,node_audio,node_s3 toneAmber
class node_api,node_auth,node_bucket_scan,node_metadata,node_image_scan toneMint
class node_repo_select,node_repo_contract,node_sqlite,node_postgres,node_bucket_repo toneRose
class node_listener toneIndigo
```

## Components

### Web application

- [App entry](https://github.com/redhox/cephalopode/blob/main/vite-front/src/Root.tsx): `vite-front/src/Root.tsx`
- [Auth state](https://github.com/redhox/cephalopode/blob/main/vite-front/src/AuthContext.tsx): `vite-front/src/AuthContext.tsx`
- [App shell](https://github.com/redhox/cephalopode/blob/main/vite-front/src/App.tsx): `vite-front/src/App.tsx`
- [Library settings](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/AdminSettingsView.tsx): `vite-front/src/components/AdminSettingsView.tsx`

### Music discovery

- [Home](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/home.tsx): `vite-front/src/components/home.tsx`
- [Search view](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/recherche.tsx): `vite-front/src/components/recherche.tsx`
- [Artist view](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/Artist.tsx): `vite-front/src/components/Artist.tsx`
- [Playlist editor](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/playlist.tsx): `vite-front/src/components/playlist.tsx`
- [Playlist view](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/playlistView.tsx): `vite-front/src/components/playlistView.tsx`
- [Liked music](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/like.tsx): `vite-front/src/components/like.tsx`
- [Audio player](https://github.com/redhox/cephalopode/blob/main/vite-front/src/components/AudioPlayer.tsx): `vite-front/src/components/AudioPlayer.tsx`

### API and services

- [API routes](https://github.com/redhox/cephalopode/blob/main/api/main.py): `api/main.py`
- [Token validation](https://github.com/redhox/cephalopode/blob/main/api/auth.py): `api/auth.py`
- [Library scan orchestration](https://github.com/redhox/cephalopode/blob/main/api/main.py): `api/main.py`
- [Audio metadata scan](https://github.com/redhox/cephalopode/blob/main/api/bucket_scanner.py): `api/bucket_scanner.py`
- [Artist image scan](https://github.com/redhox/cephalopode/blob/main/api/artist_image_scanner.py): `api/artist_image_scanner.py`

### Persistence and media

- [Repository selection](https://github.com/redhox/cephalopode/blob/main/api/repositories/__init__.py): `api/repositories/__init__.py`
- [Repository contract](https://github.com/redhox/cephalopode/blob/main/api/repositories/base.py): `api/repositories/base.py`
- [SQLite repository](https://github.com/redhox/cephalopode/blob/main/api/repositories/sqlite_repo.py): `api/repositories/sqlite_repo.py`
- [PostgreSQL repository](https://github.com/redhox/cephalopode/blob/main/api/repositories/postgres_repo.py): `api/repositories/postgres_repo.py`
- [S3 contact repository](https://github.com/redhox/cephalopode/blob/main/api/repositories/bucket_repo.py): `api/repositories/bucket_repo.py`

### Other components

- **Listener or admin**
- **S3-compatible storage**

## Connections

- Listener or admin → App entry: opens app
- App entry → Auth state: provides auth (evidence: `vite-front/src/Root.tsx`)
- App entry → App shell: renders (evidence: `vite-front/src/Root.tsx`)
- App shell → Auth state: reads session (evidence: `vite-front/src/App.tsx`)
- App shell → Home: shows view (evidence: `vite-front/src/App.tsx`)
- App shell → Search view: shows view (evidence: `vite-front/src/App.tsx`)
- App shell → Artist view: shows view (evidence: `vite-front/src/App.tsx`)
- App shell → Playlist view: shows view (evidence: `vite-front/src/App.tsx`)
- App shell → Liked music: shows view (evidence: `vite-front/src/App.tsx`)
- App shell → Audio player: dispatches playback (evidence: `vite-front/src/App.tsx`)
- App shell → Library settings: opens settings
- Listener or admin → Audio player: listens
- Search view → API routes: requests search
- Home → API routes: loads catalogue
- Artist view → API routes: loads artist
- Playlist editor → API routes: manages playlist
- Playlist view → API routes: loads playlist
- Liked music → API routes: loads likes
- Library settings → API routes: configures libraries
- API routes → Token validation: verifies identity (evidence: `api/main.py`)
- Token validation → Repository selection: looks up user (evidence: `api/auth.py`)
- API routes → Repository selection: uses repository (evidence: `api/main.py`)
- Repository selection → SQLite repository: selects by config (evidence: `api/repositories/__init__.py`)
- Repository selection → PostgreSQL repository: selects by config (evidence: `api/repositories/__init__.py`)
- SQLite repository → Repository contract: implements (evidence: `api/repositories/sqlite_repo.py`)
- PostgreSQL repository → Repository contract: implements (evidence: `api/repositories/postgres_repo.py`)
- API routes → Library scan orchestration: orchestrates scan (evidence: `api/main.py`)
- Library scan orchestration → Audio metadata scan: reads metadata (evidence: `api/main.py`)
- Library scan orchestration → Artist image scan: updates images (evidence: `api/main.py`)
- Library scan orchestration → Repository selection: reads and writes catalogue (evidence: `api/main.py`)
- Audio metadata scan → S3-compatible storage: reads objects
- S3 contact repository → S3-compatible storage: contacts storage
- Repository selection → S3 contact repository: creates storage adapter (evidence: `api/repositories/__init__.py`)
