# kowsalya-21/music_misatch_prediction architecture

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

- Interactive diagram: https://gitdiagram.com/kowsalya-21/music_misatch_prediction
- Repository: https://github.com/kowsalya-21/music_misatch_prediction

## Overview

Label Audit is a web-backed music mood and editorial-label auditing service. Users submit audio or search for a track; the API obtains audio and optional lyrics, produces acoustic and lyrical mood estimates, compares them with the supplied label, and invokes an investigative agent for flagged mismatches. The repository also contains substantial dataset preparation, model-training, and evaluation code. The graph reflects documented capabilities and indexed imports; unsampled implementation details and frontend wiring are not inferred.

Main entry points: [`backend/app/main.py`](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/main.py) (Analysis API), [`src/train/train_audio.py`](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/train/train_audio.py) (Audio model training), [`backend/app/agent/tools.py`](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/agent/tools.py) (Investigation tools), [`backend/static/app.js`](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/static/app.js) (Audit dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_audit["Audit service"]
  node_web["Audit dashboard<br/>[app.js]"]
  node_api["Analysis API<br/>[main.py]"]
  node_agent["Verification agent<br/>[engine.py]"]
  node_tools["Investigation tools<br/>[tools.py]"]
end

subgraph group_models["Inference models"]
  node_audio["Acoustic inference<br/>[audio.py]"]
  node_lyrics["Lyrics inference<br/>[lyrics.py]"]
  node_label["Label mood mapping<br/>[label.py]"]
  node_compare["Mismatch comparator<br/>[comparator.py]"]
  node_onnx["Audio model artifact<br/>[audio_mood.onnx]"]
end

subgraph group_research["Data and training"]
  node_preprocess["Audio preprocessing<br/>[preprocess.py]"]
  node_features["Audio feature extraction<br/>[audio_features.py]"]
  node_audio_model["Acoustic CNN<br/>[audio_model.py]"]
  node_augment["Spectrogram augmentation<br/>[augmentations.py]"]
  node_train_audio["Audio model training<br/>[train_audio.py]"]
  node_train_lyrics["Lyrics model training<br/>[train_lyrics.py]"]
  node_calibration["Temperature calibration"]
  node_baselines["Acoustic baselines<br/>[baseline_models.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Evaluation metrics<br/>[metrics.py]"]
end

node_user(("Auditor"))
node_catalog["Online catalog services"]

node_user -->|"uses"| node_web
node_web -.->|"submits analysis"| node_api
node_api -->|"predicts mood"| node_audio
node_api -->|"analyzes lyrics"| node_lyrics
node_api -->|"maps label"| node_label
node_api -->|"compares signals"| node_compare
node_api -->|"requests verification"| node_agent
node_api -->|"fetches lyrics"| node_tools
node_agent -->|"runs tools"| node_tools
node_tools -->|"searches catalog"| node_catalog
node_audio -->|"loads model"| node_onnx
node_preprocess -->|"uses extraction"| node_features
node_train_audio -->|"trains CNN"| node_audio_model
node_train_audio -->|"augments samples"| node_augment
node_train_audio -->|"calibrates outputs"| node_calibration
node_train_audio -->|"trains baselines"| node_baselines
node_train_audio -->|"evaluates predictions"| node_metrics
node_baselines -->|"computes scores"| node_metrics
node_train_lyrics -.->|"uses emotion datasets"| node_catalog

click node_web "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/static/app.js"
click node_api "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/main.py"
click node_audio "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/audio.py"
click node_lyrics "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/lyrics.py"
click node_label "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/label.py"
click node_compare "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/comparator.py"
click node_agent "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/agent/engine.py"
click node_tools "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/agent/tools.py"
click node_onnx "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/weights/audio_mood.onnx"
click node_preprocess "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/features/preprocess.py"
click node_features "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/features/audio_features.py"
click node_audio_model "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/audio_model.py"
click node_augment "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/augmentations.py"
click node_train_audio "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/train/train_audio.py"
click node_train_lyrics "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/train/train_lyrics.py"
click node_calibration "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/temperature_scaling.py"
click node_baselines "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/baseline_models.py"
click node_metrics "https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/eval/metrics.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_web,node_api,node_agent,node_tools toneBlue
class node_audio,node_lyrics,node_label,node_compare,node_onnx toneAmber
class node_preprocess,node_features,node_audio_model,node_augment,node_train_audio,node_train_lyrics,node_calibration,node_baselines toneMint
class node_metrics toneRose
class node_user,node_catalog toneIndigo
```

## Components

### Audit service

- [Audit dashboard](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/static/app.js): `backend/static/app.js`
- [Analysis API](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/main.py): `backend/app/main.py`
- [Verification agent](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/agent/engine.py): `backend/app/agent/engine.py`
- [Investigation tools](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/agent/tools.py): `backend/app/agent/tools.py`

### Inference models

- [Acoustic inference](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/audio.py): `backend/app/inference/audio.py`
- [Lyrics inference](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/lyrics.py): `backend/app/inference/lyrics.py`
- [Label mood mapping](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/label.py): `backend/app/inference/label.py`
- [Mismatch comparator](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/backend/app/inference/comparator.py): `backend/app/inference/comparator.py`
- [Audio model artifact](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/weights/audio_mood.onnx): `weights/audio_mood.onnx`

### Data and training

- [Audio preprocessing](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/features/preprocess.py): `src/features/preprocess.py`
- [Audio feature extraction](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/features/audio_features.py): `src/features/audio_features.py`
- [Acoustic CNN](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/audio_model.py): `src/models/audio_model.py`
- [Spectrogram augmentation](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/augmentations.py): `src/models/augmentations.py`
- [Audio model training](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/train/train_audio.py): `src/train/train_audio.py`
- [Lyrics model training](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/train/train_lyrics.py): `src/train/train_lyrics.py`
- [Temperature calibration](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/temperature_scaling.py): `src/models/temperature_scaling.py`
- [Acoustic baselines](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/models/baseline_models.py): `src/models/baseline_models.py`

### Evaluation

- [Evaluation metrics](https://github.com/kowsalya-21/music_misatch_prediction/blob/main/src/eval/metrics.py): `src/eval/metrics.py`

### Other components

- **Auditor**
- **Online catalog services**

## Connections

- Auditor → Audit dashboard: uses (evidence: `README.md`)
- Audit dashboard → Analysis API: submits analysis
- Analysis API → Acoustic inference: predicts mood (evidence: `backend/app/main.py`)
- Analysis API → Lyrics inference: analyzes lyrics (evidence: `backend/app/main.py`)
- Analysis API → Label mood mapping: maps label (evidence: `backend/app/main.py`)
- Analysis API → Mismatch comparator: compares signals (evidence: `backend/app/main.py`)
- Analysis API → Verification agent: requests verification (evidence: `backend/app/main.py`)
- Analysis API → Investigation tools: fetches lyrics (evidence: `backend/app/main.py`)
- Verification agent → Investigation tools: runs tools (evidence: `backend/app/agent/engine.py`)
- Investigation tools → Online catalog services: searches catalog (evidence: `backend/app/agent/tools.py`)
- Acoustic inference → Audio model artifact: loads model (evidence: `backend/app/inference/audio.py`)
- Audio preprocessing → Audio feature extraction: uses extraction (evidence: `src/features/preprocess.py`)
- Audio model training → Acoustic CNN: trains CNN (evidence: `src/train/train_audio.py`)
- Audio model training → Spectrogram augmentation: augments samples (evidence: `src/train/train_audio.py`)
- Audio model training → Temperature calibration: calibrates outputs (evidence: `src/train/train_audio.py`)
- Audio model training → Acoustic baselines: trains baselines (evidence: `src/train/train_audio.py`)
- Audio model training → Evaluation metrics: evaluates predictions (evidence: `src/train/train_audio.py`)
- Acoustic baselines → Evaluation metrics: computes scores (evidence: `src/models/baseline_models.py`)
- Lyrics model training → Online catalog services: uses emotion datasets
