How lj19950508/ddd-demo-java works
Project type and purpose
• This is a Java multi‑module microservice built using the Hexagonal (Ports & Adapters) architecture combined with CQRS.
• Modules:
• start – Spring Boot bootstrap & configuration
• adapter – inbound (REST/gRPC) & outbound (persistence, RPC) adapters
• application – orchestration layer (commands & queries)
• domain – business logic (aggregates, entities, value objects, domain services)
• provider – RPC server/client definitions for other services
• Purpose: expose user‑related functionality over REST/gRPC, orchestrate domain operations, persist data to MySQL/Redis/MQ, and offer an RPC interface for peer services.
File structure
• Top‑level POM aggregates sub‑modules.
• start/: SpringBoot entry point + YAML configs for MySQL, Redis, web.
• adapter/:
– in/http/rest/api/UserController.java
– out/persistent/UserRepositoryImpl.java
– out/rpc/grpc (RPC client stubs)
• application/:
– command/… (CommandService, factories to build domain objects)
– query/… (QueryService, query params/results)
– service/UserService.java
• domain/:
– biz1/entity/User.java (Aggregate Root)
– biz1/valueobject/Address.java
– biz1/repository/IUserRepository (port)
– biz1/service (domain services)
• provider/: definitions for exposing this service’s RPC interface.
README for additional insights
• Dependency flow: infrastructure → adapter → application → domain
• Inbound adapters handle protocol translation (PO ↔ DO ↔ VO)
• Application layer orchestrates domain logic, command/query segregation (CQRS)
• Domain is “pure”: no external dependencies, uses DI only for wiring interfaces
• Infrastructure provides actual implementations for persistence, MQ, RPC clients