# snehap08/leaf_gemini architecture

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

- Interactive diagram: https://gitdiagram.com/snehap08/leaf_gemini
- Repository: https://github.com/snehap08/leaf_gemini

## Overview

##### Project type and purpose
- This is a small, Python-based open-source conversational assistant (L-E-A-F) designed to run locally as a CLI/voice interface.
- Its core goal is to capture voice input, send it to an AI service for language processing, and present the AI’s response back to the user.

##### File structure
- Top-level files:
- README.md – project overview & usage instructions
- config.py – holds configuration (API keys, endpoints, thresholds)
- main.py – orchestrator: initializes modules, drives the conversation loop
- mic_input.py – audio capture and (optional) speech-to-text wrapper
- No frontend/backend split—this is a single-process tool. The pattern is a simple modular pipeline: Input → Processing → Output.

##### Extract insights from the README
- Dependencies are installed via pip and invoked through `python main.py`.
- Users interact via terminal prompts (and possibly audio I/O).
- The “AI-powered” portion is outsourced to an external API (e.g., OpenAI, Google Cloud, etc.).

##### Main components & interactions
a. Components
1. User (Microphone / Keyboard)
2. Audio Input Module (mic_input.py)
3. Conversation Orchestrator (main.py)
4. Configuration Store (config.py)
5. External AI Service (e.g., OpenAI API)
6. Output Module (console print or TTS)
b. Relationships & data flows
- User → Audio Input Module: raw audio stream
- Audio Input Module → Orchestrator: transcribed text (or raw audio pointer)
- Orchestrator → Config Store: read API keys and settings
- Orchestrator → External AI Service: send user prompt
→ receive AI response
- Orchestrator → Output Module: display or speak reply
- Optionally loop back to Audio Input Module for next turn
c. Architectural patterns & principles
- Single-process pipeline with clear separation of concerns
- Modular design: swapping out mic_input.py or config.py causes minimal ripple
- External dependency inversion: AI logic is abstracted behind an API interface
d. Key technologies & libraries
- Python 3.x
- Speech-to-text library (e.g., SpeechRecognition or custom)
- HTTP client (e.g., requests or openai sdk)
- (Optional) Text-to-speech library

##### Detail is key—capture every module and its inputs/outputs
- Break out the **speech-to-text** and **text-to-speech** (if present)
- Config as a read-only dependency of main.py

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User I/O
    User["User\n(Microphone / Keyboard)"]:::userIO

    %% Internal Modules
    AIInput["Audio Input Module\n(mic_input.py)"]:::local
    Orchestrator["Conversation Orchestrator\n(main.py)"]:::local
    ConfigStore[(Configuration Store\nconfig.py)]:::local
    OutputModule["Output Module\n(console/TTS)"]:::local

    %% External Service
    AIService["External AI Service"]:::external

    %% Data Flows
    User -->|"raw audio stream"| AIInput
    AIInput -->|"transcribed text"| Orchestrator
    Orchestrator -->|"read settings / keys"| ConfigStore
    Orchestrator -->|"API request"| AIService
    AIService -->|"API response"| Orchestrator
    Orchestrator -->|"display / speak reply"| OutputModule
    OutputModule -->|"next turn"| AIInput

    %% Click Events
    click AIInput "https://github.com/snehap08/leaf_gemini/blob/main/mic_input.py"
    click Orchestrator "https://github.com/snehap08/leaf_gemini/blob/main/main.py"
    click ConfigStore "https://github.com/snehap08/leaf_gemini/blob/main/config.py"
    click AIService "https://github.com/snehap08/leaf_gemini/blob/main/main.py"
    click OutputModule "https://github.com/snehap08/leaf_gemini/blob/main/main.py"

    %% Styles
    classDef userIO fill:#b2f2bb,stroke:#333,stroke-width:1px
    classDef local fill:#aed6f1,stroke:#333,stroke-width:1px
    classDef external fill:#f5b041,stroke:#333,stroke-width:1px
```
