# rmfatemi/bitvoker architecture

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

- Interactive diagram: https://gitdiagram.com/rmfatemi/bitvoker
- Repository: https://github.com/rmfatemi/bitvoker

## Overview

##### Project type and purpose
- **Type**: Full-stack notification system (Python TCP/API server + React web UI).
- **Purpose**: Ingest arbitrary text messages over TCP, optionally summarize via AI, dispatch notifications to multiple channels, store history in a local database, and provide a real-time web dashboard for configuration and monitoring.

##### File structure
- **bitvoker/**: Core Python server modules:
- server.py: TCP listener
- api.py/router.py: HTTP/WS interface for the web UI
- handler.py: Orchestrates message flow
- ai.py: Optional AI summary component
- notifier.py: Channel adapters (Telegram, Discord, Slack, Gotify, etc.)
- database.py: SQLite persistence
- config.py/constants.py/logger.py/notifier.py: Supporting utilities
- **data/**: Configuration YAML and SQLite database file
- **web/**: React application (ports 8085):
- public/: static HTML/manifest
- src/: components (Dashboard, Logs, Settings, etc.)
- **Dockerfile/entrypoint.sh/Makefile**: Build and deployment
- **.github/workflows/docker-publish.yml**: CI for Docker image

##### README for additional insights
- Ports: 8084 for TCP/API, 8085 for web UI
- Features: real-time updates (implies WebSockets or Server-Sent Events), dynamic config, multi-channel dispatch, AI integration via Meta’s API
- Deployment: Docker, Compose, or standalone Python

a. **Main components**
- **TCP Ingestor**: Listens on port 8084, receives raw messages
- **Processing Pipeline**:
- **Handler**: Validates incoming text
- **AI Summarizer** (optional): Calls Meta AI API
- **Router**: Determines which notifier channels to use
- **Database**: SQLite (data/database.db) holds notification history, config, logs
- **Notifier Adapters**: Modules for Telegram, Discord, Slack, Gotify, etc.
- **API/WebSocket Server**: Exposes state, config endpoints, and real-time push to clients
- **React Web UI**: Dashboard, Logs, Settings pages served on port 8085
- **External Services**:
- Meta AI API (for summarization)
- Messaging platforms (Telegram, Discord, Slack, Gotify)
b. **Relationships and interactions**
1. Client (e.g., `nc` or script) → TCP Ingestor
2. Ingestor → Handler → (optional) AI Summarizer → Router
3. Router → Database (persist message + metadata)
4. Router → Notifier Adapters → External Messaging Services
5. Handler/API Server → WebSocket pushes update to React UI
6. React UI ↔ API Server (HTTP) for config changes
7. Config changes → Config module → dynamic reload in Pipeline
c. **Architectural patterns / design principles**
- **Modular pipeline**: clear separation of ingest → process → dispatch
- **Pluggable adapters**: each notifier is its own module
- **Dynamic configuration**: live reload without restart
- **Event-driven updates**: push notifications to web client in real time
d. **Key technologies**
- **Python 3.11+, FastAPI-like API** (api.py/router.py)
- **SQLite** for lightweight persistence
- **Meta AI** for summarization (unauthenticated HTTP calls)
- **React** (Create React App) for web dashboard
- **Docker** & **Makefile** for CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Services
    subgraph "Backend Services"
        Ingestor["TCP Ingestor\n(port 8084)"]:::backend
        Handler["Message Handler"]:::backend
        Summarizer["AI Summarizer"]:::backend
        Router["Request Router"]:::backend
        API["HTTP/WebSocket API Server\n(port 8084)"]:::backend
        ConfigMod["Configuration Module"]:::backend
        Logger["Logging Utility"]:::backend
        Database["SQLite Database"]:::db
        ConfigFile["config.yaml"]:::dbfile
        DBFile["database.db"]:::dbfile
        Constants["Constants Definitions"]:::backend
        Notifier["Notifier Adapters"]:::backend
    end

    %% React Web UI
    subgraph "React Web UI" 
        Index["public/index.html"]:::frontend
        App["src/App.js"]:::frontend
        Dashboard["Dashboard.jsx"]:::frontend
        NotificationTable["NotificationTable.jsx"]:::frontend
        LogsComp["Logs.jsx"]:::frontend
        SettingsComp["Settings.jsx"]:::frontend
        ChannelCard["ChannelCard.jsx"]:::frontend
        HeaderComp["Header.jsx"]:::frontend
    end

    %% External Services
    subgraph "External Services"
        MetaAI["Meta AI API"]:::ext
        Telegram["Telegram"]:::ext
        Discord["Discord"]:::ext
        Slack["Slack"]:::ext
        Gotify["Gotify"]:::ext
    end

    %% Build & Deployment
    subgraph "Build & Deployment"
        Dockerfile["Dockerfile"]:::build
        Entry["entrypoint.sh"]:::build
        CI["docker-publish.yml"]:::build
        MakefileNode["Makefile"]:::build
        PyProject["pyproject.toml"]:::build
        GitIgnore[".gitignore"]:::build
    end

    %% Connections
    Client["Client (nc, script)"]:::ext -->|TCP| Ingestor
    Ingestor --> Handler
    Handler -->|optional| Summarizer
    Summarizer -->|HTTP| MetaAI
    MetaAI --> Summarizer
    Handler --> Router
    ConfigMod --> Handler
    Router --> Database
    Router --> Notifier
    Notifier --> Telegram
    Notifier --> Discord
    Notifier --> Slack
    Notifier --> Gotify
    Handler --> Logger
    API --> Logger
    Logger --> Database
    API -->|WebSocket| App
    App -->|HTTP| API
    ConfigFile --> ConfigMod
    DBFile --> Database
    Constants --> Handler
    Constants --> Notifier

    %% Click Events
    click Ingestor "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/server.py"
    click API "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/api.py"
    click Router "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/router.py"
    click Handler "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/handler.py"
    click Summarizer "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/ai.py"
    click Notifier "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/notifier.py"
    click Database "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/database.py"
    click ConfigMod "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/config.py"
    click ConfigFile "https://github.com/rmfatemi/bitvoker/blob/master/data/config.yaml"
    click DBFile "https://github.com/rmfatemi/bitvoker/blob/master/data/database.db"
    click Constants "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/constants.py"
    click Logger "https://github.com/rmfatemi/bitvoker/blob/master/bitvoker/logger.py"
    click Index "https://github.com/rmfatemi/bitvoker/blob/master/web/public/index.html"
    click App "https://github.com/rmfatemi/bitvoker/blob/master/web/src/App.js"
    click Dashboard "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Dashboard/Dashboard.jsx"
    click NotificationTable "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Dashboard/NotificationTable.jsx"
    click LogsComp "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Logs/Logs.jsx"
    click SettingsComp "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Settings/Settings.jsx"
    click ChannelCard "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Settings/ChannelCard.jsx"
    click HeaderComp "https://github.com/rmfatemi/bitvoker/blob/master/web/src/components/Header/Header.jsx"
    click Dockerfile "https://github.com/rmfatemi/bitvoker/tree/master/Dockerfile"
    click Entry "https://github.com/rmfatemi/bitvoker/blob/master/entrypoint.sh"
    click CI "https://github.com/rmfatemi/bitvoker/blob/master/.github/workflows/docker-publish.yml"
    click MakefileNode "https://github.com/rmfatemi/bitvoker/tree/master/Makefile"
    click PyProject "https://github.com/rmfatemi/bitvoker/blob/master/pyproject.toml"
    click GitIgnore "https://github.com/rmfatemi/bitvoker/blob/master/.gitignore"

    %% Styles
    classDef backend fill:#fef,stroke:#333,stroke-width:1px
    classDef frontend fill:#efe,stroke:#333,stroke-width:1px
    classDef db fill:#ffd,stroke:#333,stroke-width:1px
    classDef dbfile fill:#ffd,stroke:#333,stroke-dasharray: 4 2
    classDef ext fill:#ddf,stroke:#333,stroke-width:1px
    classDef build fill:#fdd,stroke:#333,stroke-width:1px
```
