How agelenler/food-ordering-system works
Main Components
• Microservices:
– Customer Service (with its customer-application, customer-dataaccess, customer-domain, and customer-messaging modules)
– Order Service (including its order-application, order-dataaccess, order-domain, and order-messaging modules)
– Payment Service (with payment-container, payment-dataaccess, payment-domain, and payment-messaging modules)
– Restaurant Service (encompassing restaurant-container, restaurant-dataaccess, restaurant-domain, and restaurant-messaging modules)
• Common Module:
– Contains shared domain classes and common infrastructure across services (see common/common-application, common-dataaccess, and common-domain)
• Infrastructure Components:
– Kafka Subsystem: Includes Kafka Producer, Consumer, Model and Config components; the Docker Compose files show a Kafka cluster and Zookeeper setup.
– Outbox Pattern: Each service (especially Order, Payment, and Restaurant) has an outbox with scheduler classes, dedicated repositories, and mappers.
– Saga Orchestrator: Specific classes implementing steps in SAGA (see OrderApprovalSaga, OrderPaymentSaga, and related scheduler/outbox schedulers).
Relationships and Interactions
• Each microservice exposes REST endpoints (e.g., CustomerController, OrderController) and communicates via messaging.
– The Order Service emits events (e.g., OrderCreatedEvent) that other services listen to.
– The Payment Service listens to payment request messages from Order and responds via Kafka.
– The Restaurant Service listens for restaurant approval events and publishes responses.
• Outbox modules capture local state changes and publish integration events.
• SAGA orchestration is evident in the Order Service, where multiple steps coordinate (customer notification, payment confirmation, restaurant approval).
Architectural Patterns Highlighted
• Clean and Hexagonal Architecture: Show separation between Application, Domain, and Infrastructure (data access, messaging layers).
• Domain-Driven Design (DDD): Bounded contexts for customer, order, payment, and restaurant with corresponding domain entities, value objects, and domain services.
• Event-Driven Communication: Kafka-based messaging channels (producers and consumers) are essential for asynchronous integration.
• Outbox Pattern: An internal staging area for transactional message production.
• SAGA Pattern: The orchestration of multi-step long-running transactions across microservices.
Technologies and Frameworks
• Spring Boot for all microservices (each service container has a main application class).
• Maven (pom.xml files) for dependency management.
• Kafka (producers, consumers, event models, and Avro schemas provided in the kafka modules).
• Docker Compose for deployment of Kafka, Zookeeper, and other infrastructure components.
• Databases (implied via schema init scripts and SQL files) and JPA/Hibernate (repositories and entity classes).
Additional Advice for Detail
• Do not over-simplify – it is beneficial to show as many boundaries and interactions as possible.
• Be mindful of how the modules are structured (e.g., separate data access, domain, application layers) so that their dependencies are clearly mapped out.
• How the Outbox and Saga mechanisms support eventual consistency across the distributed transactions.