# tahalammouchi/restaurant-app-microservices architecture

> Architecture diagram of the GitHub repository tahalammouchi/restaurant-app-microservices, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tahalammouchi/restaurant-app-microservices
- Repository: https://github.com/tahalammouchi/restaurant-app-microservices

## Overview

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`](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/docker-compose.yml) (Compose), [`services/gateway-service`](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/gateway-service) (Gateway), [`services/order-service`](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/order-service) (Order), [`services/config-service`](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/config-service) (Config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_infrastructure["Infrastructure"]
  node_docker_compose["Compose<br/>deployment boundary<br/>[docker-compose.yml]"]
end

subgraph group_edge["Edge"]
  node_gateway_service["Gateway"]
end

subgraph group_control["Control Plane"]
  node_config_service["Config"]
  node_discovery_service["Discovery<br/>service registry"]
end

subgraph group_business["Business Services"]
  node_customer_service["Customer<br/>profile service"]
  node_menu_service["Menu<br/>catalog service"]
  node_order_service["Order<br/>orchestrator"]
  node_payment_service["Payment"]
  node_notification_service["Notification<br/>event consumer"]
  node_customer_api["Customer API<br/>controller layer"]
  node_menu_api["Menu API<br/>controller layer"]
  node_order_api["Order API<br/>controller layer"]
  node_payment_api["Payment API<br/>controller layer"]
  node_notification_consumer["Kafka Consumer<br/>event consumer"]
  node_order_producer["Order Producer<br/>event producer<br/>[OrderProducer.java]"]
  node_payment_producer["Notification Producer<br/>event producer"]
  node_notification_email["Email Service<br/>mailer<br/>[EmailService.java]"]
end

subgraph group_data["Persistence"]
  node_customer_repo[("Customer Repo")]
  node_menu_repo[("Menu Repo")]
  node_order_repo[("Order Repo")]
  node_payment_repo[("Payment Repo")]
  node_notification_repo[("Notification Repo")]
end

node_docker_compose -->|"starts"| node_config_service
node_docker_compose -->|"starts"| node_discovery_service
node_docker_compose -->|"starts"| node_gateway_service
node_docker_compose -->|"starts"| node_customer_service
node_docker_compose -->|"starts"| node_menu_service
node_docker_compose -->|"starts"| node_order_service
node_docker_compose -->|"starts"| node_payment_service
node_docker_compose -->|"starts"| node_notification_service
node_gateway_service -->|"routes"| node_customer_service
node_gateway_service -->|"routes"| node_menu_service
node_gateway_service -->|"routes"| node_order_service
node_gateway_service -->|"routes"| node_payment_service
node_gateway_service -.->|"routes"| node_notification_service
node_config_service -->|"configures"| node_gateway_service
node_config_service -->|"configures"| node_customer_service
node_config_service -->|"configures"| node_menu_service
node_config_service -->|"configures"| node_order_service
node_config_service -->|"configures"| node_payment_service
node_config_service -->|"configures"| node_notification_service
node_discovery_service -->|"registers"| node_gateway_service
node_discovery_service -->|"registers"| node_customer_service
node_discovery_service -->|"registers"| node_menu_service
node_discovery_service -->|"registers"| node_order_service
node_discovery_service -->|"registers"| node_payment_service
node_discovery_service -->|"registers"| node_notification_service
node_customer_api -->|"uses"| node_customer_repo
node_menu_api -->|"uses"| node_menu_repo
node_order_api -->|"uses"| node_order_repo
node_payment_api -->|"uses"| node_payment_repo
node_notification_consumer -->|"persists"| node_notification_repo
node_notification_email -->|"records"| node_notification_repo
node_order_service -->|"feign client"| node_customer_service
node_order_service -->|"feign client"| node_menu_service
node_order_service -->|"feign client"| node_payment_service
node_order_service -->|"publishes"| node_order_producer
node_payment_service -->|"publishes"| node_payment_producer
node_order_producer -->|"Kafka event"| node_notification_consumer
node_payment_producer -->|"Kafka event"| node_notification_consumer
node_notification_consumer -->|"dispatches"| node_notification_email

click node_docker_compose "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/docker-compose.yml"
click node_config_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/config-service"
click node_discovery_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/discovery-service"
click node_gateway_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/gateway-service"
click node_customer_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/customer-service"
click node_menu_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/menu-service"
click node_order_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/order-service"
click node_payment_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/payment-service"
click node_notification_service "https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/notification-service"
click node_customer_api "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/customer-service/src/main/java/com/restaurant/customer/customer/controllers/CustomerController.java"
click node_menu_api "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/controllers/MenuItemController.java"
click node_order_api "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/order/controllers/OrderController.java"
click node_payment_api "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/payment/controllers/PaymentController.java"
click node_notification_consumer "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/kafka/services/NotificationConsumer.java"
click node_order_producer "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/kafka/services/OrderProducer.java"
click node_payment_producer "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/kafka/services/NotificationProducer.java"
click node_notification_email "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/email/services/EmailService.java"
click node_customer_repo "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/customer-service/src/main/java/com/restaurant/customer/customer/repositories/CustomerRepository.java"
click node_menu_repo "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/repositories/MenuItemRepository.java"
click node_order_repo "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/order/repositories/OrderRepository.java"
click node_payment_repo "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/payment/repositories/PaymentRepository.java"
click node_notification_repo "https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/notification/repositories/NotificationRepository.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_docker_compose toneBlue
class node_gateway_service toneAmber
class node_config_service,node_discovery_service toneMint
class node_customer_service,node_menu_service,node_order_service,node_payment_service,node_notification_service,node_customer_api,node_menu_api,node_order_api,node_payment_api,node_notification_consumer,node_order_producer,node_payment_producer,node_notification_email toneRose
class node_customer_repo,node_menu_repo,node_order_repo,node_payment_repo,node_notification_repo toneIndigo
```

## Components

### Infrastructure

Deployment and platform services

- [Compose](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/docker-compose.yml): deployment boundary · Runs the full system together · `docker-compose.yml`

### Edge

Client entry and security boundary

- [Gateway](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/gateway-service): API gateway · External entry point with security and API routing · `services/gateway-service`

### Control Plane

Shared runtime services for config and discovery

- [Config](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/config-service): Spring config server · Central configuration server with per-service YAML files · `services/config-service`
- [Discovery](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/discovery-service): service registry · Service registration and lookup · `services/discovery-service`

### Business Services

Domain services for ordering flow

- [Customer](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/customer-service): profile service · Customer profiles and addresses · `services/customer-service`
- [Menu](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/menu-service): catalog service · Menu categories and menu items · `services/menu-service`
- [Order](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/order-service): orchestrator · Core order workflow and synchronous coordination · `services/order-service`
- [Payment](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/payment-service): payment service · Payment processing and notification event emission · `services/payment-service`
- [Notification](https://github.com/tahalammouchi/restaurant-app-microservices/tree/main/services/notification-service): event consumer · Consumes events, stores notifications, and sends emails · `services/notification-service`
- [Customer API](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/customer-service/src/main/java/com/restaurant/customer/customer/controllers/CustomerController.java): controller layer · HTTP boundary for customer operations · `services/customer-service/src/main/java/com/restaurant/customer/customer/controllers/CustomerController.java`
- [Menu API](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/controllers/MenuItemController.java): controller layer · HTTP boundary for menu item operations · `services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/controllers/MenuItemController.java`
- [Order API](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/order/controllers/OrderController.java): controller layer · HTTP boundary for order operations · `services/order-service/src/main/java/com/restaurant/order_service/order/controllers/OrderController.java`
- [Payment API](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/payment/controllers/PaymentController.java): controller layer · HTTP boundary for payment operations · `services/payment-service/src/main/java/com/restaurant/payment_service/payment/controllers/PaymentController.java`
- [Kafka Consumer](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/kafka/services/NotificationConsumer.java): event consumer · Consumes order and payment events · `services/notification-service/src/main/java/com/restaurant/notification_service/kafka/services/NotificationConsumer.java`
- [Order Producer](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/kafka/services/OrderProducer.java): event producer · Publishes order confirmation events · `services/order-service/src/main/java/com/restaurant/order_service/kafka/services/OrderProducer.java`
- [Notification Producer](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/kafka/services/NotificationProducer.java): event producer · Publishes payment-driven notification requests · `services/payment-service/src/main/java/com/restaurant/payment_service/kafka/services/NotificationProducer.java`
- [Email Service](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/email/services/EmailService.java): mailer · 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](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/customer-service/src/main/java/com/restaurant/customer/customer/repositories/CustomerRepository.java): repository · Customer persistence access · `services/customer-service/src/main/java/com/restaurant/customer/customer/repositories/CustomerRepository.java`
- [Menu Repo](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/repositories/MenuItemRepository.java): repository · Menu category and item persistence · `services/menu-service/src/main/java/com/restaurant/menu_service/menuItem/repositories/MenuItemRepository.java`
- [Order Repo](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/order-service/src/main/java/com/restaurant/order_service/order/repositories/OrderRepository.java): repository · Order and order-item persistence · `services/order-service/src/main/java/com/restaurant/order_service/order/repositories/OrderRepository.java`
- [Payment Repo](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/payment-service/src/main/java/com/restaurant/payment_service/payment/repositories/PaymentRepository.java): repository · Payment persistence · `services/payment-service/src/main/java/com/restaurant/payment_service/payment/repositories/PaymentRepository.java`
- [Notification Repo](https://github.com/tahalammouchi/restaurant-app-microservices/blob/main/services/notification-service/src/main/java/com/restaurant/notification_service/notification/repositories/NotificationRepository.java): repository · Notification history persistence · `services/notification-service/src/main/java/com/restaurant/notification_service/notification/repositories/NotificationRepository.java`

## Connections

- 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
