# abtinmbm/andon architecture

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

- Interactive diagram: https://gitdiagram.com/abtinmbm/andon
- Repository: https://github.com/abtinmbm/andon

## Overview

Andon is an anomaly-detection product that learns normal machine sounds and signals deviations through an andon light. Its principal workflow is audio/data ingestion → log-mel features → model training and anomaly scoring → control limits and light-state simulation. The repository also includes benchmark evaluation, int8 conversion/export, a dashboard, and a Pico-oriented C firmware path. README statements support the documented end-to-end capabilities; firmware internals are only partly sampled, so uncertain internal connections are omitted or marked unverified.

Main entry points: [`andon/data/features.py`](https://github.com/abtinmbm/andon/blob/main/andon/data/features.py) (Feature extraction/cache), [`andon/train_idcnn.py`](https://github.com/abtinmbm/andon/blob/main/andon/train_idcnn.py) (CNN training), [`andon/train.py`](https://github.com/abtinmbm/andon/blob/main/andon/train.py) (Baseline training), [`andon/score.py`](https://github.com/abtinmbm/andon/blob/main/andon/score.py) (Anomaly scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data and features"]
  node_dataset["DCASE dataset<br/>[dataset.py]"]
  node_audio_io["WAV audio I/O<br/>[audio.py]"]
  node_features_cache["Feature extraction/cache<br/>[features.py]"]
  node_logmel["Log-mel frontend<br/>[logmel.py]"]
end

subgraph group_detection["Detection models"]
  node_classic_models["Classic models<br/>[classic.py]"]
  node_autoencoder["Autoencoder<br/>[autoencoder.py]"]
  node_idcnn["Machine-ID CNN<br/>[idcnn.py]"]
  node_train_classic["Baseline training<br/>[train.py]"]
  node_train_idcnn["CNN training<br/>[train_idcnn.py]"]
end

subgraph group_runtime["Scoring and evaluation"]
  node_experiment["Experiment configuration<br/>[experiment.py]"]
  node_scoring["Anomaly scoring<br/>[score.py]"]
  node_evaluation["Benchmark evaluation<br/>[evaluate.py]"]
  node_light["Light state logic<br/>[light.py]"]
  node_simulation["Stream simulator<br/>[simulate.py]"]
  node_quantization["Int8 conversion<br/>[quantize.py]"]
end

subgraph group_embedded["Embedded device"]
  node_export["C model export<br/>[export_c.py]"]
  node_firmware_main["Firmware controller<br/>[main.c]"]
  node_firmware_audio["Microphone stream<br/>[mic_stream.c]"]
  node_firmware_features["C log-mel frontend<br/>[logmel.c]"]
  node_firmware_model["C inference model<br/>[model.c]"]
end

subgraph group_interfaces["Interfaces"]
  node_dashboard["Dashboard<br/>[app.py]"]
end

node_machine_audio(("Machine audio"))
node_dataset_source[("DCASE recordings")]
node_fan["Fan hardware"]

node_dataset_source -->|"provides clips"| node_dataset
node_dataset -->|"selects clips"| node_features_cache
node_features_cache -->|"reads WAV"| node_audio_io
node_features_cache -->|"extracts features"| node_logmel
node_features_cache -->|"supplies features"| node_train_idcnn
node_features_cache -->|"supplies features"| node_train_classic
node_train_classic -->|"trains"| node_autoencoder
node_train_classic -.->|"trains"| node_classic_models
node_train_idcnn -->|"trains"| node_idcnn
node_train_idcnn -->|"loads normal clips"| node_dataset
node_train_classic -->|"uses run config"| node_experiment
node_train_idcnn -->|"uses run config"| node_experiment
node_scoring -->|"uses scoring helpers"| node_train_idcnn
node_scoring -->|"evaluates scores"| node_evaluation
node_simulation -->|"scores windows"| node_scoring
node_simulation -->|"drives states"| node_light
node_evaluation -->|"scores test clips"| node_dataset
node_evaluation -->|"logs results"| node_experiment
node_idcnn -->|"produces ID scores"| node_scoring
node_quantization -->|"converts model"| node_idcnn
node_quantization -->|"checks scores"| node_evaluation
node_export -->|"exports int8 model"| node_quantization
node_export -->|"writes C headers"| node_firmware_model
node_machine_audio -.->|"streams sound"| node_firmware_audio
node_firmware_main -->|"uses stream"| node_firmware_audio
node_firmware_audio -.->|"feeds frames"| node_firmware_features
node_firmware_features -.->|"provides features"| node_firmware_model
node_firmware_main -->|"controls fan"| node_fan
node_dashboard -->|"uses demo flow"| node_simulation
node_dashboard -->|"uses configuration"| node_experiment
node_dashboard -->|"uses light logic"| node_light

click node_dataset "https://github.com/abtinmbm/andon/blob/main/andon/data/dataset.py"
click node_audio_io "https://github.com/abtinmbm/andon/blob/main/andon/data/audio.py"
click node_features_cache "https://github.com/abtinmbm/andon/blob/main/andon/data/features.py"
click node_logmel "https://github.com/abtinmbm/andon/blob/main/andon/features/logmel.py"
click node_classic_models "https://github.com/abtinmbm/andon/blob/main/andon/models/classic.py"
click node_autoencoder "https://github.com/abtinmbm/andon/blob/main/andon/models/autoencoder.py"
click node_idcnn "https://github.com/abtinmbm/andon/blob/main/andon/models/idcnn.py"
click node_train_classic "https://github.com/abtinmbm/andon/blob/main/andon/train.py"
click node_train_idcnn "https://github.com/abtinmbm/andon/blob/main/andon/train_idcnn.py"
click node_experiment "https://github.com/abtinmbm/andon/blob/main/andon/experiment.py"
click node_scoring "https://github.com/abtinmbm/andon/blob/main/andon/score.py"
click node_evaluation "https://github.com/abtinmbm/andon/blob/main/andon/evaluate.py"
click node_light "https://github.com/abtinmbm/andon/blob/main/andon/light.py"
click node_simulation "https://github.com/abtinmbm/andon/blob/main/andon/simulate.py"
click node_quantization "https://github.com/abtinmbm/andon/blob/main/andon/quantize.py"
click node_export "https://github.com/abtinmbm/andon/blob/main/andon/export_c.py"
click node_firmware_main "https://github.com/abtinmbm/andon/blob/main/firmware/src/main.c"
click node_firmware_audio "https://github.com/abtinmbm/andon/blob/main/firmware/src/mic_stream.c"
click node_firmware_features "https://github.com/abtinmbm/andon/blob/main/firmware/src/logmel.c"
click node_firmware_model "https://github.com/abtinmbm/andon/blob/main/firmware/src/model.c"
click node_dashboard "https://github.com/abtinmbm/andon/blob/main/dashboard/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_dataset,node_audio_io,node_features_cache,node_logmel toneBlue
class node_classic_models,node_autoencoder,node_idcnn,node_train_classic,node_train_idcnn,node_dataset_source toneAmber
class node_experiment,node_scoring,node_evaluation,node_light,node_simulation,node_quantization toneMint
class node_export,node_firmware_main,node_firmware_audio,node_firmware_features,node_firmware_model toneRose
class node_dashboard,node_machine_audio,node_fan toneIndigo
```

## Components

### Data and features

- [DCASE dataset](https://github.com/abtinmbm/andon/blob/main/andon/data/dataset.py): `andon/data/dataset.py`
- [WAV audio I/O](https://github.com/abtinmbm/andon/blob/main/andon/data/audio.py): `andon/data/audio.py`
- [Feature extraction/cache](https://github.com/abtinmbm/andon/blob/main/andon/data/features.py): `andon/data/features.py`
- [Log-mel frontend](https://github.com/abtinmbm/andon/blob/main/andon/features/logmel.py): `andon/features/logmel.py`

### Detection models

- [Classic models](https://github.com/abtinmbm/andon/blob/main/andon/models/classic.py): `andon/models/classic.py`
- [Autoencoder](https://github.com/abtinmbm/andon/blob/main/andon/models/autoencoder.py): `andon/models/autoencoder.py`
- [Machine-ID CNN](https://github.com/abtinmbm/andon/blob/main/andon/models/idcnn.py): `andon/models/idcnn.py`
- [Baseline training](https://github.com/abtinmbm/andon/blob/main/andon/train.py): `andon/train.py`
- [CNN training](https://github.com/abtinmbm/andon/blob/main/andon/train_idcnn.py): `andon/train_idcnn.py`

### Scoring and evaluation

- [Experiment configuration](https://github.com/abtinmbm/andon/blob/main/andon/experiment.py): `andon/experiment.py`
- [Anomaly scoring](https://github.com/abtinmbm/andon/blob/main/andon/score.py): `andon/score.py`
- [Benchmark evaluation](https://github.com/abtinmbm/andon/blob/main/andon/evaluate.py): `andon/evaluate.py`
- [Light state logic](https://github.com/abtinmbm/andon/blob/main/andon/light.py): `andon/light.py`
- [Stream simulator](https://github.com/abtinmbm/andon/blob/main/andon/simulate.py): `andon/simulate.py`
- [Int8 conversion](https://github.com/abtinmbm/andon/blob/main/andon/quantize.py): `andon/quantize.py`

### Embedded device

- [C model export](https://github.com/abtinmbm/andon/blob/main/andon/export_c.py): `andon/export_c.py`
- [Firmware controller](https://github.com/abtinmbm/andon/blob/main/firmware/src/main.c): `firmware/src/main.c`
- [Microphone stream](https://github.com/abtinmbm/andon/blob/main/firmware/src/mic_stream.c): `firmware/src/mic_stream.c`
- [C log-mel frontend](https://github.com/abtinmbm/andon/blob/main/firmware/src/logmel.c): `firmware/src/logmel.c`
- [C inference model](https://github.com/abtinmbm/andon/blob/main/firmware/src/model.c): `firmware/src/model.c`

### Interfaces

- [Dashboard](https://github.com/abtinmbm/andon/blob/main/dashboard/app.py): `dashboard/app.py`

### Other components

- **Machine audio**
- **DCASE recordings**
- **Fan hardware**

## Connections

- DCASE recordings → DCASE dataset: provides clips
- DCASE dataset → Feature extraction/cache: selects clips (evidence: `andon/data/features.py`)
- Feature extraction/cache → WAV audio I/O: reads WAV (evidence: `andon/data/features.py`)
- Feature extraction/cache → Log-mel frontend: extracts features (evidence: `andon/data/features.py`)
- Feature extraction/cache → CNN training: supplies features (evidence: `andon/train_idcnn.py`)
- Feature extraction/cache → Baseline training: supplies features (evidence: `andon/train.py`)
- Baseline training → Autoencoder: trains (evidence: `andon/train.py`)
- Baseline training → Classic models: trains
- CNN training → Machine-ID CNN: trains (evidence: `andon/train_idcnn.py`)
- CNN training → DCASE dataset: loads normal clips (evidence: `andon/train_idcnn.py`)
- Baseline training → Experiment configuration: uses run config (evidence: `andon/train.py`)
- CNN training → Experiment configuration: uses run config (evidence: `andon/train_idcnn.py`)
- Anomaly scoring → CNN training: uses scoring helpers (evidence: `andon/score.py`)
- Anomaly scoring → Benchmark evaluation: evaluates scores (evidence: `andon/score.py`)
- Stream simulator → Anomaly scoring: scores windows (evidence: `andon/simulate.py`)
- Stream simulator → Light state logic: drives states (evidence: `andon/simulate.py`)
- Benchmark evaluation → DCASE dataset: scores test clips (evidence: `andon/evaluate.py`)
- Benchmark evaluation → Experiment configuration: logs results (evidence: `andon/evaluate.py`)
- Machine-ID CNN → Anomaly scoring: produces ID scores
- Int8 conversion → Machine-ID CNN: converts model (evidence: `andon/quantize.py`)
- Int8 conversion → Benchmark evaluation: checks scores (evidence: `andon/quantize.py`)
- C model export → Int8 conversion: exports int8 model (evidence: `andon/export_c.py`)
- C model export → C inference model: writes C headers
- Machine audio → Microphone stream: streams sound
- Firmware controller → Microphone stream: uses stream (evidence: `firmware/src/main.c`)
- Microphone stream → C log-mel frontend: feeds frames
- C log-mel frontend → C inference model: provides features
- Firmware controller → Fan hardware: controls fan (evidence: `firmware/src/main.c`)
- Dashboard → Stream simulator: uses demo flow (evidence: `dashboard/app.py`)
- Dashboard → Experiment configuration: uses configuration (evidence: `dashboard/app.py`)
- Dashboard → Light state logic: uses light logic (evidence: `dashboard/app.py`)
