# layzxz/bitchord-flac-addon architecture

> Architecture diagram of the GitHub repository layzxz/bitchord-flac-addon, 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/layzxz/bitchord-flac-addon
- Repository: https://github.com/layzxz/bitchord-flac-addon

## Overview

BitChord clients request a manifest, search for audio, or resolve an item to a stream URL. The search workflow queries Internet Archive audio records, resolves candidate metadata, selects actual FLAC files, and formats matching tracks; stream requests reuse FLAC resolution. The implementation is concentrated in server.py, so nodes distinguish its runtime responsibilities rather than implying separate modules. The excerpt shows the relevant calls; Internet Archive is an external service.

Main entry points: [`server.py`](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py) (Search handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["Addon HTTP API"]
  node_manifest["Manifest endpoints<br/>[server.py]"]
  node_health["Health endpoint<br/>[server.py]"]
  node_search_route["Search route<br/>[server.py]"]
  node_stream_route["Stream routes<br/>[server.py]"]
end

subgraph group_discovery["Archive Discovery"]
  node_search_handler["Search handler<br/>[server.py]"]
  node_ia_search["IA search API"]
  node_track_formatter["Track formatter<br/>[server.py]"]
end

subgraph group_flac["FLAC Resolution"]
  node_item_resolver["Item FLAC resolver<br/>[server.py]"]
  node_ia_metadata["IA metadata API"]
  node_flac_inspector["FLAC inspector<br/>[server.py]"]
  node_header_probe["Header probe<br/>[server.py]"]
  node_ia_files["IA file downloads"]
  node_stream_handler["Stream handler<br/>[server.py]"]
  node_quality_label["Quality labeling<br/>[server.py]"]
end

node_client(("BitChord client"))

node_client -->|"requests"| node_manifest
node_client -->|"checks"| node_health
node_client -->|"searches"| node_search_route
node_client -->|"resolves"| node_stream_route
node_search_route -->|"dispatches"| node_search_handler
node_search_handler -->|"queries"| node_ia_search
node_search_handler -->|"resolves candidates"| node_item_resolver
node_item_resolver -->|"fetches metadata"| node_ia_metadata
node_item_resolver -->|"submits inspection"| node_flac_inspector
node_flac_inspector -->|"probes missing details"| node_header_probe
node_header_probe -->|"reads file header"| node_ia_files
node_search_handler -->|"formats matches"| node_track_formatter
node_track_formatter -->|"labels quality"| node_quality_label
node_stream_route -->|"dispatches"| node_stream_handler
node_stream_handler -->|"resolves item"| node_item_resolver
node_stream_handler -->|"labels quality"| node_quality_label

click node_manifest "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_health "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_search_route "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_search_handler "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_item_resolver "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_flac_inspector "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_header_probe "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_track_formatter "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_stream_route "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_stream_handler "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py"
click node_quality_label "https://github.com/layzxz/bitchord-flac-addon/blob/main/server.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_manifest,node_health,node_search_route,node_stream_route,node_client toneBlue
class node_search_handler,node_ia_search,node_track_formatter toneAmber
class node_item_resolver,node_ia_metadata,node_flac_inspector,node_header_probe,node_ia_files,node_stream_handler,node_quality_label toneMint
```

## Components

### Addon HTTP API

- [Manifest endpoints](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- [Health endpoint](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- [Search route](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- [Stream routes](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`

### Archive Discovery

- [Search handler](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- **IA search API**
- [Track formatter](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`

### FLAC Resolution

- [Item FLAC resolver](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- **IA metadata API**
- [FLAC inspector](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- [Header probe](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- **IA file downloads**
- [Stream handler](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`
- [Quality labeling](https://github.com/layzxz/bitchord-flac-addon/blob/main/server.py): `server.py`

### Other components

- **BitChord client**

## Connections

- BitChord client → Manifest endpoints: requests (evidence: `server.py`)
- BitChord client → Health endpoint: checks (evidence: `server.py`)
- BitChord client → Search route: searches (evidence: `server.py`)
- BitChord client → Stream routes: resolves (evidence: `server.py`)
- Search route → Search handler: dispatches (evidence: `server.py`)
- Search handler → IA search API: queries (evidence: `server.py`)
- Search handler → Item FLAC resolver: resolves candidates (evidence: `server.py`)
- Item FLAC resolver → IA metadata API: fetches metadata (evidence: `server.py`)
- Item FLAC resolver → FLAC inspector: submits inspection (evidence: `server.py`)
- FLAC inspector → Header probe: probes missing details (evidence: `server.py`)
- Header probe → IA file downloads: reads file header (evidence: `server.py`)
- Search handler → Track formatter: formats matches (evidence: `server.py`)
- Track formatter → Quality labeling: labels quality (evidence: `server.py`)
- Stream routes → Stream handler: dispatches (evidence: `server.py`)
- Stream handler → Item FLAC resolver: resolves item (evidence: `server.py`)
- Stream handler → Quality labeling: labels quality (evidence: `server.py`)
