# d-evil0per/ollama-chat-console architecture

> Architecture diagram of the GitHub repository d-evil0per/ollama-chat-console, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d-evil0per/ollama-chat-console
- Repository: https://github.com/d-evil0per/ollama-chat-console

## Overview

##### Project type and purpose
- This is a single‐page web application (a Streamlit frontend) that acts as a chat client for locally hosted Ollama LLMs.
- Purpose: provide a responsive UI for sending prompts, adjusting parameters, viewing/streaming responses, handling chat history (export/clear), and optionally uploading files to multimodal models.

##### File structure
- Top‐level files:
- app.py – the Streamlit “frontend” logic, UI layout, state management, user interactions.
- OllamaClient.py – a thin client library encapsulating HTTP/streaming calls to the local Ollama server.
- requirements.txt – Python dependencies (streamlit, requests or httpx, etc.).
- .streamlit/config.toml – Streamlit configuration (port, theme, etc.).
- image/ – static assets for README and in‐app screenshots and logos.
- No separate “backend” service – the Streamlit app itself hosts the UI and orchestrates calls to the Ollama server.

##### README for additional insights
- Confirms core flows: connect to localhost:11434, choose model, set parameters, send user messages, stream or batch receive.
- Chat history lives in UI state and can be exported to JSON.
- Supports file attachments for multimodal models.

a. Main components:
1. User’s Browser / Client Interface (served by Streamlit)
2. Streamlit App (app.py)
3. OllamaClient Library (OllamaClient.py)
4. Local Ollama Server (localhost:11434)
5. Local LLM Models & Runtimes (inside Ollama Server)
6. Chat History Store (in‐memory state + JSON export)
7. File Upload Handler / Static Assets (image/)
b. Interactions & Data Flow:
- User inputs in the Browser → Streamlit App (HTTP/websocket)
- Streamlit App invokes OllamaClient methods → HTTP REST or streaming gRPC to Ollama Server
- Ollama Server processes through the selected model → streams or returns full response
- Streamlit App updates UI with responses; app state holds chat history
- On “export” action, Streamlit App serializes state → JSON file download
- File uploads from Browser → Streamlit App → forwarded to Ollama Server if model supports multimodal
c. Architectural patterns & design principles:
- Monolithic web app (no separate microservices)
- Client‐server over HTTP/HTTPS for UI
- Adapter pattern: OllamaClient abstracts protocol details
- State‐driven UI (Streamlit’s reactive paradigm)
d. Key technologies & libraries:
- Streamlit – UI & session management
- Python stdlib / third‐party HTTP client (inside OllamaClient.py)
- Ollama Server – local LLM hosting
- JSON – chat history export format

- Both real‐time (streaming) and batch response flows
- File‐upload path distinctly if multimodal models are involved
- In‐app state (chat history) and the export mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        Browser["User's Browser / Client Interface"]:::ui
    end

    %% Application Layer
    subgraph "Application Layer"
        StreamlitApp["Streamlit App (app.py)"]:::app
        Config["Streamlit Config (.streamlit/config.toml)"]:::config
        Requirements["Python Dependencies (requirements.txt)"]:::config
        README["Project Documentation (README.md)"]:::config
    end

    %% Integration Layer
    subgraph "Integration Layer"
        OllamaClient["OllamaClient Library (OllamaClient.py)"]:::app
        FileUpload["File Upload Handler & Static Assets"]:::data
        ChatHistory["Chat History Store (In-memory)"]:::data
        JSONExport["JSON Export (Chat History)"]:::data
    end

    %% LLM Hosting Layer
    subgraph "LLM Hosting Layer"
        OllamaServer["Local Ollama Server"]:::external
        ModelRuntimes["LLM Models & Runtimes"]:::external
    end

    %% Connections
    Browser -->|"HTTP/WebSocket"| StreamlitApp
    StreamlitApp -->|"invoke"| OllamaClient
    OllamaClient -->|"HTTP/Streaming API"| OllamaServer
    OllamaServer -->|"streams/batch response"| StreamlitApp
    Browser -->|"file upload"| FileUpload
    FileUpload -->|"forward"| OllamaClient
    StreamlitApp -->|"update UI"| ChatHistory
    StreamlitApp -->|"export chat"| JSONExport
    JSONExport -->|"download"| Browser

    %% Click Events
    click Browser "https://github.com/d-evil0per/ollama-chat-console/blob/main/app.py"
    click StreamlitApp "https://github.com/d-evil0per/ollama-chat-console/blob/main/app.py"
    click Config "https://github.com/d-evil0per/ollama-chat-console/blob/main/.streamlit/config.toml"
    click Requirements "https://github.com/d-evil0per/ollama-chat-console/blob/main/requirements.txt"
    click README "https://github.com/d-evil0per/ollama-chat-console/blob/main/README.md"
    click OllamaClient "https://github.com/d-evil0per/ollama-chat-console/blob/main/OllamaClient.py"
    click FileUpload "https://github.com/d-evil0per/ollama-chat-console/tree/main/image/"
    click ChatHistory "https://github.com/d-evil0per/ollama-chat-console/blob/main/app.py"
    click JSONExport "https://github.com/d-evil0per/ollama-chat-console/blob/main/app.py"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef app fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef data fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
