# lichshell/mc-shopping-cart-pub-event-service-v1 architecture

> Architecture diagram of the GitHub repository lichshell/mc-shopping-cart-pub-event-service-v1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lichshell/mc-shopping-cart-pub-event-service-v1
- Repository: https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1

## Overview

This Spring Boot service accepts shopping-cart events over HTTP and publishes them to Kafka using real-time, batch, or micro-batch modes, with JSON Schema or plain-string serialization. Requests become validated event models, then the selected producer resolves a mode/serialization-specific topic and sends through a configured Kafka sender. The README also documents topic-creation controls and Schema Registry. Some producer and configuration implementations were not excerpted; edges relying on their indexed references are limited to those references.

Main entry points: [`src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java) (Event controller), [`src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java`](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java) (Cart event), [`src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java) (Micro-batch producer), [`src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java`](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java) (Topic resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_controller["Event controller"]
  node_requests["Request DTOs"]
  node_factory["Event factory"]
end

subgraph group_events["Event Model"]
  node_event["Cart event<br/>[CartEvent.java]"]
  node_eventtype["Event types<br/>[CartEventType.java]"]
  node_item["Cart item<br/>[CartItem.java]"]
  node_schema["Event schema"]
end

subgraph group_publishing["Kafka Publishing"]
  node_realtime["Real-time producer"]
  node_batch["Batch producer"]
  node_microbatch["Micro-batch producer"]
  node_queue["Micro-batch buffer"]
  node_topicresolver["Topic resolver<br/>[TopicResolver.java]"]
  node_senders["Sender registry"]
  node_sender["Kafka sender"]
end

subgraph group_configuration["Producer Configuration"]
  node_app["Application startup"]
  node_producerconfig["Kafka producer config"]
  node_producerprops["Producer properties"]
  node_topicprops["Topic properties"]
  node_topicsconfig["Topic creation<br/>[TopicsConfig.java]"]
end

node_caller(("API caller"))
node_kafka[("Kafka cluster")]
node_registry[("Schema Registry")]

node_caller -->|"submits HTTP"| node_controller
node_controller -->|"accepts input"| node_requests
node_controller -->|"builds events"| node_factory
node_factory -->|"creates"| node_event
node_factory -->|"creates items"| node_item
node_requests -->|"uses type"| node_eventtype
node_event -->|"contains type"| node_eventtype
node_event -->|"contains items"| node_item
node_event -->|"matches schema"| node_schema
node_controller -->|"dispatches"| node_realtime
node_controller -->|"dispatches"| node_batch
node_controller -->|"dispatches"| node_microbatch
node_microbatch -->|"buffers events"| node_queue
node_microbatch -->|"resolves topic"| node_topicresolver
node_microbatch -->|"selects sender"| node_senders
node_batch -->|"resolves topic"| node_topicresolver
node_batch -->|"selects sender"| node_senders
node_realtime -->|"resolves topic"| node_topicresolver
node_realtime -->|"selects sender"| node_senders
node_senders -->|"returns sender"| node_sender
node_sender -->|"publishes records"| node_kafka
node_producerconfig -->|"configures"| node_sender
node_producerconfig -->|"reads settings"| node_producerprops
node_topicresolver -->|"reads names"| node_topicprops
node_topicsconfig -->|"configures topics"| node_topicprops
node_app -.->|"starts service"| node_producerconfig
node_schema -.->|"validates values"| node_registry
node_kafka -.->|"uses schemas"| node_registry

click node_controller "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java"
click node_requests "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/CartEventRequest.java"
click node_factory "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventFactory.java"
click node_event "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java"
click node_eventtype "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEventType.java"
click node_item "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartItem.java"
click node_schema "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/resources/schemas/cart-event.schema.json"
click node_realtime "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/RealTimeCartProducer.java"
click node_batch "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/BatchCartProducer.java"
click node_microbatch "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java"
click node_queue "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java"
click node_topicresolver "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java"
click node_senders "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/CartEventSenders.java"
click node_sender "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/KafkaCartEventSender.java"
click node_app "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/ShoppingCartEventProducerApplication.java"
click node_producerconfig "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/KafkaProducerConfig.java"
click node_producerprops "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/ProducerProperties.java"
click node_topicprops "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/AppTopicsProperties.java"
click node_topicsconfig "https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/TopicsConfig.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_controller,node_requests,node_factory toneBlue
class node_event,node_eventtype,node_item,node_schema,node_kafka,node_registry toneAmber
class node_realtime,node_batch,node_microbatch,node_queue,node_topicresolver,node_senders,node_sender,node_caller toneMint
class node_app,node_producerconfig,node_producerprops,node_topicprops,node_topicsconfig toneRose
```

## Components

### HTTP API

- [Event controller](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`
- [Request DTOs](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/CartEventRequest.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/web/CartEventRequest.java`
- [Event factory](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventFactory.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventFactory.java`

### Event Model

- [Cart event](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java`
- [Event types](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEventType.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEventType.java`
- [Cart item](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartItem.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartItem.java`
- [Event schema](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/resources/schemas/cart-event.schema.json): `src/main/resources/schemas/cart-event.schema.json`

### Kafka Publishing

- [Real-time producer](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/RealTimeCartProducer.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/RealTimeCartProducer.java`
- [Batch producer](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/BatchCartProducer.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/BatchCartProducer.java`
- [Micro-batch producer](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`
- [Micro-batch buffer](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`
- [Topic resolver](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java`
- [Sender registry](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/CartEventSenders.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/CartEventSenders.java`
- [Kafka sender](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/producer/KafkaCartEventSender.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/KafkaCartEventSender.java`

### Producer Configuration

- [Application startup](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/ShoppingCartEventProducerApplication.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/ShoppingCartEventProducerApplication.java`
- [Kafka producer config](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/KafkaProducerConfig.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/config/KafkaProducerConfig.java`
- [Producer properties](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/ProducerProperties.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/config/ProducerProperties.java`
- [Topic properties](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/AppTopicsProperties.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/config/AppTopicsProperties.java`
- [Topic creation](https://github.com/lichshell/mc-shopping-cart-pub-event-service-v1/blob/master/src/main/java/org/lich/shopping/cart/pub/event/v1/config/TopicsConfig.java): `src/main/java/org/lich/shopping/cart/pub/event/v1/config/TopicsConfig.java`

### Other components

- **API caller**
- **Kafka cluster**
- **Schema Registry**

## Connections

- API caller → Event controller: submits HTTP (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Event controller → Request DTOs: accepts input (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Event controller → Event factory: builds events (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Event factory → Cart event: creates (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventFactory.java`)
- Event factory → Cart item: creates items (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventFactory.java`)
- Request DTOs → Event types: uses type (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/CartEventRequest.java`)
- Cart event → Event types: contains type (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java`)
- Cart event → Cart item: contains items (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java`)
- Cart event → Event schema: matches schema (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/model/CartEvent.java`)
- Event controller → Real-time producer: dispatches (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Event controller → Batch producer: dispatches (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Event controller → Micro-batch producer: dispatches (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/web/ShoppingCartEventController.java`)
- Micro-batch producer → Micro-batch buffer: buffers events (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`)
- Micro-batch producer → Topic resolver: resolves topic (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`)
- Micro-batch producer → Sender registry: selects sender (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/MicroBatchCartProducer.java`)
- Batch producer → Topic resolver: resolves topic (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/BatchCartProducer.java`)
- Batch producer → Sender registry: selects sender (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/BatchCartProducer.java`)
- Real-time producer → Topic resolver: resolves topic (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/RealTimeCartProducer.java`)
- Real-time producer → Sender registry: selects sender (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/RealTimeCartProducer.java`)
- Sender registry → Kafka sender: returns sender (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/CartEventSenders.java`)
- Kafka sender → Kafka cluster: publishes records (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/KafkaCartEventSender.java`)
- Kafka producer config → Kafka sender: configures (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/config/KafkaProducerConfig.java`)
- Kafka producer config → Producer properties: reads settings (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/config/KafkaProducerConfig.java`)
- Topic resolver → Topic properties: reads names (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/producer/TopicResolver.java`)
- Topic creation → Topic properties: configures topics (evidence: `src/main/java/org/lich/shopping/cart/pub/event/v1/config/TopicsConfig.java`)
- Application startup → Kafka producer config: starts service
- Event schema → Schema Registry: validates values (evidence: `README.md`)
- Kafka cluster → Schema Registry: uses schemas (evidence: `README.md`)
