# kamilmazurek/event-driven-architecture-template architecture

> Architecture diagram of the GitHub repository kamilmazurek/event-driven-architecture-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kamilmazurek/event-driven-architecture-template
- Repository: https://github.com/kamilmazurek/event-driven-architecture-template

## Overview

This is a Java/Spring event-driven microservice template. Its example workflow accepts an item-creation request, creates an item and event, publishes the event to Kafka, consumes it into an in-memory item store, and exposes stored items through a read endpoint. Shared model classes define the item and event contracts. The README also documents Kafka’s replay/traceability role and Actuator health checks; source excerpts do not establish replay configuration or health-check wiring, so those links are omitted.

Main entry points: [`producer/src/main/java/template/producer/service/ItemService.java`](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/service/ItemService.java) (Item service), [`producer/src/main/java/template/producer/controller/ItemCreateController.java`](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/controller/ItemCreateController.java) (Create endpoint), [`producer/src/main/java/template/producer/publisher/ItemEventPublisher.java`](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/publisher/ItemEventPublisher.java) (Event publisher), [`consumer/src/main/java/template/consumer/listener/ItemEventListener.java`](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/listener/ItemEventListener.java) (Event listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_producer["Producer service"]
  node_create_api["Create endpoint"]
  node_item_service["Item service<br/>[ItemService.java]"]
  node_publisher["Event publisher"]
end

subgraph group_messaging["Event backbone"]
  node_kafka["Kafka broker"]
  node_topics["Topic constants<br/>[Topics.java]"]
end

subgraph group_consumer["Consumer service"]
  node_listener["Event listener"]
  node_handler["Event handler"]
  node_item_store[("Item store<br/>[ItemStore.java]")]
  node_read_api["Read endpoint"]
end

subgraph group_shared["Shared contracts"]
  node_item["Item domain<br/>[Item.java]"]
  node_event["Created event"]
  node_item_dto["Item DTO<br/>[ItemDTO.java]"]
  node_health["Kafka health indicator"]
end

node_client(("HTTP client"))

node_client -->|"submits item"| node_create_api
node_create_api -->|"creates item"| node_item_service
node_item_service -->|"creates"| node_item
node_item_service -->|"builds event"| node_event
node_item_service -->|"publishes"| node_publisher
node_publisher -->|"selects topic"| node_topics
node_publisher -->|"sends event"| node_kafka
node_kafka -->|"delivers event"| node_listener
node_listener -->|"subscribes to"| node_topics
node_listener -->|"dispatches event"| node_handler
node_handler -->|"adds item"| node_item_store
node_handler -->|"reads payload"| node_event
node_read_api -->|"reads items"| node_item_store
node_read_api -->|"maps response"| node_item_dto
node_create_api -->|"maps response"| node_item_dto
node_client -->|"requests items"| node_read_api

click node_create_api "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/controller/ItemCreateController.java"
click node_item_service "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/service/ItemService.java"
click node_publisher "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/publisher/ItemEventPublisher.java"
click node_topics "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/topic/Topics.java"
click node_listener "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/listener/ItemEventListener.java"
click node_handler "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/handler/ItemCreatedEventHandler.java"
click node_item_store "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/store/ItemStore.java"
click node_read_api "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/controller/ItemReadController.java"
click node_item "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/domain/Item.java"
click node_event "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/event/ItemCreatedEvent.java"
click node_item_dto "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/dto/ItemDTO.java"
click node_health "https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/health/CustomKafkaHealthIndicator.java"

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_create_api,node_item_service,node_publisher,node_client toneBlue
class node_kafka,node_topics toneAmber
class node_listener,node_handler,node_item_store,node_read_api toneMint
class node_item,node_event,node_item_dto,node_health toneRose
```

## Components

### Producer service

- [Create endpoint](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/controller/ItemCreateController.java): `producer/src/main/java/template/producer/controller/ItemCreateController.java`
- [Item service](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/service/ItemService.java): `producer/src/main/java/template/producer/service/ItemService.java`
- [Event publisher](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/producer/src/main/java/template/producer/publisher/ItemEventPublisher.java): `producer/src/main/java/template/producer/publisher/ItemEventPublisher.java`

### Event backbone

- **Kafka broker**
- [Topic constants](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/topic/Topics.java): `commons/src/main/java/template/commons/model/topic/Topics.java`

### Consumer service

- [Event listener](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/listener/ItemEventListener.java): `consumer/src/main/java/template/consumer/listener/ItemEventListener.java`
- [Event handler](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/handler/ItemCreatedEventHandler.java): `consumer/src/main/java/template/consumer/handler/ItemCreatedEventHandler.java`
- [Item store](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/store/ItemStore.java): `consumer/src/main/java/template/consumer/store/ItemStore.java`
- [Read endpoint](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/consumer/src/main/java/template/consumer/controller/ItemReadController.java): `consumer/src/main/java/template/consumer/controller/ItemReadController.java`

### Shared contracts

- [Item domain](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/domain/Item.java): `commons/src/main/java/template/commons/model/domain/Item.java`
- [Created event](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/event/ItemCreatedEvent.java): `commons/src/main/java/template/commons/model/event/ItemCreatedEvent.java`
- [Item DTO](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/model/dto/ItemDTO.java): `commons/src/main/java/template/commons/model/dto/ItemDTO.java`
- [Kafka health indicator](https://github.com/kamilmazurek/event-driven-architecture-template/blob/main/commons/src/main/java/template/commons/health/CustomKafkaHealthIndicator.java): `commons/src/main/java/template/commons/health/CustomKafkaHealthIndicator.java`

### Other components

- **HTTP client**

## Connections

- HTTP client → Create endpoint: submits item
- Create endpoint → Item service: creates item
- Item service → Item domain: creates
- Item service → Created event: builds event
- Item service → Event publisher: publishes
- Event publisher → Topic constants: selects topic
- Event publisher → Kafka broker: sends event
- Kafka broker → Event listener: delivers event
- Event listener → Topic constants: subscribes to
- Event listener → Event handler: dispatches event
- Event handler → Item store: adds item
- Event handler → Created event: reads payload
- Read endpoint → Item store: reads items
- Read endpoint → Item DTO: maps response
- Create endpoint → Item DTO: maps response
- HTTP client → Read endpoint: requests items
