# Graph Report - mcma-backend (2026-07-11) ## Corpus Check - 180 files · ~52,130 words - Verdict: corpus is large enough that graph structure adds value. ## Summary - 1994 nodes · 5692 edges · 133 communities (89 shown, 44 thin omitted) - Extraction: 90% EXTRACTED · 10% INFERRED · 0% AMBIGUOUS · INFERRED: 573 edges (avg confidence: 0.55) - Token cost: 0 input · 0 output ## Graph Freshness - Built from commit: `fb5ce3c7` - Run `git rev-parse HEAD` and compare to check if the graph is stale. - Run `graphify update .` after code changes (no API cost). ## Community Hubs (Navigation) - Storage Backend & Disk Usage - Auth Schemas & Tokens - Error Mapping & Search Schemas - Download Service Orchestration - Playlist Schemas & API - Album Repository - ORM Base & Models - Correlation ID Middleware & Config - Auth Services (native + Subsonic) - Audio Tags & Metadata Test Fakes - YouTube Source Backend - Dependency Wiring (deps.py) - Library Stats & Track Availability - Library Import Service - Subsonic Response Envelope - Chromaprint Fingerprinting - Album/Search Response Schemas - Pagination & Likes Endpoints - Metadata Enrichment Service - Subsonic ID Encoding - Track & Artist Domain Entities - Source Port Protocols - User Management Service - Metadata Enrichment Value Objects - DB Session & Health Checks - Download Service Tests - Download Job Domain Entity - Credentials & User Repository - Streaming Auth Dependencies - Subsonic Browsing Endpoints - Remote Library Service Tests - Worker Session Scope & Download Task - Metadata Enrichment Pipeline - Album Domain & Cover Value Object - Downloads API Tests - Subsonic Search Encoding - In-Memory Auth Repository Fakes - Storage Stats Response Schemas - Subsonic App-Password Crypto - Artist Schemas & Endpoints - Download Request/Response Schemas - Settings & MusicBrainz User-Agent - Subsonic API Integration Tests - Playlist Endpoints - Play History Domain & Repository - DB Engine Lifecycle - Shared Query Param Annotations - Local Folder Source Backend - Track Metadata Match Schemas - Like Domain Entity (event log) - Auth API Integration Tests - Cover API Tests - Upload/Stream API Tests - Tag Parsing Helpers - Metadata API Tests - Subsonic Auth Service Tests - Cover Art Serving - Play History Schemas - Refresh Token Repository - Radio Endpoints - Subsonic Legacy Password Decoding - Management CLI - Sources API Tests - Hexagonal Architecture Layers (doc) - Test DB Fixtures (conftest) - Upload Response Schemas - Cover Art Extraction (Vorbis/MP4) - Storage Stats API Tests - AcoustID Response Parser Tests - Like Request/Response Schemas - Streaming Endpoint - Auth Token Issue/Refresh Flow - Generic Job/Result Store Protocol - Remote Library Materialization - CI Docker Publish Workflow - User Scrobbling Settings - Domain Invariants (dedup, manual overwrite, offline tags) - Alembic Migration Environment - Cover Art Archive Client - Health Endpoint Smoke Tests - ASGI Middleware Protocol - File Hashing Utilities - Package: app.api - Package: app.api.schemas - Package: app.application - Package: app.core - Package: app.domain - Package: app.infrastructure - Package: metadata-enrichment adapters - Package: source backends - Package: storage adapters - Package: app root (mcma-backend) - Package: arq worker - Package: arq tasks - Config Conventions (doc) - Subsonic Adapter Convention (doc) - DB Session Convention (doc) - Health Convention (doc) - Invariant: Graceful Degradation - Invariant: Likes Are Append-Only - Invariant: Stable Track content_id - Logging Convention (doc) - Python 3.14 Lazy Annotations Note - App-Passwords Mechanism (doc) - Local Dev Setup (doc) - Tooling Section (doc) - app/application — use cases / services - Composition roots (app/main.py, app/api/deps.py) - app/core — cross-cutting concerns - app/domain — pure business core - Error handling convention (domain errors → HTTP in app/api/errors.py) - Hexagonal architecture (ports & adapters) - app/infrastructure — driven adapters - Invariant: dedup on (source, source_id) and acoustid_fingerprint - Invariant: no heavy work in the request cycle (goes to arq workers) - Invariant: never overwrite metadata_status=manual - Migrations convention (async, settings-driven Alembic) - app/workers — arq background tasks - Build (Docker) section - Hexagonal architecture (ports & adapters) — README - Database migrations (Alembic) section - Subsonic API (/rest) section - acoustid_trust_score (trust high-confidence AcoustID over junk tags) - Offline tag reader (deterministic, always runs) - scarlet_fire_otis_mcdonald.mp3 test fixture ## God Nodes (most connected - your core abstractions) 1. `NotFoundError` - 95 edges 2. `UserService` - 57 edges 3. `Track` - 50 edges 4. `AuthenticationError` - 49 edges 5. `TrackRepository` - 49 edges 6. `SourceInfo` - 49 edges 7. `MetadataEnrichmentService` - 47 edges 8. `DownloadResult` - 47 edges 9. `get_settings()` - 46 edges 10. `session_scope()` - 45 edges ## Surprising Connections (you probably didn't know these) - `test_id_malformed_rejected()` --indirect_call--> `NotFoundError` [INFERRED] tests/test_subsonic_security.py → app/domain/errors.py - `test_id_wrong_prefix_rejected()` --indirect_call--> `NotFoundError` [INFERRED] tests/test_subsonic_security.py → app/domain/errors.py - `FakeAcoustId` --uses--> `MetadataEnrichmentService` [INFERRED] tests/test_metadata_service.py → app/application/metadata_service.py - `FakeAlbumRepo` --uses--> `MetadataEnrichmentService` [INFERRED] tests/test_metadata_service.py → app/application/metadata_service.py - `FakeArtistRepo` --uses--> `MetadataEnrichmentService` [INFERRED] tests/test_metadata_service.py → app/application/metadata_service.py ## Import Cycles - None detected. ## Hyperedges (group relationships) - **Cross-cutting conventions (errors, config, logging, db sessions, migrations, health)** — claude_error_handling_convention, claude_config_convention, claude_logging_convention, claude_db_sessions_convention, claude_migrations_convention, claude_health_convention [EXTRACTED 1.00] - **Non-negotiable domain invariants (for future sync + ML)** — claude_invariant_likes_event_log, claude_invariant_track_id_stable, claude_invariant_dedup, claude_invariant_graceful_degradation, claude_invariant_no_manual_overwrite, claude_invariant_no_heavy_work_in_request, claude_invariant_subsonic_compatibility [EXTRACTED 1.00] - **Hexagonal architecture layers (domain/application/infrastructure/api/core/workers)** — claude_domain_layer, claude_application_layer, claude_infrastructure_layer, claude_api_layer, claude_core_layer, claude_workers_layer [EXTRACTED 1.00] ## Communities (133 total, 44 thin omitted) ### Community 0 - "Storage Backend & Disk Usage" Cohesion: 0.05 Nodes (54): DiskUsage, ObjectStat, Value objects for file storage., Capacity of the volume backing the media store. ``None`` for backends (e.g., File storage operation failed., StorageError, Capacity of the volume backing the store, or ``None`` when the backend h, LocalFileStorage (+46 more) ### Community 1 - "Auth Schemas & Tokens" Cohesion: 0.07 Nodes (59): LoginRequest, BaseModel, Auth request/response schemas. Tokens are returned in the body (the client store, RefreshRequest, RegisterRequest, TokenResponse, BaseModel, Schemas for Subsonic app-password self-service (native /api/v1 surface). The Su (+51 more) ### Community 2 - "Error Mapping & Search Schemas" Cohesion: 0.07 Nodes (39): _is_subsonic(), FastAPI, Maps domain exceptions to HTTP responses. The only place that knows both. Two s, register_exception_handlers(), ExternalSearchResponse, ExternalSearchResultOut, BaseModel, Flat list of hits across one or more searchable sources, plus the names of s (+31 more) ### Community 3 - "Download Service Orchestration" Cohesion: 0.07 Nodes (20): DownloadRequest, EnrichEnqueuer, DownloadService — request external downloads and import their results. Two role, Outcome of asking for a download. Exactly one of the three states holds: th, EnrichEnqueuer, Path, Protocol, UploadService — handles user file uploads. (+12 more) ### Community 4 - "Playlist Schemas & API" Cohesion: 0.20 Nodes (28): PlaylistAddTrack, PlaylistCreate, PlaylistOut, PlaylistReorder, PlaylistUpdate, BaseModel, Playlist request/response schemas., add_playlist_track() (+20 more) ### Community 5 - "Album Repository" Cohesion: 0.06 Nodes (11): AlbumRepository, DownloadJobRepository, LikeRepository, PlaylistRepository, datetime, UUID, Resolve/create an album bound to a remote ``(source, source_id)`` (lazy, Persistence for download jobs (plan §6.1). Drives the §A5 download manager a (+3 more) ### Community 6 - "ORM Base & Models" Cohesion: 0.10 Nodes (31): Base, Declarative base with a fixed naming convention. The naming convention makes Al, Base for all ORM models. Import models so Alembic sees their metadata., ORM model for albums., ORM model for artists., ORM model for download jobs (plan §6.1). Tracks a queued download through its l, LikeValue, LyricsStatus (+23 more) ### Community 7 - "Correlation ID Middleware & Config" Cohesion: 0.12 Nodes (17): CorrelationIdMiddleware, HTTP middleware: bind a correlation id and log each request., Pure-ASGI middleware: reuse inbound ``X-Correlation-Id`` or mint one, bind i, app_version(), User-Agent sent to MusicBrainz/AcoustID: ``MCMA/ ( )``., _add_correlation_id(), configure_logging(), create_app() (+9 more) ### Community 8 - "Auth Services (native + Subsonic)" Cohesion: 0.09 Nodes (42): EnrichmentResult, AcoustIdClient, AudioFingerprinter, AudioTagReader, CoverArtExtractor, CoverArtProvider, FetchableSource, HistoryRepository (+34 more) ### Community 9 - "Audio Tags & Metadata Test Fakes" Cohesion: 0.15 Nodes (28): AudioTags, Embedded tags read from the file itself (ID3 / Vorbis / MP4 …). Every field, _cover_service(), FakeAlbumRepo, FakeArtistRepo, FakeCoverExtractor, FakeCoverProvider, FakeTagReader (+20 more) ### Community 10 - "YouTube Source Backend" Cohesion: 0.08 Nodes (32): One hit from a searchable source (plan §5), shown on the discover screen. `, SearchResult, Which backend imported a track. Drives ``is_replaceable`` (plan §6.6)., TrackSource, _default_download(), _default_search(), _libs_available(), Any (+24 more) ### Community 11 - "Dependency Wiring (deps.py)" Cohesion: 0.11 Nodes (29): get_album_repository(), get_artist_repository(), get_auth_service(), get_download_service(), get_history_repository(), get_like_repository(), get_metadata_service(), get_password_hasher() (+21 more) ### Community 12 - "Library Stats & Track Availability" Cohesion: 0.13 Nodes (18): FormatBreakdown, LibraryStats, Per-container-format slice of the library (e.g. ``flac`` → 312 tracks)., Aggregate facts about everything the instance has stored. Computed from the, Track, Whether a track's audio is on local storage or still a remote placeholder (p, TrackAvailability, TrackModel (+10 more) ### Community 13 - "Library Import Service" Cohesion: 0.12 Nodes (19): ImportSummary, LibraryImportService, UUID, LibraryImportService — imports files discovered by an indexable source. Batch s, Source-backend value objects — framework-free. A *source* is a place tracks com, A single importable file discovered by an indexable source. ``source_id`` i, SourceFile, ``local`` source — indexes audio files from a mounted folder. Walks a configure (+11 more) ### Community 14 - "Subsonic Response Envelope" Cohesion: 0.12 Nodes (30): _build_xml(), _is_json(), Any, Element, Response, The Subsonic response envelope — one serializer, two wire formats. Every Subson, A ``status="failed"`` envelope carrying a Subsonic ````., Recursively drop ``None`` values so JSON output matches XML (no empty attrs). (+22 more) ### Community 15 - "Chromaprint Fingerprinting" Cohesion: 0.09 Nodes (24): AcoustIdHttpClient, Implements :class:`app.domain.ports.AcoustIdClient`., FpcalcFingerprinter, Path, FpcalcFingerprinter — Chromaprint fingerprint via the ``fpcalc`` binary. ``fpca, Implements :class:`app.domain.ports.AudioFingerprinter`., MutagenTagReader, Implements :class:`app.domain.ports.AudioTagReader`. (+16 more) ### Community 16 - "Album/Search Response Schemas" Cohesion: 0.12 Nodes (33): AlbumOut, BaseModel, Album request/response schemas., ArtistOut, BaseModel, Artist request/response schemas., PagedResponse, BaseModel (+25 more) ### Community 17 - "Pagination & Likes Endpoints" Cohesion: 0.13 Nodes (39): MaterializeResponse, MetadataApply, MetadataMatch, MetadataMatchesOut, BaseModel, Track request/response schemas., One AcoustID candidate for the metadata editor's match picker (§A7)., Manual edits / accepted match applied via ``PUT /tracks/{id}/metadata``. Se (+31 more) ### Community 18 - "Metadata Enrichment Service" Cohesion: 0.11 Nodes (11): _first_int(), MetadataEnrichmentService, _opt_str(), UUID, MetadataEnrichmentService — the §6.2 pipeline orchestrator. Order (tag-first):, Explain a ``failed`` (no-identity) run in terms a user can act on: which, AcoustID candidates for the metadata editor's match picker (§A7). Read-, Fill in an album cover when it has none. Source order mirrors the tag-fi (+3 more) ### Community 19 - "Subsonic ID Encoding" Cohesion: 0.13 Nodes (29): Subsonic annotation endpoints: star/unstar, rating, scrobble. * ``star``/``unst, decode_album(), decode_artist(), _decode_as(), decode_track(), encode(), encode_track(), IdKind (+21 more) ### Community 20 - "Track & Artist Domain Entities" Cohesion: 0.10 Nodes (17): Schemas for searching external (fetch) sources — the §A4 discover screen., Artist, Track and Artist domain entities., Resolve/create an artist bound to a remote ``(source, source_id)`` (lazy, ArtistModel, AsyncSession, UUID, Artist repository — adapter over ``AsyncSession``. (+9 more) ### Community 21 - "Source Port Protocols" Cohesion: 0.18 Nodes (11): Playlist, Playlist domain entity., PlaylistModel, PlaylistTrackModel, A track's membership in a playlist. ``position`` is a float so a track can, AsyncSession, UUID, Playlist repository — adapter over ``AsyncSession``. (+3 more) ### Community 22 - "User Management Service" Cohesion: 0.11 Nodes (36): AuthService, _hash_token(), UUID, Authentication use cases: login, token refresh (rotation), logout, and access-to, At-rest hash of a refresh token. A signed JWT is high-entropy, so a fast SHA, User-management use cases: admin CRUD plus self-service password change. Deleti, UserService, _cmd_create_admin() (+28 more) ### Community 23 - "Metadata Enrichment Value Objects" Cohesion: 0.17 Nodes (10): Domain entities and value objects — pure, framework-free., Fingerprint, Value objects for the metadata-enrichment pipeline (plan §6.2). Pure data carri, Chromaprint fingerprint plus the decoded duration (both needed by AcoustID)., A single AcoustID result, flattened to the fields enrichment cares about. `, RecordingMatch, _parse_matches(), _parse_one() (+2 more) ### Community 24 - "DB Session & Health Checks" Cohesion: 0.16 Nodes (17): _check_db(), _check_ml(), _check_redis(), health(), HealthResponse, BaseModel, Response, Health & readiness endpoints — used by compose healthchecks and the admin UI. * (+9 more) ### Community 25 - "Download Service Tests" Cohesion: 0.16 Nodes (14): DownloadService, FakeArtistRepo, FakeJobRepo, FakeStorage, FakeTrackRepo, Path, UUID, Unit tests for DownloadService — DB-free, in-memory fakes. (+6 more) ### Community 26 - "Download Job Domain Entity" Cohesion: 0.13 Nodes (10): DownloadJob, Download job domain entity (plan §6.1). A queued fetch from an external source,, An unfinished (queued/downloading/enriching) job for the same item, if a, DownloadJobModel, DownloadStatus, Lifecycle of a download job (plan §6.1)., datetime, UUID (+2 more) ### Community 27 - "Credentials & User Repository" Cohesion: 0.10 Nodes (20): get_current_superuser(), get_current_user(), get_streaming_user(), AuthServiceDep, CurrentUser, Authenticate a stream request. The browser ``