# omkarok2510/optimzation_assign_system architecture

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

- Interactive diagram: https://gitdiagram.com/omkarok2510/optimzation_assign_system
- Repository: https://github.com/omkarok2510/optimzation_assign_system

## Overview

##### Project Type and Purpose
- This is a full-stack, modular monolith web application built in Python (Flask), with AI/ML and blockchain sub-modules, plus a Telegram Bot integration. Its goal is to assign tasks/resources optimally via a web dashboard and chat interface.

##### Main Components
a. Presentation Layer
- Web UI (templates/dashboard.html, advanced_dashboard.html)
- Telegram Bot Interface (telegram_bot.py)
b. Application Layer
- Flask App (app.py) – handles HTTP routes, API endpoints, orchestrates logic
- Business Logic Sub-modules:
– AI Module (ai/predictive.py, ai/federated.py)
– Blockchain Module (blockchain/ledger.py)
c. Data Layer
- Relational Database (complaints.db – SQLite)
- Logging System (digital_twin_log.txt)
d. External Services
- Telegram API
- (Optional) Future DB backends (MySQL/PostgreSQL)

##### Interactions and Data Flows
- Users → Web Browser → HTTP(S) → Flask App →
- Queries/Updates DB
- Invokes AI Module for optimization calculations
- Calls Blockchain Module to record transaction/assignment proofs
- Logs events to digital_twin_log.txt
← Renders Dashboard HTML
- Telegram User → Telegram API → telegram_bot.py → internally forwards requests to Flask App or directly uses AI/Blockchain modules → sends replies back to Telegram API

##### Architectural Patterns & Principles
- Layered Architecture (Presentation / Application / Data)
- Modularization: Separate folders for ai/ and blockchain/ keep independent concerns
- Single-process monolith currently, but components can be extracted into microservices later
- Use clear abstraction boundaries: API layer, service layer, data access layer

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actors
    Browser["Web Browser"]:::external
    TelegramUser["Telegram User"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        WebUIDashboard["templates/dashboard.html"]:::presentation
        WebUIAdv["templates/advanced_dashboard.html"]:::presentation
        TelegramBot["telegram_bot.py (Telegram Bot)"]:::presentation
    end

    %% Backend Service
    subgraph "Backend Service"
        direction TB
        FlaskApp["app.py (Flask App)"]:::backend
        Predictive["ai/predictive.py (AI Predictive)"]:::logic
        Federated["ai/federated.py (AI Federated)"]:::logic
        Ledger["blockchain/ledger.py (Blockchain Ledger)"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        SQLiteDB["complaints.db (SQLite)"]:::data
        LogFile["digital_twin_log.txt (Log File)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        TelegramAPI["Telegram API"]:::external
        FutureDB["MySQL/PostgreSQL (Future)"]:::future
    end

    %% Flows
    Browser -->|"HTTP(S)"| FlaskApp
    FlaskApp -->|"renders"| WebUIDashboard
    FlaskApp -->|"renders"| WebUIAdv
    TelegramUser -->|"uses"| TelegramAPI
    TelegramAPI -->|"webhook"| TelegramBot
    TelegramBot -->|"forwards"| FlaskApp
    FlaskApp -->|"predict() call"| Predictive
    FlaskApp -->|"federated() call"| Federated
    FlaskApp -->|"record() call"| Ledger
    FlaskApp -->|"INSERT/SELECT"| SQLiteDB
    FlaskApp -->|"write"| LogFile
    TelegramBot -->|"predict() call"| Predictive
    TelegramBot -->|"record() call"| Ledger

    %% Legend
    subgraph "Legend"
        direction TB
        P["Presentation Layer"]:::presentation
        B["Business Logic"]:::backend
        D["Data Layer"]:::data
        E["External Services"]:::external
        F["Future Modules"]:::future
    end

    %% Click Events
    click WebUIDashboard "https://github.com/omkarok2510/optimzation_assign_system/blob/main/templates/dashboard.html"
    click WebUIAdv "https://github.com/omkarok2510/optimzation_assign_system/blob/main/templates/advanced_dashboard.html"
    click TelegramBot "https://github.com/omkarok2510/optimzation_assign_system/blob/main/telegram_bot.py"
    click FlaskApp "https://github.com/omkarok2510/optimzation_assign_system/blob/main/app.py"
    click Predictive "https://github.com/omkarok2510/optimzation_assign_system/blob/main/ai/predictive.py"
    click Federated "https://github.com/omkarok2510/optimzation_assign_system/blob/main/ai/federated.py"
    click Ledger "https://github.com/omkarok2510/optimzation_assign_system/blob/main/blockchain/ledger.py"
    click SQLiteDB "https://github.com/omkarok2510/optimzation_assign_system/blob/main/complaints.db"
    click LogFile "https://github.com/omkarok2510/optimzation_assign_system/blob/main/digital_twin_log.txt"

    %% Styles
    classDef presentation fill:#D6EAF8,stroke:#1B4F72,stroke-width:1px
    classDef backend fill:#A9DFBF,stroke:#154360,stroke-width:1px
    classDef logic fill:#ABEBC6,stroke:#1D8348,stroke-width:1px
    classDef data fill:#F9E79F,stroke:#7D6608,stroke-width:1px
    classDef external fill:#D5DBDB,stroke:#1C2833,stroke-width:1px
    classDef future fill:#FFFFFF,stroke:#AAAAAA,stroke-dasharray:5 5,stroke-width:1px
```
