# projected1/kafka-spring-boot-demo architecture

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

- Interactive diagram: https://gitdiagram.com/projected1/kafka-spring-boot-demo
- Repository: https://github.com/projected1/kafka-spring-boot-demo

## Overview

##### Main Components

a. Infrastructure Layer:
- Zookeeper Server (for Kafka cluster management)
- Multiple Kafka Brokers (show at least kafka-server1 and kafka-server2)
- Kafka Topics (show the 'example' topic with its partitions)

b. Application Components:
- Spring Boot Application
- Kafka Producer Configuration
- Kafka Consumer Configuration
- Topic Configuration
- Consumer Service

##### Specific Elements

a. Infrastructure Components:
- Docker network (kafka-net) boundary

b. Application Components:
- KafkaProducerConfiguration
- KafkaConsumerConfiguration
- KafkaTopicConfiguration
- KafkaConsumerService

c. Message Flow:
Spring Boot → Kafka Brokers
Kafka Brokers → Consumer Group

##### Important Details to Highlight

- Consumer group concept as illustrated in the README's image
- Partition distribution across brokers
- Port mappings (2181 for Zookeeper, 9092/9093 for Kafka)
- Docker network boundary

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Docker["Docker Environment (kafka-net)"]
        subgraph SpringBoot["Spring Boot Application"]
            direction TB
            App["KafkaDemoApplication"]:::spring
            click App "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/java/com/example/kafkademo/KafkaDemoApplication.java"
            
            subgraph Config["Configuration"]
                direction TB
                ProdConfig["Producer Config"]:::spring
                ConsConfig["Consumer Config"]:::spring
                TopicConfig["Topic Config"]:::spring
                AppConfig["Application Properties"]:::spring
                
                click ProdConfig "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/java/com/example/kafkademo/config/KafkaProducerConfiguration.java"
                click ConsConfig "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/java/com/example/kafkademo/config/KafkaConsumerConfiguration.java"
                click TopicConfig "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/java/com/example/kafkademo/config/KafkaTopicConfiguration.java"
                click AppConfig "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/resources/application.properties"
            end
            
            ConsService["Consumer Service"]:::spring
            click ConsService "https://github.com/projected1/kafka-spring-boot-demo/blob/master/src/main/java/com/example/kafkademo/service/KafkaConsumerService.java"
        end
        
        subgraph Kafka["Kafka Cluster"]
            Broker1["Kafka Broker 1<br/>Port: 9092"]:::kafka
            Broker2["Kafka Broker 2<br/>Port: 9093"]:::kafka
            
            subgraph Topics["Topics"]
                Topic1["example-topic<br/>Partitions: 3"]:::topic
            end
        end
        
        ZK["Zookeeper<br/>Port: 2181"]:::zookeeper
    end
    
    %% Connections
    App --> ProdConfig
    App --> ConsConfig
    App --> TopicConfig
    App --> ConsService
    
    ProdConfig -.-> Broker1
    ProdConfig -.-> Broker2
    ConsService -.-> Broker1
    ConsService -.-> Broker2
    
    Broker1 --- Topic1
    Broker2 --- Topic1
    
    Broker1 -.- ZK
    Broker2 -.- ZK
    
    %% Styles
    classDef spring fill:#90EE90,stroke:#000
    classDef kafka fill:#ADD8E6,stroke:#000
    classDef zookeeper fill:#FFA500,stroke:#000
    classDef topic fill:#FFE4B5,stroke:#000
    
    %% Legend
    subgraph Legend
        L1["Spring Components"]:::spring
        L2["Kafka Components"]:::kafka
        L3["Zookeeper"]:::zookeeper
        L4["Topics"]:::topic
    end
```
