Project Architecture
Multi-module Maven structure with clear separation between common, backend, and frontend concerns.
Multi-Module Structure
SpringBootKafkaWorkshop/
├── spring-boot-kafka-common/ # Shared DTOs and enums
├── spring-boot-kafka-backend/ # REST API + Kafka consumer
├── spring-boot-kafka-frontend/ # Web UI + Kafka producer
├── docker-compose.yml # Infrastructure
└── pom.xml # Parent POM
Module Details
spring-boot-kafka-common
Purpose: Shared code used by both backend and frontend
Contains:
ProductDTO- Product data transfer objectPurchaseOrderDTO- Order data transfer objectProductOrderDTO- Order line itemPurchaseOrderStatus- Order status enum
spring-boot-kafka-backend
Port: 8080
Purpose: Business logic, persistence, and Kafka consumer
Key Components:
- Entities: Product, Order, OrderItem (JPA)
- Repositories: Spring Data JPA repositories
- Services: CommandService and QueryService (CQRS)
- Controllers: REST API endpoints
- Kafka Consumer: Processes purchase orders
spring-boot-kafka-frontend
Port: 8081
Purpose: User interface and Kafka producer
Key Components:
- Controllers: Thymeleaf page controllers
- Services: REST client for backend communication
- Kafka Producer: Publishes purchase orders
- Templates: Thymeleaf views with Tailwind CSS
Domain Model
ProductDTO {
String id (UUID)
String name
String description
Double price
Integer stock
String category
}
PurchaseOrderDTO {
String orderId (UUID)
String customerId
List<ProductOrderDTO> products
Double total
LocalDateTime orderDate
PurchaseOrderStatus status
}
Why Multi-Module?
- Code Reuse: Common DTOs shared between modules
- Clear Boundaries: Separation of concerns between layers
- Independent Deployment: Modules can be deployed separately
- Team Organization: Different teams can work on different modules
Key Takeaways
- Common module for shared code
- Backend handles persistence and business logic
- Frontend handles UI and async order submission
- Clear separation of concerns