How tahalammouchi/restaurant-app-microservices works
1. Repository shape
This is a multi-service Spring Boot microservices repo. Each service lives in its own Maven project under services/*, with its own pom.xml, Dockerfile, wrapper scripts, and src/main/resources/application.yaml. The root docker-compose.yml is the deployment boundary for running the system together.
2. Control plane services
Two services are infrastructure, not business domains:
- config-service: central configuration server, with per-service YAML files in src/main/resources/configurations/.
- discovery-service: service registry/discovery server.
Most other services are designed to boot against these control-plane services.
3. Edge and security boundary
gateway-service is the external entry point. It contains SecurityConfig and OpenApiConfig, so it acts as the request gatekeeper and API surface for clients. The README says JWT/OAuth2 security is handled here, with traffic routed onward to internal services.
4. Business services
The domain is a restaurant ordering flow split into bounded services:
- customer-service: customer profiles and addresses
- menu-service: menu categories and items
- order-service: order orchestration and order items
- payment-service: payment processing
- notification-service: outbound notifications and notification history
5. Order as the orchestration hub
order-service is the central synchronous orchestrator. Its clients/* packages show Feign-based HTTP clients to:
- customer-service
- menu-service
- payment-service
This indicates order creation validates customer and menu data, then triggers payment as part of the workflow.
6. Asynchronous messaging path
Kafka is the main event bus for post-processing. The services are wired around topic-specific config and producer/consumer classes:
- order-service publishes OrderConfirmation
- payment-service publishes payment-related notification requests
- notification-service consumes order/payment events via NotificationConsumer
This is the decoupled event-driven part of the architecture.
7. Notification subsystem
notification-service is more than a simple consumer: it has email/services, HTML templates under resources/templates, and a NotificationRepository. So it receives Kafka events, persists notification records, and renders/sends emails from templates.
8. Service-local data ownership
The repo follows database-per-service. The persisted services each keep their own model/repository layer:
- customer-service: domain models and repository abstractions, likely document-oriented given the README’s MongoDB note
- menu-service, order-service, payment-service: include SQL migration scripts under resources/db/migration, which suggests relational persistence with schema versioning
- notification-service: stores notification state independently
There is no shared database module.
9. Common internal layering
Most business services use the same internal pattern:
- controller layer
- DTOs for input/output
- domain models
- repositories
- service and mapper classes
- global exception handling with custom business exceptions
This gives each service a clean API boundary and keeps transport concerns separate from domain state.
10. Configuration and startup flow
order-service has bootstrap.yaml, which usually means it pulls remote config early during startup. Several services also have OpenApiConfig, showing that API documentation is generated per service rather than centrally. The config server and discovery server are dependencies of the runtime topology, not just optional utilities.
11. Operational packaging
Every service is container-ready and independently deployable. The repo is structured so the runtime graph is:
client/Gateway at the edge, control-plane services underneath, synchronous service-to-service calls for request handling, and Kafka for event propagation. That separation is the key thing to capture in an architecture diagram.
Main entry points: docker-compose.yml Compose · gateway-service Gateway · order-service Order · config-service Config
Components 22
Infrastructure
Deployment and platform services
- Compose · Runs the full system together
docker-compose.yml
Edge
Client entry and security boundary
- Gateway · External entry point with security and API routing
services/gateway-service
Control Plane
Shared runtime services for config and discovery
Business Services
Domain services for ordering flow
- Customer · Customer profiles and addresses
services/customer-service - Menu · Menu categories and menu items
services/menu-service - Order · Core order workflow and synchronous coordination
services/order-service - Payment · Payment processing and notification event emission
services/payment-service - Notification · Consumes events, stores notifications, and sends emails
services/notification-service - Customer API · HTTP boundary for customer operations
services/customer-service/src/main/java/com/restaurant/customer/customer/controllers/CustomerController.java - Menu API · HTTP boundary for menu item operations
services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/controllers/MenuItemController.java - Order API · HTTP boundary for order operations
services/order-service/src/main/java/com/restaurant/order_service/order/controllers/OrderController.java - Payment API · HTTP boundary for payment operations
services/payment-service/src/main/java/com/restaurant/payment_service/payment/controllers/PaymentController.java - Kafka Consumer · Consumes order and payment events
services/notification-service/src/main/java/com/restaurant/notification_service/kafka/services/NotificationConsumer.java - Order Producer · Publishes order confirmation events
services/order-service/src/main/java/com/restaurant/order_service/kafka/services/OrderProducer.java - Notification Producer · Publishes payment-driven notification requests
services/payment-service/src/main/java/com/restaurant/payment_service/kafka/services/NotificationProducer.java - Email Service · Renders templates and sends email notifications
services/notification-service/src/main/java/com/restaurant/notification_service/email/services/EmailService.java
Persistence
Service-owned storage concerns
- Customer Repo · Customer persistence access
services/customer-service/src/main/java/com/restaurant/customer/customer/repositories/CustomerRepository.java - Menu Repo · Menu category and item persistence
services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/repositories/MenuItemRepository.java - Order Repo · Order and order-item persistence
services/order-service/src/main/java/com/restaurant/order_service/order/repositories/OrderRepository.java - Payment Repo · Payment persistence
services/payment-service/src/main/java/com/restaurant/payment_service/payment/repositories/PaymentRepository.java - Notification Repo · Notification history persistence
services/notification-service/src/main/java/com/restaurant/notification_service/notification/repositories/NotificationRepository.java
Connections 39
- Compose → Config: starts · Deploys the config server as part of the system
- Compose → Discovery: starts · Deploys the registry as part of the system
- Compose → Gateway: starts · Deploys the edge gateway
- Compose → Customer: starts · Deploys business services
- Compose → Menu: starts · Deploys business services
- Compose → Order: starts · Deploys business services
- Compose → Payment: starts · Deploys business services
- Compose → Notification: starts · Deploys business services
- Gateway → Customer: routes · Proxies customer requests to internal service
- Gateway → Menu: routes · Proxies menu requests to internal service
- Gateway → Order: routes · Proxies order requests to internal service
- Gateway → Payment: routes · Proxies payment requests to internal service
- Gateway → Notification: routes · Proxies notification-related requests if exposed
- Config → Gateway: configures · Serves gateway configuration
- Config → Customer: configures · Serves customer service configuration
- Config → Menu: configures · Serves menu service configuration
- Config → Order: configures · Serves order service configuration
- Config → Payment: configures · Serves payment service configuration
- Config → Notification: configures · Serves notification service configuration
- Discovery → Gateway: registers · Gateway registers for discovery
- Discovery → Customer: registers · Customer service registers for discovery
- Discovery → Menu: registers · Menu service registers for discovery
- Discovery → Order: registers · Order service registers for discovery
- Discovery → Payment: registers · Payment service registers for discovery
- Discovery → Notification: registers · Notification service registers for discovery
- Customer API → Customer Repo: uses · Controller delegates to persistence layer
- Menu API → Menu Repo: uses · Controller delegates to persistence layer
- Order API → Order Repo: uses · Controller delegates to persistence layer
- Payment API → Payment Repo: uses · Controller delegates to persistence layer
- Kafka Consumer → Notification Repo: persists · Consumes events and stores notification history
- Email Service → Notification Repo: records · Notification outcomes are stored independently
- Order → Customer: feign client · Validates customer data during order flow
- Order → Menu: feign client · Fetches menu item data during order flow
- Order → Payment: feign client · Triggers payment as part of order flow
- Order → Order Producer: publishes · Emits order confirmation event
- Payment → Notification Producer: publishes · Emits payment-driven notification request
- Order Producer → Kafka Consumer: Kafka event · Order confirmation is consumed asynchronously
- Notification Producer → Kafka Consumer: Kafka event · Payment notification event is consumed asynchronously
- Kafka Consumer → Email Service: dispatches · Consumer hands off to email rendering/sending