# maxi2771/luchat architecture

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

- Interactive diagram: https://gitdiagram.com/maxi2771/luchat
- Repository: https://github.com/maxi2771/luchat

## Overview

##### Project Type and Purpose
- This is a single‐page, full-stack web application built with Streamlit (Python) that provides an interactive chatbot interface.
- It uses the Groq language‐model API (external service) to power conversational AI (Ludmi) and supports features like model selection, history display, and conversation reset.

##### File Structure
- `.streamlit/config.toml`: holds Groq API token (secrets management).
- `index.py`: main application logic and UI definition (Streamlit “frontend” and “backend” live in one file).
- `requirements.txt`: lists dependencies (`streamlit`, `groq`).
- `README.md`: project description, setup steps, technologies.

##### Readme Insights
- Streamlit serves both UI and server logic; there is no separate front‐end codebase (React/Angular).
- The app communicates over HTTP(S) to Groq’s API endpoint for generating chat completions.
- Users interact via a browser; the server runs locally or in the cloud.

##### Main Components and Relationships
a. User Browser (Client)
b. Streamlit App Server (index.py)
- UI Layer: input widgets, buttons, chat history display
- Business Logic Layer: processes user input, handles model selection, resets state
c. Groq External API
d. Configuration Store (.streamlit secrets)
e. (Optional) Static Assets Host (img folder)

Interactions:
1. User types a message in the browser.
2. Streamlit captures input in index.py.
3. Business logic constructs an API call (with groq_api token).
4. Streamlit (server) sends HTTP request to Groq endpoint.
5. Groq returns LLM-generated response.
6. Streamlit updates chat history and renders response in the browser.

##### Architectural Patterns and Design Principles
- Single‐page server‐driven UI (Streamlit).
- Clear separation of concerns within index.py: UI definitions vs. API interaction and state management.
- Externalizing secrets/configuration (12-factor app).
- External API integration for LLM functionality.

- Browser UI
- Streamlit Server (split into UI module and Logic module)
- Groq API Service
- Config/Secrets store
- Static Assets
- Browser → Streamlit UI
- UI → Logic (model selection, chat history)
- Logic → Groq API (HTTP request)
- Groq API → Logic (response)
- Logic → UI (render)
- Blue: User‐facing components (Browser UI)
- Green: In‐process server components (Streamlit UI + Logic)
- Orange: External services (Groq API)
- Grey: Configuration and assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User-facing Component
    Browser["User Browser (UI)"]:::user

    %% Streamlit App Server Components
    subgraph "Streamlit App Server"
        UI["Streamlit UI Module"]:::server
        Logic["Business Logic Module"]:::server
    end

    %% External Service
    API["Groq LLM API Service"]:::external

    %% Support & Configuration
    subgraph "Support & Assets"
        Config["Config Store (.streamlit/config.toml)"]:::support
        Assets["Static Assets (img/)"]:::support
        Deps["Dependencies (requirements.txt)"]:::support
        Docs["Project Docs (README.md)"]:::support
    end

    %% Data Flows
    Browser -->|"Chat message"| UI
    UI -->|"passes input"| Logic
    Logic -->|"HTTP API call\n(JSON request)"| API
    API -->|"JSON response"| Logic
    Logic -->|"renders response"| UI
    UI -->|"updates UI"| Browser

    Logic -->|"reads token"| Config
    UI -->|"loads assets"| Assets

    %% Click Events
    click UI "https://github.com/maxi2771/luchat/blob/master/index.py"
    click Config "https://github.com/maxi2771/luchat/blob/master/.streamlit/config.toml"
    click Assets "https://github.com/maxi2771/luchat/tree/master/img/"
    click Deps "https://github.com/maxi2771/luchat/blob/master/requirements.txt"
    click Docs "https://github.com/maxi2771/luchat/blob/master/README.md"

    %% Styles
    classDef user fill:#ACE7EF,stroke:#000,stroke-width:1px
    classDef server fill:#B9E4C9,stroke:#000,stroke-width:1px
    classDef external fill:#FFCC99,stroke:#000,stroke-width:1px
    classDef support fill:#D3D3D3,stroke:#000,stroke-width:1px
```
