# amigoscode/microservices architecture

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

- Interactive diagram: https://gitdiagram.com/amigoscode/microservices
- Repository: https://github.com/amigoscode/microservices

## Overview

1. This repository is a Spring Boot microservices system split into multiple independently deployable services plus shared support modules. The main runtime services are `customer`, `fraud`, `notification`, `apigw`, and `eureka-server`.

2. The request entry point is the API gateway (`apigw`). It sits in front of the services and is the likely external HTTP boundary for clients. It routes requests onward rather than hosting business logic itself.

3. Service discovery is handled by `eureka-server`. The individual services are designed to register there and discover one another dynamically, which is important because the deployment targets include Docker and Kubernetes where service locations are not fixed.

4. The `customer` service is the core business workflow service. It contains a REST controller, service layer, repository, and domain model for customer registration. This is the most likely orchestration point for the customer onboarding flow.

5. The `fraud` service is a separate domain service with its own controller, service, entity, and repository for fraud check history. The `clients` module includes a `FraudClient` and `FraudCheckResponse`, indicating the customer service calls fraud synchronously through a generated client interface rather than embedding fraud logic locally.

6. The `notification` service is another isolated domain service with its own persistence and REST controller, but it also contains `rabbitmq/NotificationConsumer`, which shows it consumes async messages from RabbitMQ. This suggests notifications are handled asynchronously after customer-related events rather than inline with the request.

7. RabbitMQ is the asynchronous integration backbone. The shared `amqp` module provides `RabbitMQConfig` and `RabbitMQMessageProducer`, so message publication is centralized and reused. The `notification` service consumes those messages, forming the main event-driven path in the system.

8. The `clients` module is a shared contract layer. It packages the HTTP client interfaces and DTOs for cross-service calls, specifically fraud and notification requests/responses. This reduces duplication and keeps service-to-service APIs consistent.

9. Persistence is service-owned and not shared as a single database layer. `customer`, `fraud`, and `notification` each define their own repository and domain objects, which fits the microservice pattern of data ownership per service. The Kubernetes bootstrap files also include PostgreSQL manifests, so at least one shared or service-backed Postgres instance is part of the deployment topology.

10. Observability and infrastructure are first-class parts of the repo. There are Kubernetes bootstrap manifests for PostgreSQL, RabbitMQ, and Zipkin under `k8s/minikube/bootstrap`, which indicates local cluster setup includes the database, messaging broker, and distributed tracing backend.

11. Deployment is supported in two modes: Docker and Kubernetes. Each service has environment-specific configuration files such as `application-docker.yml` and `application-kube.yml`, and the repository includes `docker-compose.yml` plus Minikube manifests for both platform bootstrapping and individual service deployments.

12. The overall data flow is: external client -> API gateway -> customer service; customer service may call fraud synchronously through `clients`; domain events are published to RabbitMQ through `amqp`; notification service consumes those events and stores/handles notifications; Eureka supports discovery across these calls. The architecture is therefore a hybrid of synchronous request/response and asynchronous event-driven messaging.

Main entry points: [`docker-compose.yml`](https://github.com/amigoscode/microservices/blob/main/docker-compose.yml) (Docker/K8s), [`customer/src/main/java/com/amigoscode/customer/CustomerService.java`](https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerService.java) (Customer flow), [`eureka-server/src/main/java/com/amigoscode/eurekaserver/EurekaServerApplication.java`](https://github.com/amigoscode/microservices/blob/main/eureka-server/src/main/java/com/amigoscode/eurekaserver/EurekaServerApplication.java) (Eureka server), [`k8s/minikube/bootstrap/postgres/statefulset.yml`](https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/postgres/statefulset.yml) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime services"]
  node_apigw["API gateway<br/>Spring gateway"]
  node_eureka["Eureka server<br/>Discovery registry"]
  node_customer_app["Customer svc<br/>Business service"]
  node_customer_api["Customer API<br/>REST controller"]
  node_customer_core["Customer flow<br/>Service layer"]
  node_customer_data[("Customer data<br/>Repository + model")]
  node_fraud_app["Fraud svc<br/>Domain service"]
  node_fraud_api["Fraud API<br/>REST controller"]
  node_fraud_core["Fraud logic<br/>Service layer"]
  node_fraud_data[("Fraud data<br/>Repository + model")]
  node_notif_app["Notification svc<br/>Async service"]
  node_notif_api["Notification API<br/>REST controller"]
  node_notif_consumer["Rabbit consumer<br/>Message consumer"]
  node_notif_data[("Notification data<br/>Repository + model")]
end

subgraph group_infra["Infrastructure"]
  node_postgres[("PostgreSQL<br/>Database runtime<br/>[statefulset.yml]")]
  node_rabbitmq["RabbitMQ<br/>Message broker<br/>[statefulset.yaml]"]
  node_zipkin(("Zipkin<br/>Tracing backend<br/>[statefulset.yml]"))
  node_deploy["Docker/K8s<br/>Deployment config<br/>[docker-compose.yml]"]
end

subgraph group_contracts["Shared contracts"]
  node_clients["Client contracts<br/>Shared HTTP contracts"]
  node_amqp["AMQP support<br/>Shared messaging"]
end

node_apigw -->|"routes to"| node_customer_app
node_customer_app -.->|"registers"| node_eureka
node_fraud_app -.->|"registers"| node_eureka
node_notif_app -.->|"registers"| node_eureka
node_customer_api -->|"delegates"| node_customer_core
node_customer_core -->|"persists"| node_customer_data
node_customer_core -->|"calls fraud"| node_clients
node_clients -->|"invokes"| node_fraud_app
node_fraud_api -->|"delegates"| node_fraud_core
node_fraud_core -->|"persists"| node_fraud_data
node_notif_app -->|"hosts"| node_notif_api
node_notif_consumer -->|"consumes from"| node_rabbitmq
node_customer_core -->|"publishes"| node_amqp
node_amqp -->|"sends to"| node_rabbitmq
node_notif_consumer -->|"writes"| node_notif_data
node_customer_data -->|"stores in"| node_postgres
node_fraud_data -->|"stores in"| node_postgres
node_notif_data -->|"stores in"| node_postgres
node_customer_app -.->|"deployed via"| node_deploy
node_fraud_app -.->|"deployed via"| node_deploy
node_notif_app -.->|"deployed via"| node_deploy
node_apigw -.->|"deployed via"| node_deploy
node_eureka -.->|"deployed via"| node_deploy
node_deploy -.->|"boots"| node_rabbitmq
node_deploy -.->|"boots"| node_postgres
node_deploy -.->|"boots"| node_zipkin

click node_apigw "https://github.com/amigoscode/microservices/blob/main/apigw/src/main/java/com/amigoscode/apigw/ApiGWApplication.java"
click node_eureka "https://github.com/amigoscode/microservices/blob/main/eureka-server/src/main/java/com/amigoscode/eurekaserver/EurekaServerApplication.java"
click node_customer_app "https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerApplication.java"
click node_customer_api "https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerController.java"
click node_customer_core "https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerService.java"
click node_customer_data "https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerRepository.java"
click node_fraud_app "https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudApplication.java"
click node_fraud_api "https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudController.java"
click node_fraud_core "https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudCheckService.java"
click node_fraud_data "https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudCheckHistoryRepository.java"
click node_notif_app "https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationApplication.java"
click node_notif_api "https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationController.java"
click node_notif_consumer "https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/rabbitmq/NotificationConsumer.java"
click node_notif_data "https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationRepository.java"
click node_clients "https://github.com/amigoscode/microservices/tree/main/clients/src/main/java/com/amigoscode/clients"
click node_amqp "https://github.com/amigoscode/microservices/blob/main/amqp/src/main/java/com/amigoscode/amqp/RabbitMQConfig.java"
click node_postgres "https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/postgres/statefulset.yml"
click node_rabbitmq "https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/rabbitmq/statefulset.yaml"
click node_zipkin "https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/zipkin/statefulset.yml"
click node_deploy "https://github.com/amigoscode/microservices/blob/main/docker-compose.yml"

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_apigw,node_eureka,node_customer_app,node_customer_api,node_customer_core,node_customer_data,node_fraud_app,node_fraud_api,node_fraud_core,node_fraud_data,node_notif_app,node_notif_api,node_notif_consumer,node_notif_data toneBlue
class node_postgres,node_rabbitmq,node_zipkin,node_deploy toneAmber
class node_clients,node_amqp toneMint
```

## Components

### Runtime services

Deployable Spring Boot services and shared runtime modules

- [API gateway](https://github.com/amigoscode/microservices/blob/main/apigw/src/main/java/com/amigoscode/apigw/ApiGWApplication.java): Spring gateway · External HTTP entry point and request router · `apigw/src/main/java/com/amigoscode/apigw/ApiGWApplication.java`
- [Eureka server](https://github.com/amigoscode/microservices/blob/main/eureka-server/src/main/java/com/amigoscode/eurekaserver/EurekaServerApplication.java): Discovery registry · Service registration and lookup for the microservices · `eureka-server/src/main/java/com/amigoscode/eurekaserver/EurekaServerApplication.java`
- [Customer svc](https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerApplication.java): Business service · Customer onboarding and orchestration flow · `customer/src/main/java/com/amigoscode/customer/CustomerApplication.java`
- [Customer API](https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerController.java): REST controller · Handles customer registration requests · `customer/src/main/java/com/amigoscode/customer/CustomerController.java`
- [Customer flow](https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerService.java): Service layer · Coordinates registration, fraud check, and persistence · `customer/src/main/java/com/amigoscode/customer/CustomerService.java`
- [Customer data](https://github.com/amigoscode/microservices/blob/main/customer/src/main/java/com/amigoscode/customer/CustomerRepository.java): Repository + model · Customer entity and persistence boundary · `customer/src/main/java/com/amigoscode/customer/CustomerRepository.java`
- [Fraud svc](https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudApplication.java): Domain service · Fraud check history and validation service · `fraud/src/main/java/com/amigoscode/fraud/FraudApplication.java`
- [Fraud API](https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudController.java): REST controller · Fraud check endpoint · `fraud/src/main/java/com/amigoscode/fraud/FraudController.java`
- [Fraud logic](https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudCheckService.java): Service layer · Fraud check evaluation and history writes · `fraud/src/main/java/com/amigoscode/fraud/FraudCheckService.java`
- [Fraud data](https://github.com/amigoscode/microservices/blob/main/fraud/src/main/java/com/amigoscode/fraud/FraudCheckHistoryRepository.java): Repository + model · Fraud check history persistence · `fraud/src/main/java/com/amigoscode/fraud/FraudCheckHistoryRepository.java`
- [Notification svc](https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationApplication.java): Async service · Notification persistence and message consumption · `notification/src/main/java/com/amigoscode/notification/NotificationApplication.java`
- [Notification API](https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationController.java): REST controller · Notification retrieval or management endpoint · `notification/src/main/java/com/amigoscode/notification/NotificationController.java`
- [Rabbit consumer](https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/rabbitmq/NotificationConsumer.java): Message consumer · Consumes events from RabbitMQ · `notification/src/main/java/com/amigoscode/notification/rabbitmq/NotificationConsumer.java`
- [Notification data](https://github.com/amigoscode/microservices/blob/main/notification/src/main/java/com/amigoscode/notification/NotificationRepository.java): Repository + model · Notification entity and persistence boundary · `notification/src/main/java/com/amigoscode/notification/NotificationRepository.java`

### Infrastructure

Platform services and local deployment environment

- [PostgreSQL](https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/postgres/statefulset.yml): Database runtime · Bootstrap database infrastructure for service persistence · `k8s/minikube/bootstrap/postgres/statefulset.yml`
- [RabbitMQ](https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/rabbitmq/statefulset.yaml): Message broker · Asynchronous event backbone for notifications · `k8s/minikube/bootstrap/rabbitmq/statefulset.yaml`
- [Zipkin](https://github.com/amigoscode/microservices/blob/main/k8s/minikube/bootstrap/zipkin/statefulset.yml): Tracing backend · Distributed tracing backend in local cluster setup · `k8s/minikube/bootstrap/zipkin/statefulset.yml`
- [Docker/K8s](https://github.com/amigoscode/microservices/blob/main/docker-compose.yml): Deployment config · Service and bootstrap manifests plus docker-compose support · `docker-compose.yml`

### Shared contracts

Cross-service HTTP clients and messaging support

- [Client contracts](https://github.com/amigoscode/microservices/tree/main/clients/src/main/java/com/amigoscode/clients): Shared HTTP contracts · Feign-style clients and DTOs for fraud and notification calls · `clients/src/main/java/com/amigoscode/clients`
- [AMQP support](https://github.com/amigoscode/microservices/blob/main/amqp/src/main/java/com/amigoscode/amqp/RabbitMQConfig.java): Shared messaging · RabbitMQ configuration and producer utilities · `amqp/src/main/java/com/amigoscode/amqp/RabbitMQConfig.java`

## Connections

- API gateway → Customer svc: routes to · External requests are forwarded to customer service
- Customer svc → Eureka server: registers · Customer service participates in discovery
- Fraud svc → Eureka server: registers · Fraud service participates in discovery
- Notification svc → Eureka server: registers · Notification service participates in discovery
- Customer API → Customer flow: delegates · REST layer hands off to orchestration logic
- Customer flow → Customer data: persists · Customer workflow stores domain state
- Customer flow → Client contracts: calls fraud · Uses shared client contracts for synchronous fraud checks
- Client contracts → Fraud svc: invokes · Fraud client targets the fraud service
- Fraud API → Fraud logic: delegates · Fraud REST layer hands off to logic
- Fraud logic → Fraud data: persists · Fraud service stores check history
- Notification svc → Notification API: hosts · Notification service exposes its API
- Rabbit consumer → RabbitMQ: consumes from · Notification events are received from the broker
- Customer flow → AMQP support: publishes · Customer flow emits events through shared AMQP support
- AMQP support → RabbitMQ: sends to · Producer support targets the broker
- Rabbit consumer → Notification data: writes · Consumed events become stored notifications
- Customer data → PostgreSQL: stores in · Customer persistence uses PostgreSQL
- Fraud data → PostgreSQL: stores in · Fraud persistence uses PostgreSQL
- Notification data → PostgreSQL: stores in · Notification persistence uses PostgreSQL
- Customer svc → Docker/K8s: deployed via · Customer service has Docker/Kubernetes deployment support
- Fraud svc → Docker/K8s: deployed via · Fraud service has Docker/Kubernetes deployment support
- Notification svc → Docker/K8s: deployed via · Notification service has Docker/Kubernetes deployment support
- API gateway → Docker/K8s: deployed via · API gateway is configured for Docker/Kubernetes deployment
- Eureka server → Docker/K8s: deployed via · Discovery server is configured for deployment
- Docker/K8s → RabbitMQ: boots · Cluster bootstrap includes RabbitMQ
- Docker/K8s → PostgreSQL: boots · Cluster bootstrap includes PostgreSQL
- Docker/K8s → Zipkin: boots · Cluster bootstrap includes Zipkin
