# meghanab1909/32_project3_bd architecture

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

- Interactive diagram: https://gitdiagram.com/meghanab1909/32_project3_bd
- Repository: https://github.com/meghanab1909/32_project3_bd

## Overview

Users upload an image through the web UI; the master records a job, tiles the image, and dispatches tiles through Kafka. Workers convert tiles to grayscale and return results; the master stores completion data, reassembles the image, and exposes status and download endpoints. Heartbeats feed worker monitoring in both the master and dashboard. The source excerpts show these runtime paths; template internals and the separately documented dashboard integration are not shown.

Main entry points: [`master_node.py`](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py) (Master API), [`ui_app.py`](https://github.com/meghanab1909/32_project3_bd/blob/main/ui_app.py) (Upload and status UI), [`worker_node.py`](https://github.com/meghanab1909/32_project3_bd/blob/main/worker_node.py) (Tile worker), [`dashboard.py`](https://github.com/meghanab1909/32_project3_bd/blob/main/dashboard.py) (Heartbeat dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_ui["Upload and status UI<br/>[ui_app.py]"]
  node_templates["UI views"]
end

subgraph group_master["Master processing"]
  node_master_api["Master API<br/>[master_node.py]"]
  node_tiling["Image tiling<br/>[master_node.py]"]
  node_reassembly["Result reassembly<br/>[master_node.py]"]
  node_job_store[("Job and tile state<br/>[master_node.py]")]
  node_db_writer["Queued DB writer<br/>[master_node.py]"]
end

subgraph group_workers["Worker pool"]
  node_worker["Tile worker<br/>[worker_node.py]"]
end

subgraph group_monitoring["Worker monitoring"]
  node_dashboard["Heartbeat dashboard<br/>[dashboard.py]"]
end

node_user(("User"))
node_kafka["Kafka broker"]
node_dashboard_service["Dashboard service"]

node_user -->|"uploads image"| node_ui
node_ui -->|"forwards upload"| node_master_api
node_ui -->|"requests status"| node_master_api
node_ui -->|"links download"| node_master_api
node_ui -->|"renders views"| node_templates
node_ui -->|"provides dashboard URL"| node_dashboard_service
node_master_api -->|"divides image"| node_tiling
node_master_api -->|"publishes tile tasks"| node_kafka
node_master_api -->|"records job and tiles"| node_job_store
node_worker -->|"consumes tasks"| node_kafka
node_worker -->|"processes tiles"| node_worker
node_worker -->|"publishes results"| node_kafka
node_worker -->|"publishes heartbeats"| node_kafka
node_master_api -->|"consumes results"| node_kafka
node_master_api -->|"queues result updates"| node_job_store
node_db_writer -->|"writes queued updates"| node_job_store
node_master_api -->|"assembles completed tiles"| node_reassembly
node_master_api -->|"reads status"| node_job_store
node_master_api -->|"reads worker records"| node_job_store
node_master_api -->|"consumes heartbeats"| node_kafka
node_dashboard -->|"consumes heartbeats"| node_kafka
node_dashboard_service -.->|"serves worker view"| node_dashboard

click node_ui "https://github.com/meghanab1909/32_project3_bd/blob/main/ui_app.py"
click node_templates "https://github.com/meghanab1909/32_project3_bd/tree/main/templates"
click node_master_api "https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py"
click node_tiling "https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py"
click node_reassembly "https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py"
click node_job_store "https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py"
click node_db_writer "https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py"
click node_worker "https://github.com/meghanab1909/32_project3_bd/blob/main/worker_node.py"
click node_dashboard "https://github.com/meghanab1909/32_project3_bd/blob/main/dashboard.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_ui,node_templates,node_user toneBlue
class node_master_api,node_tiling,node_reassembly,node_job_store,node_db_writer toneAmber
class node_worker toneMint
class node_dashboard toneRose
class node_kafka,node_dashboard_service toneIndigo
```

## Components

### Web interface

- [Upload and status UI](https://github.com/meghanab1909/32_project3_bd/blob/main/ui_app.py): `ui_app.py`
- [UI views](https://github.com/meghanab1909/32_project3_bd/tree/main/templates): `templates`

### Master processing

- [Master API](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py): `master_node.py`
- [Image tiling](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py): `master_node.py`
- [Result reassembly](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py): `master_node.py`
- [Job and tile state](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py): `master_node.py`
- [Queued DB writer](https://github.com/meghanab1909/32_project3_bd/blob/main/master_node.py): `master_node.py`

### Worker pool

- [Tile worker](https://github.com/meghanab1909/32_project3_bd/blob/main/worker_node.py): `worker_node.py`

### Worker monitoring

- [Heartbeat dashboard](https://github.com/meghanab1909/32_project3_bd/blob/main/dashboard.py): `dashboard.py`

### Other components

- **User**
- **Kafka broker**
- **Dashboard service**

## Connections

- User → Upload and status UI: uploads image (evidence: `README.md`)
- Upload and status UI → Master API: forwards upload (evidence: `ui_app.py`)
- Upload and status UI → Master API: requests status (evidence: `ui_app.py`)
- Upload and status UI → Master API: links download (evidence: `ui_app.py`)
- Upload and status UI → UI views: renders views (evidence: `ui_app.py`)
- Upload and status UI → Dashboard service: provides dashboard URL (evidence: `ui_app.py`)
- Master API → Image tiling: divides image (evidence: `master_node.py`)
- Master API → Kafka broker: publishes tile tasks (evidence: `master_node.py`)
- Master API → Job and tile state: records job and tiles (evidence: `master_node.py`)
- Tile worker → Kafka broker: consumes tasks (evidence: `worker_node.py`)
- Tile worker → Tile worker: processes tiles (evidence: `worker_node.py`)
- Tile worker → Kafka broker: publishes results (evidence: `worker_node.py`)
- Tile worker → Kafka broker: publishes heartbeats (evidence: `worker_node.py`)
- Master API → Kafka broker: consumes results (evidence: `master_node.py`)
- Master API → Job and tile state: queues result updates (evidence: `master_node.py`)
- Queued DB writer → Job and tile state: writes queued updates (evidence: `master_node.py`)
- Master API → Result reassembly: assembles completed tiles (evidence: `master_node.py`)
- Master API → Job and tile state: reads status (evidence: `master_node.py`)
- Master API → Job and tile state: reads worker records (evidence: `master_node.py`)
- Master API → Kafka broker: consumes heartbeats (evidence: `master_node.py`)
- Heartbeat dashboard → Kafka broker: consumes heartbeats (evidence: `dashboard.py`)
- Dashboard service → Heartbeat dashboard: serves worker view
