# ankykong/civicbot architecture

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

- Interactive diagram: https://gitdiagram.com/ankykong/civicbot
- Repository: https://github.com/ankykong/civicbot

## Overview

##### Main Components
- Bot Engine Core: This includes the files “langflow_agent.py” and “langflow_llm.py”. They likely form the core of the bot’s conversational intelligence by managing integration with a language model (LangFlow) and handling prompt logic (supported by “Basic Prompting.json”).
- Server and Client: The presence of “server.py” and “client.py” indicates a client-server architecture. The server likely handles incoming requests (from a web interface, command line, or API) and routes them to the bot engine, while the client might be used for interacting with the service or serving as a testing utility.
- Workflow/Orchestration: “runner.py” suggests a workflow manager that orchestrates processes—possibly bootstrapping the bot, handling tasks, or coordinating between the client/server and the core bot functions.
- Voice Interface: “voice_bot.py” implies an additional module that offers voice control or interaction. This can be seen as a specialized interface integrated with the core bot functionality.
- Templates and Configurations: The “templates” directory (with “streams.xml”) likely contains configuration or layout templates used either for streaming outputs, setting up UI elements, or structuring message flows.

##### Relationships and Data Flow
- The Client (client.py) sends requests to the Server (server.py) via established API endpoints.
- On the server side, the Runner (runner.py) orchestrates the workflow by directing requests to the correct component.
- For language tasks, requests are handled by the Bot Engine modules (langflow_agent.py and langflow_llm.py). They likely process input prompts (possibly using “Basic Prompting.json” as a reference) and generate responses.
- The Voice Bot (voice_bot.py) either acts as an alternative entry point or integrates with the primary workflow to enable voice-based interactions.
- Templates (streams.xml) may provide standardized output layouts or configuration for message formatting and should be shown as a supporting component.

##### Architectural Patterns and Principles
- Separation of Concerns: The clear division between client, server, workflow, language processing, and voice modules keeps responsibilities isolated.
- Client-Server Communication: Illustrate the data flow from the user’s client through the server to core language modules.

- Notes or callouts for configuration files (Basic Prompting.json, streams.xml) that indicate where external configurations are applied.
- Integration boundaries where the bot engine interfaces with external libraries or frameworks (as mentioned in requirements.txt for dependencies).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Interaction Layer
    subgraph "Interaction Layer"
        CL["Client"]:::interface
        VB["Voice Bot"]:::interface
    end

    %% Backend Services
    subgraph "Backend Services"
        SR["Server"]:::backend
        RN["Runner/Orchestrator"]:::backend
        subgraph "Bot Engine Core"
            LA["LangFlow Agent"]:::core
            LL["LangFlow LLM"]:::core
            BP["Basic Prompting"]:::core
        end
        TM["Templates/Config"]:::config
    end

    %% Data Flow Connections
    CL -->|"sendsRequest"| SR
    SR -->|"routesTo"| RN
    RN -->|"orchestrates"| LA
    RN -->|"orchestrates"| LL
    LA -->|"uses"| BP
    RN -->|"integrates"| VB
    RN -->|"applies"| TM

    %% Click Events
    click CL "https://github.com/ankykong/civicbot/blob/main/client.py"
    click SR "https://github.com/ankykong/civicbot/blob/main/server.py"
    click RN "https://github.com/ankykong/civicbot/blob/main/runner.py"
    click VB "https://github.com/ankykong/civicbot/blob/main/voice_bot.py"
    click LA "https://github.com/ankykong/civicbot/blob/main/langflow_agent.py"
    click LL "https://github.com/ankykong/civicbot/blob/main/langflow_llm.py"
    click BP "https://github.com/ankykong/civicbot/blob/main/Basic Prompting.json"
    click TM "https://github.com/ankykong/civicbot/blob/main/templates/streams.xml"

    %% Styles
    classDef interface fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef core fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef config fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
```
