# sinchanacsajjanashettar/distributed-kafka-pubsub-system architecture

> Architecture diagram of the GitHub repository sinchanacsajjanashettar/distributed-kafka-pubsub-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system
- Repository: https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system

## Overview

This repository implements a Kafka topic-and-message system with producer and consumer clients, admin and monitoring web interfaces, and MySQL-backed topic, subscription, archive, and activity state. A producer accepts generated, CSV, or manual input and publishes messages; consumers manage subscriptions and read Kafka messages. Admins approve topics, while the dashboards expose system and archive information. Source excerpts support the main database and Kafka connections; the README is empty, and broker wiring beyond the shown client code is not established.

Main entry points: [`database/db_handler.py`](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/database/db_handler.py) (Database Handler), [`admin/admin_api.py`](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/admin/admin_api.py) (Admin API), [`producer/producer.py`](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/producer/producer.py) (Producer), [`consumer/consumer1.py`](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/consumer/consumer1.py) (Consumer One)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Web Interfaces"]
  node_admin_api["Admin API<br/>[admin_api.py]"]
  node_admin_ui["Admin Dashboard<br/>[admin.html]"]
  node_frontend["Monitoring API<br/>[app.py]"]
  node_dashboard["Monitoring Dashboard<br/>[dashboard.html]"]
end

subgraph group_messaging["Kafka Messaging"]
  node_producer["Producer<br/>[producer.py]"]
  node_kafka["Kafka Broker"]
  node_topic_request["Topic Request<br/>[request_topic.py]"]
end

subgraph group_consumers["Consumers"]
  node_consumer1["Consumer One<br/>[consumer1.py]"]
  node_consumer2["Consumer Two<br/>[consumer2.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_handler["Database Handler<br/>[db_handler.py]"]
  node_schema_init["Schema Initializer<br/>[init_db.py]"]
end

node_admin_user(("Admin"))
node_producer_user(("Producer Operator"))
node_consumer_user(("Consumer User"))
node_mysql[("MySQL Database")]

node_admin_user -->|"manages topics"| node_admin_api
node_admin_api -->|"renders"| node_admin_ui
node_admin_api -->|"queries and updates"| node_db_handler
node_producer_user -->|"provides input"| node_producer
node_producer -->|"publishes messages"| node_kafka
node_producer -->|"records activity"| node_db_handler
node_consumer_user -->|"manages subscriptions"| node_consumer1
node_consumer_user -->|"manages subscriptions"| node_consumer2
node_consumer1 -->|"consumes messages"| node_kafka
node_consumer2 -->|"consumes messages"| node_kafka
node_consumer1 -->|"reads and updates"| node_db_handler
node_consumer2 -->|"reads and updates"| node_db_handler
node_frontend -->|"renders"| node_dashboard
node_frontend -->|"queries status and archives"| node_db_handler
node_topic_request -->|"requests topics"| node_db_handler
node_db_handler -->|"connects and queries"| node_mysql
node_schema_init -->|"creates schema"| node_mysql

click node_admin_api "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/admin/admin_api.py"
click node_admin_ui "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/admin/templates/admin.html"
click node_frontend "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/frontend/app.py"
click node_dashboard "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/frontend/templates/dashboard.html"
click node_producer "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/producer/producer.py"
click node_kafka "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/tree/main/broker"
click node_consumer1 "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/consumer/consumer1.py"
click node_consumer2 "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/consumer/consumer2.py"
click node_topic_request "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/scripts/request_topic.py"
click node_db_handler "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/database/db_handler.py"
click node_schema_init "https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/database/init_db.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_admin_api,node_admin_ui,node_frontend,node_dashboard,node_consumer_user toneBlue
class node_producer,node_kafka,node_topic_request,node_mysql toneAmber
class node_consumer1,node_consumer2 toneMint
class node_db_handler,node_schema_init toneRose
class node_admin_user,node_producer_user toneIndigo
```

## Components

### Web Interfaces

- [Admin API](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/admin/admin_api.py): `admin/admin_api.py`
- [Admin Dashboard](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/admin/templates/admin.html): `admin/templates/admin.html`
- [Monitoring API](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/frontend/app.py): `frontend/app.py`
- [Monitoring Dashboard](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/frontend/templates/dashboard.html): `frontend/templates/dashboard.html`

### Kafka Messaging

- [Producer](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/producer/producer.py): `producer/producer.py`
- [Kafka Broker](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/tree/main/broker): `broker`
- [Topic Request](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/scripts/request_topic.py): `scripts/request_topic.py`

### Consumers

- [Consumer One](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/consumer/consumer1.py): `consumer/consumer1.py`
- [Consumer Two](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/consumer/consumer2.py): `consumer/consumer2.py`

### Persistence

- [Database Handler](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/database/db_handler.py): `database/db_handler.py`
- [Schema Initializer](https://github.com/sinchanacsajjanashettar/distributed-kafka-pubsub-system/blob/main/database/init_db.py): `database/init_db.py`

### Other components

- **Admin**
- **Producer Operator**
- **Consumer User**
- **MySQL Database**

## Connections

- Admin → Admin API: manages topics (evidence: `admin/admin_api.py`)
- Admin API → Admin Dashboard: renders (evidence: `admin/admin_api.py`)
- Admin API → Database Handler: queries and updates (evidence: `admin/admin_api.py`)
- Producer Operator → Producer: provides input (evidence: `producer/producer.py`)
- Producer → Kafka Broker: publishes messages (evidence: `producer/producer.py`)
- Producer → Database Handler: records activity (evidence: `producer/producer.py`)
- Consumer User → Consumer One: manages subscriptions (evidence: `consumer/consumer1.py`)
- Consumer User → Consumer Two: manages subscriptions (evidence: `consumer/consumer2.py`)
- Consumer One → Kafka Broker: consumes messages (evidence: `consumer/consumer1.py`)
- Consumer Two → Kafka Broker: consumes messages (evidence: `consumer/consumer2.py`)
- Consumer One → Database Handler: reads and updates (evidence: `consumer/consumer1.py`)
- Consumer Two → Database Handler: reads and updates (evidence: `consumer/consumer2.py`)
- Monitoring API → Monitoring Dashboard: renders (evidence: `frontend/app.py`)
- Monitoring API → Database Handler: queries status and archives (evidence: `frontend/app.py`)
- Topic Request → Database Handler: requests topics (evidence: `scripts/request_topic.py`)
- Database Handler → MySQL Database: connects and queries (evidence: `database/db_handler.py`)
- Schema Initializer → MySQL Database: creates schema (evidence: `database/init_db.py`)
