# ifnesi/python-kafka-microservices architecture

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

- Interactive diagram: https://gitdiagram.com/ifnesi/python-kafka-microservices
- Repository: https://github.com/ifnesi/python-kafka-microservices

## Overview

##### Main Components

a) Frontend Layer:
- Flask Web Application (webapp.py)
- Static assets (CSS/JS/Images)
- HTML Templates
- AJAX-based real-time status updates

b) Microservices Layer:
- Pizza Assembly Service (msvc_assemble.py)
- Pizza Baking Service (msvc_bake.py)
- Delivery Service (msvc_delivery.py)
- Status Processing Service (msvc_status.py)

c) Data Layer:
- SQLite3 State Store (for materialized views)
- Apache Kafka Topics
- ksqlDB Streams and Tables

##### Data Storage Layer (Bottom)

Use these specific visual elements:

- Rectangle with blue gradient: Web Application
- Hexagons with green gradient: Microservices
- Rounded rectangles with purple gradient: ksqlDB components

##### Detailed Component Relationships

**Web Application**
**↓ (produces) → pizza-ordered topic**
**↑ (consumes via AJAX) ← Status Updates**

**pizza-ordered topic → [Assembly Service, Delivery Service (early warning)]**
**Assembly Service → pizza-assembled topic**
**pizza-assembled topic → Baking Service**
**Baking Service → pizza-baked topic**
**pizza-baked topic → Delivery Service**
**Delivery Service → pizza-status topic**
**Status Service ← pizza-status topic**
**Status Service → SQLite3 State Store**

##### Additional Elements

Supporting components:
- Configuration management (config_kafka and config_sys)
- Error handling flows
- Graceful shutdown paths
- Consumer group relationships
- Topic partitioning strategy (murmur2)

##### Notes Section

Important implementation details:
- Consumer group rebalancing
- Early warning system
- SLA monitoring capabilities
- Stateful service considerations
- Schema evolution capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        WA["Flask Web Application"]
        AJAX["AJAX Components"]
        TEMP["Frontend Templates"]
        STATIC["Static Assets"]
        CSS["CSS Styling"]
    end

    subgraph "Microservices Layer"
        AS["Pizza Assembly Service"]
        BS["Pizza Baking Service"]
        DS["Delivery Service"]
        SS["Status Processing Service"]
    end

    subgraph "Data Layer"
        KT1["pizza-ordered Topic"]
        KT2["pizza-assembled Topic"]
        KT3["pizza-baked Topic"]
        KT4["pizza-status Topic"]
        KSQL["ksqlDB Streams"]
        DB["SQLite3 State Store"]
    end

    subgraph "Configuration"
        KC["Kafka Config"]
        SC["System Config"]
    end

    %% Relationships
    WA --> KT1
    KT1 --> AS
    KT1 -.-> DS
    AS --> KT2
    KT2 --> BS
    BS --> KT3
    KT3 --> DS
    DS --> KT4
    KT4 --> SS
    SS --> DB
    AJAX -.-> WA
    DB -.-> WA

    %% Click Events
    click WA "https://github.com/ifnesi/python-kafka-microservices/blob/main/webapp.py"
    click AS "https://github.com/ifnesi/python-kafka-microservices/blob/main/msvc_assemble.py"
    click BS "https://github.com/ifnesi/python-kafka-microservices/blob/main/msvc_bake.py"
    click DS "https://github.com/ifnesi/python-kafka-microservices/blob/main/msvc_delivery.py"
    click SS "https://github.com/ifnesi/python-kafka-microservices/blob/main/msvc_status.py"
    click DB "https://github.com/ifnesi/python-kafka-microservices/blob/main/utils/db/sqlite.py"
    click KC "https://github.com/ifnesi/python-kafka-microservices/tree/main/config_kafka"
    click SC "https://github.com/ifnesi/python-kafka-microservices/tree/main/config_sys"
    click AJAX "https://github.com/ifnesi/python-kafka-microservices/blob/main/static/js/ajax_order.js"
    click TEMP "https://github.com/ifnesi/python-kafka-microservices/tree/main/templates"
    click STATIC "https://github.com/ifnesi/python-kafka-microservices/tree/main/static"
    click KSQL "https://github.com/ifnesi/python-kafka-microservices/tree/main/utils/ksqldb"
    click CSS "https://github.com/ifnesi/python-kafka-microservices/blob/main/static/css/main.css"

    %% Styling
    classDef frontend fill:#e1d5e7,stroke:#9673a6
    classDef service fill:#d5e8d4,stroke:#82b366
    classDef data fill:#fff2cc,stroke:#d6b656
    classDef config fill:#dae8fc,stroke:#6c8ebf

    class WA,AJAX,TEMP,STATIC,CSS frontend
    class AS,BS,DS,SS service
    class KT1,KT2,KT3,KT4,KSQL,DB data
    class KC,SC config
```
