# icecold009/audio-recognition architecture

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

- Interactive diagram: https://gitdiagram.com/icecold009/audio-recognition
- Repository: https://github.com/icecold009/audio-recognition

## Overview

Audio Recognition is a Flask-and-CLI song identification application. Users provide microphone audio or a file; the application validates and normalizes it, optionally writes an FFT diagnostic, dispatches recognition across configured providers or a local fingerprint index, then presents a normalized match or recovery status. The sampled code confirms the CLI orchestration, web API quota enforcement, provider calls, fingerprinting, display, and browser result handling. Some web upload conversion and provider-dispatch details are preserved only from the README.

Main entry points: [`shazam_project/matcher.py`](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/matcher.py) (Matcher Dispatcher), [`web/app.py`](https://github.com/icecold009/audio-recognition/blob/main/web/app.py) (Flask API), [`main.py`](https://github.com/icecold009/audio-recognition/blob/main/main.py) (CLI Entry), [`web/static/app.js`](https://github.com/icecold009/audio-recognition/blob/main/web/static/app.js) (Browser UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Surfaces"]
  node_browser_ui["Browser UI<br/>[app.js]"]
  node_flask_app["Flask API<br/>[app.py]"]
  node_cli["CLI Entry<br/>[main.py]"]
end

subgraph group_audio["Audio Pipeline"]
  node_audio_input["Audio Input<br/>[recorder.py]"]
  node_normalizer["Audio Normalizer<br/>[recorder.py]"]
  node_fft_diagnostic["FFT Diagnostic<br/>[fft_analyze.py]"]
end

subgraph group_recognition["Recognition Backends"]
  node_matcher["Matcher Dispatcher<br/>[matcher.py]"]
  node_shazam["RapidAPI Shazam"]
  node_acoustid["AcoustID"]
  node_audd["AudD"]
  node_fingerprint_engine["Fingerprint Engine<br/>[fingerprint.py]"]
  node_fingerprint_index[("Fingerprint Index<br/>[fingerprint.py]")]
  node_fpcalc["Chromaprint fpcalc"]
end

subgraph group_results["Results Presentation"]
  node_cli_display["CLI Display<br/>[display.py]"]
  node_session_history[("Session History<br/>[app.js]")]
end

subgraph group_ops["Runtime Controls"]
  node_config["Runtime Configuration<br/>[config.py]"]
  node_memory_quota[("Memory Quota<br/>[app.py]")]
  node_supabase_quota[("Supabase Quota")]
end

node_user_browser(("Browser User"))
node_user_cli(("CLI User"))
node_microphone(("Microphone"))
node_audio_file["Audio File"]

node_user_browser -->|"uses"| node_browser_ui
node_user_cli -->|"starts"| node_cli
node_microphone -->|"provides audio"| node_audio_input
node_audio_file -->|"provides audio"| node_audio_input
node_browser_ui -->|"uploads audio"| node_flask_app
node_flask_app -->|"matches upload"| node_matcher
node_cli -->|"loads config"| node_config
node_flask_app -->|"loads config"| node_config
node_cli -->|"captures or loads"| node_audio_input
node_audio_input -->|"normalizes input"| node_normalizer
node_matcher -->|"normalizes clip"| node_normalizer
node_cli -->|"creates diagnostic"| node_fft_diagnostic
node_cli -->|"requests match"| node_matcher
node_matcher -->|"calls provider"| node_shazam
node_matcher -->|"calls provider"| node_acoustid
node_matcher -->|"calls provider"| node_audd
node_matcher -->|"runs local match"| node_fingerprint_engine
node_fingerprint_engine -->|"reads hashes"| node_fingerprint_index
node_matcher -.->|"gets fingerprint"| node_fpcalc
node_matcher -->|"returns result"| node_flask_app
node_flask_app -->|"returns JSON"| node_browser_ui
node_matcher -->|"returns result"| node_cli_display
node_browser_ui -->|"stores session"| node_session_history
node_flask_app -->|"updates quota"| node_memory_quota
node_flask_app -.->|"checks quota"| node_supabase_quota

click node_browser_ui "https://github.com/icecold009/audio-recognition/blob/main/web/static/app.js"
click node_flask_app "https://github.com/icecold009/audio-recognition/blob/main/web/app.py"
click node_cli "https://github.com/icecold009/audio-recognition/blob/main/main.py"
click node_audio_input "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/recorder.py"
click node_normalizer "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/recorder.py"
click node_fft_diagnostic "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fft_analyze.py"
click node_matcher "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/matcher.py"
click node_fingerprint_engine "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fingerprint.py"
click node_fingerprint_index "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fingerprint.py"
click node_cli_display "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/display.py"
click node_session_history "https://github.com/icecold009/audio-recognition/blob/main/web/static/app.js"
click node_config "https://github.com/icecold009/audio-recognition/blob/main/shazam_project/config.py"
click node_memory_quota "https://github.com/icecold009/audio-recognition/blob/main/web/app.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_browser_ui,node_flask_app,node_cli,node_user_browser,node_user_cli toneBlue
class node_audio_input,node_normalizer,node_fft_diagnostic toneAmber
class node_matcher,node_shazam,node_acoustid,node_audd,node_fingerprint_engine,node_fingerprint_index,node_fpcalc toneMint
class node_cli_display,node_session_history toneRose
class node_config,node_memory_quota,node_supabase_quota,node_microphone,node_audio_file toneIndigo
```

## Components

### Entry Surfaces

- [Browser UI](https://github.com/icecold009/audio-recognition/blob/main/web/static/app.js): `web/static/app.js`
- [Flask API](https://github.com/icecold009/audio-recognition/blob/main/web/app.py): `web/app.py`
- [CLI Entry](https://github.com/icecold009/audio-recognition/blob/main/main.py): `main.py`

### Audio Pipeline

- [Audio Input](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/recorder.py): `shazam_project/recorder.py`
- [Audio Normalizer](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/recorder.py): `shazam_project/recorder.py`
- [FFT Diagnostic](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fft_analyze.py): `shazam_project/fft_analyze.py`

### Recognition Backends

- [Matcher Dispatcher](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/matcher.py): `shazam_project/matcher.py`
- **RapidAPI Shazam**
- **AcoustID**
- **AudD**
- [Fingerprint Engine](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fingerprint.py): `shazam_project/fingerprint.py`
- [Fingerprint Index](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/fingerprint.py): `shazam_project/fingerprint.py`
- **Chromaprint fpcalc**

### Results Presentation

- [CLI Display](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/display.py): `shazam_project/display.py`
- [Session History](https://github.com/icecold009/audio-recognition/blob/main/web/static/app.js): `web/static/app.js`

### Runtime Controls

- [Runtime Configuration](https://github.com/icecold009/audio-recognition/blob/main/shazam_project/config.py): `shazam_project/config.py`
- [Memory Quota](https://github.com/icecold009/audio-recognition/blob/main/web/app.py): `web/app.py`
- **Supabase Quota**

### Other components

- **Browser User**
- **CLI User**
- **Microphone**
- **Audio File**

## Connections

- Browser User → Browser UI: uses
- CLI User → CLI Entry: starts
- Microphone → Audio Input: provides audio
- Audio File → Audio Input: provides audio
- Browser UI → Flask API: uploads audio
- Flask API → Matcher Dispatcher: matches upload
- CLI Entry → Runtime Configuration: loads config
- Flask API → Runtime Configuration: loads config
- CLI Entry → Audio Input: captures or loads
- Audio Input → Audio Normalizer: normalizes input
- Matcher Dispatcher → Audio Normalizer: normalizes clip
- CLI Entry → FFT Diagnostic: creates diagnostic
- CLI Entry → Matcher Dispatcher: requests match
- Matcher Dispatcher → RapidAPI Shazam: calls provider
- Matcher Dispatcher → AcoustID: calls provider
- Matcher Dispatcher → AudD: calls provider
- Matcher Dispatcher → Fingerprint Engine: runs local match
- Fingerprint Engine → Fingerprint Index: reads hashes
- Matcher Dispatcher → Chromaprint fpcalc: gets fingerprint
- Matcher Dispatcher → Flask API: returns result
- Flask API → Browser UI: returns JSON
- Matcher Dispatcher → CLI Display: returns result
- Browser UI → Session History: stores session
- Flask API → Memory Quota: updates quota
- Flask API → Supabase Quota: checks quota
