# abhishek1mandal/am-music-backend architecture

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

- Interactive diagram: https://gitdiagram.com/abhishek1mandal/am-music-backend
- Repository: https://github.com/abhishek1mandal/am-music-backend

## Overview

AM Music Backend is a FastAPI music-library service. Its principal workflow is a client request entering the versioned API, passing through a domain endpoint, and producing catalog, discovery, download, or playback behavior. The tree also shows account and preference management, playlists, favorites, history, artwork, and maintenance. The graph preserves these product areas and the central metadata, storage, and persistence layers. Source evidence is incomplete for many endpoints, so their internal calls are not asserted; dashed links mark unverified runtime relationships.

Main entry points: [`app/api/v1/router.py`](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/router.py) (API router), [`app/core/database.py`](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/database.py) (Database session), [`app/api/v1/auth.py`](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/auth.py) (Authentication API), [`app/dependencies/auth.py`](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/dependencies/auth.py) (Authentication dependency)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_api_router["API router<br/>[router.py]"]
end

subgraph group_accounts["Accounts and preferences"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_preferences_api["Preferences API<br/>[preferences.py]"]
  node_auth_dependency["Authentication dependency<br/>[auth.py]"]
  node_language_service["Language preferences<br/>[languages.py]"]
end

subgraph group_catalog["Catalog and discovery"]
  node_home_api["Home API<br/>[home.py]"]
  node_catalog_api["Catalog APIs<br/>[albums.py]"]
  node_search_api["Search API<br/>[search.py]"]
  node_collection_apis["User collections APIs<br/>[playlists.py]"]
  node_library_api["Library API<br/>[library.py]"]
  node_home_service["Home discovery<br/>[home.py]"]
  node_musicbrainz["MusicBrainz metadata<br/>[musicbrainz.py]"]
end

subgraph group_media["Downloads and media"]
  node_downloads_api["Downloads API<br/>[downloads.py]"]
  node_streaming_api["Streaming API<br/>[streaming.py]"]
  node_artwork_api["Artwork API<br/>[artwork.py]"]
  node_maintenance_api["Maintenance API<br/>[maintenance.py]"]
  node_youtube_music["YouTube Music provider<br/>[youtube_music.py]"]
  node_download_service["Music downloading<br/>[downloader.py]"]
  node_music_services["Music processing<br/>[artwork.py]"]
end

subgraph group_platform["Runtime and persistence"]
  node_app["FastAPI application<br/>[main.py]"]
  node_security["Token and password security<br/>[security.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_database[("Database session<br/>[database.py]")]
  node_track_model["Track records<br/>[track.py]"]
  node_user_model["User records<br/>[user.py]"]
end

node_client(("API client"))
node_musicbrainz_external(("MusicBrainz service"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_api_router
node_app -->|"seeds languages"| node_language_service
node_api_router -->|"registers"| node_auth_api
node_api_router -->|"registers"| node_preferences_api
node_api_router -->|"registers"| node_home_api
node_api_router -->|"registers"| node_catalog_api
node_api_router -->|"registers"| node_search_api
node_api_router -->|"registers"| node_collection_apis
node_api_router -->|"registers"| node_library_api
node_api_router -->|"registers"| node_downloads_api
node_api_router -->|"registers"| node_streaming_api
node_api_router -->|"registers"| node_artwork_api
node_api_router -->|"registers"| node_maintenance_api
node_auth_api -->|"hashes and issues tokens"| node_security
node_auth_dependency -->|"decodes tokens"| node_security
node_home_service -->|"searches metadata"| node_musicbrainz
node_musicbrainz -.->|"requests metadata"| node_musicbrainz_external
node_home_api -.->|"uses discovery"| node_home_service
node_downloads_api -.->|"delegates downloads"| node_download_service
node_streaming_api -.->|"uses media services"| node_music_services
node_artwork_api -.->|"uses artwork service"| node_music_services
node_downloads_api -.->|"may use provider"| node_youtube_music
node_preferences_api -.->|"requires user identity"| node_auth_dependency
node_auth_api -->|"queries users"| node_database
node_auth_dependency -->|"loads user"| node_database
node_app -->|"closes resources"| node_database
node_home_service -->|"queries tracks"| node_track_model
node_home_service -->|"uses language mapping"| node_musicbrainz
node_language_service -->|"queries and seeds"| node_database
node_auth_api -->|"creates and queries"| node_user_model
node_auth_dependency -->|"checks account"| node_user_model
node_track_model -->|"maps records"| node_database
node_user_model -->|"maps records"| node_database
node_downloads_api -.->|"may read settings"| node_config
node_streaming_api -.->|"may read settings"| node_config

click node_app "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/main.py"
click node_api_router "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/router.py"
click node_auth_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/auth.py"
click node_preferences_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/preferences.py"
click node_home_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/home.py"
click node_catalog_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/albums.py"
click node_search_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/search.py"
click node_collection_apis "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/playlists.py"
click node_library_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/library.py"
click node_downloads_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/downloads.py"
click node_streaming_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/streaming.py"
click node_artwork_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/artwork.py"
click node_maintenance_api "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/maintenance.py"
click node_home_service "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/home.py"
click node_musicbrainz "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/metadata/musicbrainz.py"
click node_youtube_music "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/providers/youtube_music.py"
click node_download_service "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/music/downloader.py"
click node_music_services "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/music/artwork.py"
click node_auth_dependency "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/dependencies/auth.py"
click node_security "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/security.py"
click node_config "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/config.py"
click node_database "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/database.py"
click node_track_model "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/models/track.py"
click node_user_model "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/models/user.py"
click node_language_service "https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/preferences/languages.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_api_router,node_client toneBlue
class node_auth_api,node_preferences_api,node_auth_dependency,node_language_service toneAmber
class node_home_api,node_catalog_api,node_search_api,node_collection_apis,node_library_api,node_home_service,node_musicbrainz toneMint
class node_downloads_api,node_streaming_api,node_artwork_api,node_maintenance_api,node_youtube_music,node_download_service,node_music_services toneRose
class node_app,node_security,node_config,node_database,node_track_model,node_user_model,node_musicbrainz_external toneIndigo
```

## Components

### API surface

- [API router](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/router.py): `app/api/v1/router.py`

### Accounts and preferences

- [Authentication API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/auth.py): `app/api/v1/auth.py`
- [Preferences API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/preferences.py): `app/api/v1/preferences.py`
- [Authentication dependency](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/dependencies/auth.py): `app/dependencies/auth.py`
- [Language preferences](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/preferences/languages.py): `app/services/preferences/languages.py`

### Catalog and discovery

- [Home API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/home.py): `app/api/v1/home.py`
- [Catalog APIs](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/albums.py): `app/api/v1/albums.py`
- [Search API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/search.py): `app/api/v1/search.py`
- [User collections APIs](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/playlists.py): `app/api/v1/playlists.py`
- [Library API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/library.py): `app/api/v1/library.py`
- [Home discovery](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/home.py): `app/services/home.py`
- [MusicBrainz metadata](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/metadata/musicbrainz.py): `app/services/metadata/musicbrainz.py`

### Downloads and media

- [Downloads API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/downloads.py): `app/api/v1/downloads.py`
- [Streaming API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/streaming.py): `app/api/v1/streaming.py`
- [Artwork API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/artwork.py): `app/api/v1/artwork.py`
- [Maintenance API](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/api/v1/maintenance.py): `app/api/v1/maintenance.py`
- [YouTube Music provider](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/providers/youtube_music.py): `app/services/providers/youtube_music.py`
- [Music downloading](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/music/downloader.py): `app/services/music/downloader.py`
- [Music processing](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/services/music/artwork.py): `app/services/music/artwork.py`

### Runtime and persistence

- [FastAPI application](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/main.py): `app/main.py`
- [Token and password security](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/security.py): `app/core/security.py`
- [Runtime configuration](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/config.py): `app/core/config.py`
- [Database session](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/core/database.py): `app/core/database.py`
- [Track records](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/models/track.py): `app/models/track.py`
- [User records](https://github.com/abhishek1mandal/am-music-backend/blob/main/app/models/user.py): `app/models/user.py`

### Other components

- **API client**
- **MusicBrainz service**

## Connections

- API client → FastAPI application: sends requests
- FastAPI application → API router: mounts routes (evidence: `app/main.py`)
- FastAPI application → Language preferences: seeds languages (evidence: `app/main.py`)
- API router → Authentication API: registers (evidence: `app/api/v1/router.py`)
- API router → Preferences API: registers (evidence: `app/api/v1/router.py`)
- API router → Home API: registers (evidence: `app/api/v1/router.py`)
- API router → Catalog APIs: registers (evidence: `app/api/v1/router.py`)
- API router → Search API: registers (evidence: `app/api/v1/router.py`)
- API router → User collections APIs: registers (evidence: `app/api/v1/router.py`)
- API router → Library API: registers (evidence: `app/api/v1/router.py`)
- API router → Downloads API: registers (evidence: `app/api/v1/router.py`)
- API router → Streaming API: registers (evidence: `app/api/v1/router.py`)
- API router → Artwork API: registers (evidence: `app/api/v1/router.py`)
- API router → Maintenance API: registers (evidence: `app/api/v1/router.py`)
- Authentication API → Token and password security: hashes and issues tokens (evidence: `app/api/v1/auth.py`)
- Authentication dependency → Token and password security: decodes tokens (evidence: `app/dependencies/auth.py`)
- Home discovery → MusicBrainz metadata: searches metadata (evidence: `app/services/home.py`)
- MusicBrainz metadata → MusicBrainz service: requests metadata
- Home API → Home discovery: uses discovery
- Downloads API → Music downloading: delegates downloads
- Streaming API → Music processing: uses media services
- Artwork API → Music processing: uses artwork service
- Downloads API → YouTube Music provider: may use provider
- Preferences API → Authentication dependency: requires user identity
- Authentication API → Database session: queries users (evidence: `app/api/v1/auth.py`)
- Authentication dependency → Database session: loads user (evidence: `app/dependencies/auth.py`)
- FastAPI application → Database session: closes resources (evidence: `app/main.py`)
- Home discovery → Track records: queries tracks (evidence: `app/services/home.py`)
- Home discovery → MusicBrainz metadata: uses language mapping (evidence: `app/services/home.py`)
- Language preferences → Database session: queries and seeds (evidence: `app/services/preferences/languages.py`)
- Authentication API → User records: creates and queries (evidence: `app/api/v1/auth.py`)
- Authentication dependency → User records: checks account (evidence: `app/dependencies/auth.py`)
- Track records → Database session: maps records (evidence: `app/models/track.py`)
- User records → Database session: maps records (evidence: `app/models/user.py`)
- Downloads API → Runtime configuration: may read settings
- Streaming API → Runtime configuration: may read settings
