# harshini-raja/kafka-inspired-distributedmessagequeue architecture

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

- Interactive diagram: https://gitdiagram.com/harshini-raja/kafka-inspired-distributedmessagequeue
- Repository: https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue

## Overview

#### Purpose and Entry Points
A Kafka-inspired distributed message queue with a Java/Maven backend and React monitoring dashboard. The backend starts from `src/main/java/com/distributedQueue/MainClass.java`; the browser app starts at `DistributedMessageQueue/src/index.js` and composes its UI in `DistributedMessageQueue/src/App.js`. Deployment is container-oriented through `Docker-compose.yml`.

#### Core Queue Domain
The queue model is organized around topics, partitions, messages, and in-memory/message-queue coordination. `src/main/java/com/distributedQueue/Core/TopicManager.java` owns topic-level management, while `src/main/java/com/distributedQueue/Core/Topic.java` and `src/main/java/com/distributedQueue/Core/Partition.java` represent routing/storage boundaries. `src/main/java/com/distributedQueue/Core/Message.java` defines the message payload model and `src/main/java/com/distributedQueue/Core/MessageQueue.java` coordinates queue behavior.

#### Controller and REST Boundary
`src/main/java/com/distributedQueue/Controllers/Controller.java` is the backend control/API boundary used to expose queue operations and operational state. JSON-facing type conversion is separated in `src/main/java/com/distributedQueue/Adapters/MessageAdapter.java` and `src/main/java/com/distributedQueue/Adapters/InstantTypeAdapter.java`, insulating core models from wire serialization concerns.

#### Distributed Roles and Message Flow
Producers publish messages through `src/main/java/com/distributedQueue/Producers/Producer.java`; messages are assigned to topics/partitions managed by the core layer. Brokers in `src/main/java/com/distributedQueue/Brokers/Broker.java` host or coordinate partition work. Consumers pull/process messages through `src/main/java/com/distributedQueue/Consumers/Consumer.java`, with `src/main/java/com/distributedQueue/Consumers/ConsumerThread.java` providing concurrent consumption execution.

#### Cluster Metadata and Coordination
Partition ownership/leader-related state is represented by `src/main/java/com/distributedQueue/Metadata/PartitionMetadata.java`. Broker-to-broker coordination is modeled in `src/main/java/com/distributedQueue/Protocols/GossipProtocol.java`, making metadata propagation and broker health a distinct distributed-systems boundary rather than part of producer/consumer code.

#### Observability and Dashboard
Operational events are captured through `src/main/java/com/distributedQueue/Logging/LogMessage.java` and persisted/accessed via `src/main/java/com/distributedQueue/Logging/LogRepository.java`. The React dashboard uses `DistributedMessageQueue/src/services/Api.js` for backend access and presents cluster state in `DistributedMessageQueue/src/components/Dashboard.js`, broker status in `DistributedMessageQueue/src/components/Broker.js`, topic/leader information in `DistributedMessageQueue/src/components/Topics.js`, and producer/consumer logs in their respective components.

#### Runtime and Infrastructure
The backend runs on Java with Maven (`pom.xml`); the frontend is a separate Node/React package (`DistributedMessageQueue/package.json`) using Axios. Docker defines separate controller, broker, producer, and consumer images in `Dockerfile.controller`, `Dockerfile.broker`, `Dockerfile.producer`, and `Dockerfile.consumer`, orchestrated by `Docker-compose.yml`. This indicates the distributed roles are intended to run as independently containerized processes.

Main entry points: [`src/main/java/com/distributedQueue/Controllers/Controller.java`](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Controllers/Controller.java) (Controller API), [`Docker-compose.yml`](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/Docker-compose.yml) (Container Orchestration), [`src/main/java/com/distributedQueue/Brokers/Broker.java`](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Brokers/Broker.java) (Broker), [`src/main/java/com/distributedQueue/Producers/Producer.java`](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Producers/Producer.java) (Producer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Java Backend"]
  node_backend_entry["Backend Entry<br/>Java main<br/>[MainClass.java]"]
  node_controller["Controller API<br/>REST boundary<br/>[Controller.java]"]
  node_adapters["JSON Adapters<br/>serialization"]
  node_log_repository[("Log Repository<br/>operational logs<br/>[LogRepository.java]")]
end

subgraph group_core["Queue Core"]
  node_topic_manager["Topic Manager<br/>topic coordination<br/>[TopicManager.java]"]
  node_topic_partition["Topics &amp; Partitions<br/>routing and storage<br/>[Topic.java]"]
  node_message_queue["Message Queue<br/>queue coordinator<br/>[MessageQueue.java]"]
  node_message["Message<br/>payload model<br/>[Message.java]"]
end

subgraph group_cluster["Distributed Cluster"]
  node_producer["Producer<br/>publish role<br/>[Producer.java]"]
  node_broker{{"Broker<br/>partition host<br/>[Broker.java]"}}
  node_consumer["Consumer<br/>consume role<br/>[Consumer.java]"]
  node_consumer_thread["Consumer Thread<br/>concurrent worker"]
  node_partition_metadata[("Partition Metadata<br/>ownership and leader state")]
  node_gossip["Gossip Protocol<br/>broker coordination"]
end

subgraph group_frontend["React Dashboard"]
  node_dashboard_entry["Dashboard Entry<br/>React entry<br/>[index.js]"]
  node_dashboard["Monitoring Dashboard<br/>React UI<br/>[Dashboard.js]"]
  node_api_client["API Client<br/>Axios client<br/>[Api.js]"]
end

node_compose{{"Container Orchestration<br/>Docker Compose<br/>[Docker-compose.yml]"}}

node_backend_entry -->|"starts"| node_controller
node_controller -->|"serializes"| node_adapters
node_controller -->|"queue operations"| node_topic_manager
node_controller -->|"operational state"| node_log_repository
node_topic_manager -->|"manages"| node_topic_partition
node_topic_partition -->|"routes through"| node_message_queue
node_producer -->|"publishes"| node_message
node_producer -->|"targets topic"| node_topic_manager
node_broker -->|"hosts work"| node_message_queue
node_broker -->|"uses ownership"| node_partition_metadata
node_gossip -->|"propagates state"| node_partition_metadata
node_gossip -->|"coordinates"| node_broker
node_consumer_thread -->|"executes"| node_consumer
node_consumer -->|"pulls messages"| node_message_queue
node_dashboard_entry -->|"mounts"| node_dashboard
node_dashboard -->|"requests state"| node_api_client
node_api_client -->|"REST calls"| node_controller
node_compose -.->|"runs controller"| node_controller
node_compose -.->|"runs broker"| node_broker
node_compose -.->|"runs producer"| node_producer
node_compose -.->|"runs consumer"| node_consumer

click node_backend_entry "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/MainClass.java"
click node_controller "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Controllers/Controller.java"
click node_adapters "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Adapters/MessageAdapter.java"
click node_topic_manager "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/TopicManager.java"
click node_topic_partition "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/Topic.java"
click node_message_queue "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/MessageQueue.java"
click node_message "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/Message.java"
click node_producer "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Producers/Producer.java"
click node_broker "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Brokers/Broker.java"
click node_consumer "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Consumers/Consumer.java"
click node_consumer_thread "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Consumers/ConsumerThread.java"
click node_partition_metadata "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Metadata/PartitionMetadata.java"
click node_gossip "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Protocols/GossipProtocol.java"
click node_log_repository "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Logging/LogRepository.java"
click node_dashboard_entry "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/index.js"
click node_dashboard "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/components/Dashboard.js"
click node_api_client "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/services/Api.js"
click node_compose "https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/Docker-compose.yml"

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_backend_entry,node_controller,node_adapters,node_log_repository toneBlue
class node_topic_manager,node_topic_partition,node_message_queue,node_message toneAmber
class node_producer,node_broker,node_consumer,node_consumer_thread,node_partition_metadata,node_gossip toneMint
class node_dashboard_entry,node_dashboard,node_api_client toneRose
class node_compose toneNeutral
```

## Components

### Java Backend

- [Backend Entry](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/MainClass.java): Java main · `src/main/java/com/distributedQueue/MainClass.java`
- [Controller API](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Controllers/Controller.java): REST boundary · `src/main/java/com/distributedQueue/Controllers/Controller.java`
- [JSON Adapters](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Adapters/MessageAdapter.java): serialization · Converts messages and instants at the wire boundary. · `src/main/java/com/distributedQueue/Adapters/MessageAdapter.java`
- [Log Repository](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Logging/LogRepository.java): operational logs · `src/main/java/com/distributedQueue/Logging/LogRepository.java`

### Queue Core

- [Topic Manager](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/TopicManager.java): topic coordination · `src/main/java/com/distributedQueue/Core/TopicManager.java`
- [Topics & Partitions](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/Topic.java): routing and storage · `src/main/java/com/distributedQueue/Core/Topic.java`
- [Message Queue](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/MessageQueue.java): queue coordinator · `src/main/java/com/distributedQueue/Core/MessageQueue.java`
- [Message](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Core/Message.java): payload model · `src/main/java/com/distributedQueue/Core/Message.java`

### Distributed Cluster

- [Producer](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Producers/Producer.java): publish role · `src/main/java/com/distributedQueue/Producers/Producer.java`
- [Broker](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Brokers/Broker.java): partition host · `src/main/java/com/distributedQueue/Brokers/Broker.java`
- [Consumer](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Consumers/Consumer.java): consume role · `src/main/java/com/distributedQueue/Consumers/Consumer.java`
- [Consumer Thread](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Consumers/ConsumerThread.java): concurrent worker · `src/main/java/com/distributedQueue/Consumers/ConsumerThread.java`
- [Partition Metadata](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Metadata/PartitionMetadata.java): ownership and leader state · `src/main/java/com/distributedQueue/Metadata/PartitionMetadata.java`
- [Gossip Protocol](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/src/main/java/com/distributedQueue/Protocols/GossipProtocol.java): broker coordination · `src/main/java/com/distributedQueue/Protocols/GossipProtocol.java`

### React Dashboard

- [Dashboard Entry](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/index.js): React entry · `DistributedMessageQueue/src/index.js`
- [Monitoring Dashboard](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/components/Dashboard.js): React UI · Shows cluster, broker, topic, and role logs. · `DistributedMessageQueue/src/components/Dashboard.js`
- [API Client](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/DistributedMessageQueue/src/services/Api.js): Axios client · `DistributedMessageQueue/src/services/Api.js`

### Other components

- [Container Orchestration](https://github.com/harshini-raja/kafka-inspired-distributedmessagequeue/blob/main/Docker-compose.yml): Docker Compose · Runs controller, broker, producer, and consumer roles separately. · `Docker-compose.yml`

## Connections

- Backend Entry → Controller API: starts
- Controller API → JSON Adapters: serializes
- Controller API → Topic Manager: queue operations
- Controller API → Log Repository: operational state
- Topic Manager → Topics & Partitions: manages
- Topics & Partitions → Message Queue: routes through
- Producer → Message: publishes
- Producer → Topic Manager: targets topic
- Broker → Message Queue: hosts work
- Broker → Partition Metadata: uses ownership
- Gossip Protocol → Partition Metadata: propagates state
- Gossip Protocol → Broker: coordinates
- Consumer Thread → Consumer: executes
- Consumer → Message Queue: pulls messages
- Dashboard Entry → Monitoring Dashboard: mounts
- Monitoring Dashboard → API Client: requests state
- API Client → Controller API: REST calls
- Container Orchestration → Controller API: runs controller
- Container Orchestration → Broker: runs broker
- Container Orchestration → Producer: runs producer
- Container Orchestration → Consumer: runs consumer
