# lukifer/voicetunes architecture

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

- Interactive diagram: https://gitdiagram.com/lukifer/voicetunes
- Repository: https://github.com/lukifer/voicetunes

## Overview

##### Main System Components

a) Input Layer:
- Bluetooth Controller Interface (bt.ts)
- MQTT Listener (mqttlisten.ts)
- Voice Input System (voice2json integration)

b) Core Processing Layer:
- Intent Processing (intent.ts)
- Command Parser (sentences.ini.ts)
- Database Layer (db.ts)

c) Output Layer:
- Mopidy Audio Player
- LED Feedback System (led.ts)
- Sound Effects (sfx.ts)

##### Data Flow Representation

**[Input Sources] → [Command Processing] → [Audio Output]**
- ↓                    ↕                    ↑
**[Voice2JSON] → [Intent Parser] → [Database] → [Mopidy]**

##### Component Details

Specific elements:

a) Input Components:
- Bluetooth Button Controller
- MQTT Listener
- Microphone Input
- Both voice and text command paths

b) Processing Components:
- Voice2JSON Processing
- Intent Parser
- SQLite Database
- iTunes Library Integration

c) Output Components:
- Mopidy Audio Player
- LED Feedback
- Sound Effects System

##### External Dependencies
Integrations:
- voice2json
- Mopidy
- SQLite
- MQTT Broker
- Hardware interfaces (LED, Audio DAC)

##### Data Stores
Data sources:
- SQLite Database
- Configuration Files
- Static Data Files (years.json, decades.json, etc.)
- iTunes Library Data

##### Deployment Context

A separate section showing:
- Raspberry Pi deployment
- Startup process
- Auto-restart mechanism
- Optional UPS integration

This architecture should emphasize the project's unique approach to voice control (using a push-to-talk button rather than wake words) and its integration with various hardware and software components to create a complete car audio solution.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef hardware fill:#ff9999,stroke:#333,stroke-width:2px
    classDef software fill:#99ccff,stroke:#333,stroke-width:2px
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef datastore fill:#ffeb99,stroke:#333,stroke-width:2px
    classDef config fill:#e6ccff,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph Input
        BT["Bluetooth Controller"]:::hardware
        MQTT["MQTT Listener"]:::software
        MIC["Microphone Input"]:::hardware
    end

    %% Processing Layer
    subgraph Processing
        V2J["Voice2JSON"]:::external
        INTENT["Intent Processor"]:::software
        PARSER["Command Parser"]:::software
        CONFIG["Configuration"]:::config
    end

    %% Data Layer
    subgraph DataStores
        DB[(SQLite Database)]:::datastore
        STATIC["Static Data Files"]:::datastore
        ITUNES["iTunes Library"]:::datastore
    end

    %% Output Layer
    subgraph Output
        MOPIDY["Mopidy Player"]:::external
        LED["LED System"]:::hardware
        SFX["Sound Effects"]:::software
        DAC["USB DAC"]:::hardware
    end

    %% Connections
    BT --> INTENT
    MQTT --> INTENT
    MIC --> V2J
    V2J --> INTENT
    INTENT --> PARSER
    PARSER --> DB
    CONFIG --> INTENT
    DB --> MOPIDY
    INTENT --> LED
    INTENT --> SFX
    MOPIDY --> DAC
    STATIC --> PARSER
    ITUNES --> DB

    %% Click Events
    click BT "https://github.com/lukifer/voicetunes/blob/master/bt.ts"
    click MQTT "https://github.com/lukifer/voicetunes/blob/master/mqttlisten.ts"
    click INTENT "https://github.com/lukifer/voicetunes/blob/master/intent.ts"
    click PARSER "https://github.com/lukifer/voicetunes/blob/master/sentences.ini.ts"
    click CONFIG "https://github.com/lukifer/voicetunes/blob/master/config.ts"
    click DB "https://github.com/lukifer/voicetunes/blob/master/db.ts"
    click LED "https://github.com/lukifer/voicetunes/blob/master/led.ts"
    click SFX "https://github.com/lukifer/voicetunes/blob/master/sfx.ts"
    click STATIC "https://github.com/lukifer/voicetunes/tree/master/data"
    click ITUNES "https://github.com/lukifer/voicetunes/blob/master/itunes.ts"

    %% Legend
    subgraph Legend
        H["Hardware Component"]:::hardware
        S["Software Component"]:::software
        E["External Service"]:::external
        D["Data Store"]:::datastore
        C["Configuration"]:::config
    end
```
