# ezellm/echosee architecture

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

- Interactive diagram: https://gitdiagram.com/ezellm/echosee
- Repository: https://github.com/ezellm/echosee

## Overview

##### Project Type and Purpose
- EchoSee is an open‑source, modular voice‑assistant pipeline (not a full‑stack web app or compiler). Its goal is to provide a conversational assistant by integrating speech‑to‑text, language‑model agents, event scheduling, and text‑to‑speech.

##### File Structure
- Top‑level directories/modules:
- agent_management – manages conversational agents and tools (e.g., LeetCode helper)
- event_manager – schedules and dispatches timed callbacks
- app_manager – orchestration of the main capture→process→respond loop
- stt – speech‑to‑text interface
- tts – text‑to‑speech interface
- logger – centralized logging
- utils – configuration loading, LLM initialization, environment setup
- Configuration files: config.yml (runtime settings), CONSTANTS.py, requirements.txt, setup scripts
- Assets: alarm sound file

##### README for Architectural Insights
- The “Application Manager” drives the main loop: STT → Agent → TTS
- Agent Management interacts with Event Manager and external APIs (OpenAI, LeetCode)
- Event Manager uses a heap‑based scheduler for alarms and recurring tasks
- Utilities handle environment setup and graceful shutdown

1. Input Layer
- Microphone / Keyboard (User Interface)
- STT Module (stt/stt.py)
2. Core Processing
- Application Manager (app_manager/manager.py)
- Agent Management
- Agent Manager (agent_management/agent_manager.py)
- Agents & Tools
– LeetCode API helper (agent_management/helpers/LeetCode)
- Event Manager (event_manager/event_manager.py & callbacks.py)
3. Output Layer
- TTS Module (tts/tts.py)
- Audio Output (Speaker)
4. Support Services
- Logger (logger/logger.py)
- Utils & Config Loader (utils/utils.py, config.yml)
- Persistent Storage: logs/ directory
5. External Services
- OpenAI APIs (STT, LLM, TTS)
- LeetCode API

b. Relationships and Data Flow
- Logger attaches to every major handoff (STT → Agent → Event → TTS)
- Utils/config loaded at startup by Application Manager

c. Key Architectural Patterns & Principles
- Modular separation of concerns (STT, Agent logic, Event scheduling, TTS)
- Plugin‑style agents and helpers for extensibility (e.g., add new tools under agent_management/helpers)
- Publisher‑subscriber or callback pattern in Event Manager for alarms
- Single orchestration layer (app_manager) to avoid circular dependencies
- Centralized configuration and environment setup

d. Relevant Technologies & Frameworks
- Python 3 modules
- OpenAI APIs (LLM, STT, GPT‑4o‑mini‑tts)
- Kokoro TTS option for edge devices
- Python’s heapq for scheduling in Event Manager
- YAML for config (config.yml)
- Logging module writing to logs/

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Layer
    subgraph "Input Layer"
        direction TB
        UserInput["Microphone / Keyboard"]:::core
        STT["STT Module"]:::core
    end

    %% Core Processing
    subgraph "Core Processing"
        direction TB
        ApplicationManager["Application Manager"]:::core
        AgentManager["Agent Manager"]:::core
        subgraph "Agents & Tools"
            direction TB
            LeetCodeAPI["LeetCodeAPI"]:::external
            LeetCodeAgent["LeetCodeAgent"]:::external
        end
        subgraph "Event Manager"
            direction TB
            EventManagerScheduler["Event Manager\nScheduler"]:::core
            EventCallbacks["Event Callbacks"]:::core
            EventTools["Event Tools"]:::core
        end
    end

    %% Output Layer
    subgraph "Output Layer"
        direction TB
        TTS["TTS Module"]:::core
        Speaker["Audio Output (Speaker)"]:::core
    end

    %% Support Services
    subgraph "Support Services"
        direction TB
        Logger["Logger"]:::support
        Utils["Utils & Config Loader"]:::support
    end

    %% Configuration & Storage
    subgraph "Configuration & Storage"
        direction TB
        Config["config.yml"]:::config
        Constants["CONSTANTS.py"]:::config
        AlarmAsset["Alarm Asset\n(alarm1.wav)"]:::config
        LogsStorage(("Logs Storage")):::storage
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OpenAI["OpenAI APIs"]:::external
        LeetCodeAPIExt["LeetCode API"]:::external
    end

    %% Data Flow
    UserInput -->|"audio→stream"| STT
    STT -->|"transcribed text"| ApplicationManager
    ApplicationManager -->|"text→AgentManager"| AgentManager
    AgentManager -->|"invoke tools"| LeetCodeAPI & LeetCodeAgent
    AgentManager -->|"schedule events"| EventManagerScheduler
    EventCallbacks -->|"callback→AgentManager"| AgentManager
    AgentManager -->|"calls external LLM/STT/TTS"| OpenAI
    AgentManager -->|"response text"| ApplicationManager
    ApplicationManager -->|"text→TTS"| TTS
    TTS -->|"audio"| Speaker

    %% Logging
    STT -->|logs| Logger
    AgentManager -->|logs| Logger
    EventManagerScheduler -->|logs| Logger
    TTS -->|logs| Logger

    %% Configuration Load
    Config -->|"loaded by"| Utils
    Constants -->|"loaded by"| Utils
    Utils -->|"config/env setup"| ApplicationManager

    %% External Service mapping
    LeetCodeAPI -->|helper| LeetCodeAPIExt

    %% Click Events
    click STT "https://github.com/ezellm/echosee/blob/dev/stt/stt.py"
    click ApplicationManager "https://github.com/ezellm/echosee/blob/dev/app_manager/manager.py"
    click AgentManager "https://github.com/ezellm/echosee/blob/dev/agent_management/agent_manager.py"
    click LeetCodeAPI "https://github.com/ezellm/echosee/blob/dev/agent_management/helpers/LeetCode/LeetCodeAPI.py"
    click LeetCodeAgent "https://github.com/ezellm/echosee/blob/dev/agent_management/helpers/LeetCode/agent.py"
    click EventManagerScheduler "https://github.com/ezellm/echosee/blob/dev/event_manager/event_manager.py"
    click EventCallbacks "https://github.com/ezellm/echosee/blob/dev/event_manager/callbacks.py"
    click EventTools "https://github.com/ezellm/echosee/blob/dev/event_manager/tools.py"
    click TTS "https://github.com/ezellm/echosee/blob/dev/tts/tts.py"
    click Logger "https://github.com/ezellm/echosee/blob/dev/logger/logger.py"
    click Utils "https://github.com/ezellm/echosee/blob/dev/utils/utils.py"
    click Config "https://github.com/ezellm/echosee/blob/dev/config.yml"
    click Constants "https://github.com/ezellm/echosee/blob/dev/CONSTANTS.py"
    click AlarmAsset "https://github.com/ezellm/echosee/blob/dev/assets/alarm1.wav"
    click LogsStorage "https://github.com/ezellm/echosee/tree/dev/logs/"

    %% Styles
    classDef core fill:#ACE7EF,stroke:#2F4F4F,color:#000;
    classDef support fill:#C6E2B3,stroke:#2F4F4F,color:#000;
    classDef external fill:#F4A460,stroke:#2F4F4F,color:#000;
    classDef config fill:#D3D3D3,stroke:#2F4F4F,color:#000;
    classDef storage fill:#E6E6FA,stroke:#2F4F4F,color:#000;
```
