# emmdrole/tars architecture

> Architecture diagram of the GitHub repository emmdrole/tars, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emmdrole/tars
- Repository: https://github.com/emmdrole/tars

## Overview

##### Project type and purpose
- This is a Python-based real-time audio processing application (named “realtime_robot”) packaged as a CLI/service.
- Purpose: capture live audio, send it to OpenAI via WebSocket, receive text or commands, then synthesize voice using ElevenLabs TTS and potentially route output back to the user (or downstream systems).

##### File structure
- Top level:
- pyproject.toml & .venv → Python project with isolated environment and packaging info
- src/main.py → application entry point (orchestrator)
- src/audio/audio_input.py → audio capture module
- src/ws/openai_ws.py → WebSocket client to OpenAI
- src/voice/elevenlabs_ws.py → WebSocket client to ElevenLabs TTS
- debug_audio.raw → sample or test audio data

##### README for additional insights
- README.md is a placeholder (“tars… coming soon”), so no formal architecture docs. All inference comes from code layout and file names.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Internal Modules
    subgraph "Internal Modules"
        direction TB
        AudioInput["Audio Input Module"]:::inputoutput
        Orchestrator["Orchestrator / Controller"]:::orchestrator
        OpenAIWS["OpenAI WebSocket Client"]:::wsclient
        ElevenLabsWS["ElevenLabs WebSocket Client"]:::wsclient
        AudioOutput["Audio Output Module"]:::inputoutput
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI_API["OpenAI API"]:::external
        ElevenLabs_API["ElevenLabs TTS API"]:::external
    end

    %% Project Files
    subgraph "Project Files"
        direction TB
        Packaging1["pyproject.toml"]:::files
        Packaging2["src/realtime_robot.egg-info/"]:::files
        DebugAudio["debug_audio.raw"]:::files
    end

    %% Data Flow
    AudioInput -->|"PCM frames over callback"| Orchestrator
    Orchestrator -->|"JSON over WebSocket"| OpenAIWS
    OpenAIWS -->|"Text/commands JSON"| Orchestrator
    Orchestrator -->|"JSON over WebSocket"| ElevenLabsWS
    ElevenLabsWS -->|"Audio stream"| Orchestrator
    Orchestrator -->|"PCM frames or file"| AudioOutput

    %% External connections
    OpenAIWS -->|"WebSocket"| OpenAI_API
    ElevenLabsWS -->|"WebSocket"| ElevenLabs_API

    %% Click Events
    click AudioInput "https://github.com/emmdrole/tars/blob/master/src/audio/audio_input.py"
    click Orchestrator "https://github.com/emmdrole/tars/blob/master/src/main.py"
    click OpenAIWS "https://github.com/emmdrole/tars/blob/master/src/ws/openai_ws.py"
    click ElevenLabsWS "https://github.com/emmdrole/tars/blob/master/src/voice/elevenlabs_ws.py"
    click Packaging1 "https://github.com/emmdrole/tars/blob/master/pyproject.toml"
    click Packaging2 "https://github.com/emmdrole/tars/tree/master/src/realtime_robot.egg-info/"
    click DebugAudio "https://github.com/emmdrole/tars/blob/master/debug_audio.raw"

    %% Styles
    classDef inputoutput fill:#e2f7e1,stroke:#2d662d,color:#2d662d;
    classDef orchestrator fill:#cfe2f3,stroke:#2b5797,color:#2b5797;
    classDef wsclient fill:#e3d4f3,stroke:#5b2e7e,color:#5b2e7e;
    classDef external fill:#d3d3d3,stroke:#666666,color:#444444;
    classDef files fill:#f9e79f,stroke:#b7950b,color:#7d6608;
```
