# kaizenick/dunechatbot-voice-from-the-sietch architecture

> Architecture diagram of the GitHub repository kaizenick/dunechatbot-voice-from-the-sietch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaizenick/dunechatbot-voice-from-the-sietch
- Repository: https://github.com/kaizenick/dunechatbot-voice-from-the-sietch

## Overview

##### Main Components
- Chat UI Frontend: Represented primarily by app.py. This is where Streamlit serves the user interface, displays the chat, and handles user interactions.
- Language Model Layer: The langchain_ollama library in the project acts as the bridge between the Chat UI and the LLM running on the Ollama server.
- LLM Service: Ollama server (running the llama3.2 model locally) processes the incoming queries and returns the responses.
- Media/Asset Repository: The media directory, which holds static assets (like the movie file). This may be referenced by the UI for theming or illustration.
- Chat History Management: Although simple, the application maintains state (session history) within the Streamlit interface to preserve conversation context.

##### Relationships and Interactions
- User Interaction → Chat UI (app.py): The user sends a query via the Streamlit interface.
- Chat UI → Langchain Connector: The app.py uses langchain_ollama to pass the query to the locally running Ollama server.
- Langchain Connector ↔ Ollama Server: The query is processed by the LLM server which returns a response.
- Response Routing: The response is then sent back through the same chain and displayed in the Chat UI.
- Media Assets: The UI may access the media directory for displaying themed assets or multimedia content.

##### Architectural Patterns / Design Principles
- Dependency Inversion: The app.py is abstracted away from the specific details of the LLM because it uses langchain_ollama to communicate, making it easier to swap implementations if needed.
- Stateless/Stateful Management: Even though the application is simple, indicate that chat history (state) is maintained in the front-end session or similar.

##### Technical Stack and Key Technologies
- Python 3.8+: The core language.
- Streamlit: For creating the web-based chat interface.
- langchain_ollama: For interfacing with the local Ollama server.
- Ollama (llama3.2 model): The language model backend.
- Git for version control (with .gitignore to manage repository files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User"]:::user

    %% Frontend Layer
    subgraph "Frontend Layer"
        Chat_UI["Chat UI (Streamlit - app.py)"]:::frontend
        Chat_History["Chat History (Session)"]:::session
    end

    %% Backend Processing
    subgraph "Backend Processing"
        LM_Connector["Language Model Connector (langchain_ollama)"]:::frontend
        LLM_Server["Ollama Server (llama3.2)"]:::backend
    end

    %% Media Assets
    subgraph "Media Assets"
        Media["Media Assets (Directory)"]:::assets
        Movie_F["Movie Asset (movie.mov)"]:::assets
    end

    %% Connections
    User -->|"sendsQuery"| Chat_UI
    Chat_UI -->|"storesChat"| Chat_History
    Chat_UI -->|"sendsQuery"| LM_Connector
    LM_Connector -->|"forwardsQuery"| LLM_Server
    LLM_Server -->|"returnsResponse"| LM_Connector
    LM_Connector -->|"sendsResponse"| Chat_UI
    Chat_UI -->|"loadsMedia"| Media
    Media -->|"contains"| Movie_F

    %% Click Events
    click Chat_UI "https://github.com/kaizenick/dunechatbot-voice-from-the-sietch/blob/main/app.py"
    click LM_Connector "https://github.com/kaizenick/dunechatbot-voice-from-the-sietch/blob/main/app.py"
    click Chat_History "https://github.com/kaizenick/dunechatbot-voice-from-the-sietch/blob/main/app.py"
    click Media "https://github.com/kaizenick/dunechatbot-voice-from-the-sietch/tree/main/media/"
    click Movie_F "https://github.com/kaizenick/dunechatbot-voice-from-the-sietch/blob/main/media/movie.mov"

    %% Styles
    classDef user fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef frontend fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef backend fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef assets fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef session fill:#ffe5b4,stroke:#ff8c00,stroke-width:2px;
```
