# brodygaudel/bank architecture

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

- Interactive diagram: https://gitdiagram.com/brodygaudel/bank
- Repository: https://github.com/brodygaudel/bank

## Overview

1. This repository is a microservices monorepo. Each service is a separate Spring Boot application with its own Maven build, tests, and runtime configuration, so the architecture is deployment-unit oriented rather than a single shared application.

2. The edge layer is split into a discovery service and a reactive gateway. The discovery service is a Eureka registry; the gateway is the public entry point that routes requests to downstream services by service name, letting clients avoid talking to services directly.

3. The authentication service owns user identity and authorization. It models users, roles, and verification records, exposes REST endpoints for login and account/password management, and uses JWT-based security. Other services share the same JWT validation pattern through their own security filters/configs.

4. The customer service is a conventional CRUD service for customer master data. It persists a Customer entity through JPA, exposes REST endpoints, enforces domain validation such as minimum age, and returns DTOs for create/read flows. Other services consult it for customer existence and profile-related checks.

5. The account service is the most architecturally specialized part of the system. It implements CQRS and event sourcing with Axon Framework: command handling is separated from query handling, and account changes are emitted as domain events instead of being written directly to a single mutable model.

6. Inside the account service, the command side centers on an AccountAggregate plus command objects for create, activate, suspend, credit, debit, delete, and transfer. Commands pass through validation/interception, then the aggregate produces events such as AccountCreatedEvent or AccountDebitedEvent.

7. The account service query side builds a separate read model. Event handlers project account and operation events into JPA entities and repositories, and query handlers serve read requests from these materialized views. This means writes and reads are intentionally decoupled and can evolve independently.

8. Service-to-service communication is synchronous and client-based. The account and authentication services include REST clients for customer and notification interactions, so flows like “validate customer”, “send notification”, or “check account state” cross service boundaries through HTTP rather than shared database access.

9. The notification service is a dedicated outbound communication service. It accepts notification requests, renders email content using an HTML template, and centralizes messaging concerns so business services do not embed mail delivery logic.

10. Data ownership is service-scoped. Authentication manages users/roles/verifications, customer manages customers, account maintains both event-sourced command state and read-side projections, and notification is focused on delivery. Axon Server must be up first for the account service, while Docker support and the root Maven build indicate the repo is designed for containerized, independently runnable services.

Main entry points: [`pom.xml`](https://github.com/brodygaudel/bank/blob/main/pom.xml) (Root build), [`gateway-service/src/main/java/org/mounanga/gatewayservice/GatewayServiceApplication.java`](https://github.com/brodygaudel/bank/blob/main/gateway-service/src/main/java/org/mounanga/gatewayservice/GatewayServiceApplication.java) (Gateway), [`discovery-service/src/main/java/org/mounanga/discoveryservice/DiscoveryServiceApplication.java`](https://github.com/brodygaudel/bank/blob/main/discovery-service/src/main/java/org/mounanga/discoveryservice/DiscoveryServiceApplication.java) (Discovery), [`authentication-service/src/main/java/org/mounanga/authenticationservice/AuthenticationServiceApplication.java`](https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/AuthenticationServiceApplication.java) (Auth service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform"]
  node_mono_build["Root build<br/>maven monorepo<br/>[pom.xml]"]
end

subgraph group_edge["Edge"]
  node_discovery_service(("Discovery<br/>Eureka registry"))
  node_gateway_service(("Gateway"))
end

subgraph group_services["Business services"]
  node_auth_service["Auth service<br/>Spring Boot service"]
  node_customer_service["Customer service<br/>CRUD service"]
  node_account_service["Account service<br/>CQRS/event-sourced service"]
  node_notification_service["Notification<br/>delivery service"]
  node_auth_security["JWT security<br/>security filters"]
  node_auth_identity[("Identity model<br/>user/role domain<br/>[User.java]")]
  node_auth_api["Auth API<br/>REST controllers"]
  node_customer_core[("Customer core<br/>JPA CRUD domain")]
  node_customer_api["Customer API<br/>REST controller"]
  node_notification_core[("Notify core<br/>email service")]
  node_notification_api["Notify API<br/>REST controller"]
end

subgraph group_account["Account internals"]
  node_account_command{{"Command side<br/>Axon command model"}}
  node_account_query[("Query side<br/>read model")]
  node_account_events["Account events<br/>domain events"]
  node_account_api["Account API<br/>REST controllers"]
  node_account_clients["Service clients<br/>HTTP clients"]
end

node_mono_build -->|"includes"| node_discovery_service
node_mono_build -->|"includes"| node_gateway_service
node_mono_build -->|"includes"| node_auth_service
node_mono_build -->|"includes"| node_customer_service
node_mono_build -->|"includes"| node_account_service
node_mono_build -->|"includes"| node_notification_service
node_gateway_service -->|"registers via"| node_discovery_service
node_auth_service -->|"registers via"| node_discovery_service
node_customer_service -->|"registers via"| node_discovery_service
node_account_service -->|"registers via"| node_discovery_service
node_notification_service -->|"registers via"| node_discovery_service
node_gateway_service -->|"routes to"| node_auth_api
node_gateway_service -->|"routes to"| node_customer_api
node_gateway_service -->|"routes to"| node_account_api
node_gateway_service -->|"routes to"| node_notification_api
node_auth_api -->|"protected by"| node_auth_security
node_auth_service -->|"owns"| node_auth_identity
node_customer_api -->|"serves"| node_customer_core
node_account_api -->|"writes"| node_account_command
node_account_api -->|"reads"| node_account_query
node_account_command -->|"emits"| node_account_events
node_account_events -->|"projects into"| node_account_query
node_account_command -->|"calls"| node_account_clients
node_account_query -->|"calls"| node_account_clients
node_account_clients -->|"checks"| node_customer_service
node_account_clients -->|"notifies"| node_notification_service
node_auth_service -->|"notifies"| node_notification_service
node_notification_api -->|"delegates to"| node_notification_core
node_customer_service -.->|"shares pattern"| node_auth_security
node_account_service -.->|"shares pattern"| node_auth_security

click node_mono_build "https://github.com/brodygaudel/bank/blob/main/pom.xml"
click node_discovery_service "https://github.com/brodygaudel/bank/blob/main/discovery-service/src/main/java/org/mounanga/discoveryservice/DiscoveryServiceApplication.java"
click node_gateway_service "https://github.com/brodygaudel/bank/blob/main/gateway-service/src/main/java/org/mounanga/gatewayservice/GatewayServiceApplication.java"
click node_auth_service "https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/AuthenticationServiceApplication.java"
click node_customer_service "https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/CustomerServiceApplication.java"
click node_account_service "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/AccountServiceApplication.java"
click node_notification_service "https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/NotificationServiceApplication.java"
click node_auth_security "https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/security/SecurityConfiguration.java"
click node_auth_identity "https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/entity/User.java"
click node_auth_api "https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/web/AuthenticationRestController.java"
click node_customer_core "https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/service/implementation/CustomerServiceImpl.java"
click node_customer_api "https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/web/CustomerRestController.java"
click node_account_command "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/aggregate/AccountAggregate.java"
click node_account_query "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/queries/service/AccountQueryHandlerService.java"
click node_account_events "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/common/event/AccountCreatedEvent.java"
click node_account_api "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/web/AccountCommandRestController.java"
click node_account_clients "https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/web/CustomerRestClient.java"
click node_notification_core "https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/service/implementation/NotificationServiceImpl.java"
click node_notification_api "https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/web/NotificationRestController.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_mono_build toneBlue
class node_discovery_service,node_gateway_service toneAmber
class node_auth_service,node_customer_service,node_account_service,node_notification_service,node_auth_security,node_auth_identity,node_auth_api,node_customer_core,node_customer_api,node_notification_core,node_notification_api toneMint
class node_account_command,node_account_query,node_account_events,node_account_api,node_account_clients toneRose
```

## Components

### Platform

Cross-cutting runtime and composition pieces

- [Root build](https://github.com/brodygaudel/bank/blob/main/pom.xml): maven monorepo · Top-level multi-service Maven build and repo composition · `pom.xml`

### Edge

Discovery and public entry points

- [Discovery](https://github.com/brodygaudel/bank/blob/main/discovery-service/src/main/java/org/mounanga/discoveryservice/DiscoveryServiceApplication.java): Eureka registry · Service registry for runtime discovery · `discovery-service/src/main/java/org/mounanga/discoveryservice/DiscoveryServiceApplication.java`
- [Gateway](https://github.com/brodygaudel/bank/blob/main/gateway-service/src/main/java/org/mounanga/gatewayservice/GatewayServiceApplication.java): reactive API gateway · Public entry point that routes to downstream services by service name · `gateway-service/src/main/java/org/mounanga/gatewayservice/GatewayServiceApplication.java`

### Business services

Domain services with their own data and APIs

- [Auth service](https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/AuthenticationServiceApplication.java): Spring Boot service · Identity, roles, verification, login, and password management · `authentication-service/src/main/java/org/mounanga/authenticationservice/AuthenticationServiceApplication.java`
- [Customer service](https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/CustomerServiceApplication.java): CRUD service · Customer master data with validation and DTO-based REST access · `customer-service/src/main/java/org/mounanga/customerservice/CustomerServiceApplication.java`
- [Account service](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/AccountServiceApplication.java): CQRS/event-sourced service · Account management with Axon command and query separation · `account-service/src/main/java/org/mounanga/accountservice/AccountServiceApplication.java`
- [Notification](https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/NotificationServiceApplication.java): delivery service · Outbound messaging and email rendering · `notification-service/src/main/java/org/mounanga/notificationservice/NotificationServiceApplication.java`
- [JWT security](https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/security/SecurityConfiguration.java): security filters · JWT authorization and security configuration · `authentication-service/src/main/java/org/mounanga/authenticationservice/security/SecurityConfiguration.java`
- [Identity model](https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/entity/User.java): user/role domain · Users, roles, and verification records · `authentication-service/src/main/java/org/mounanga/authenticationservice/entity/User.java`
- [Auth API](https://github.com/brodygaudel/bank/blob/main/authentication-service/src/main/java/org/mounanga/authenticationservice/web/AuthenticationRestController.java): REST controllers · Login, user, role, and password endpoints · `authentication-service/src/main/java/org/mounanga/authenticationservice/web/AuthenticationRestController.java`
- [Customer core](https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/service/implementation/CustomerServiceImpl.java): JPA CRUD domain · Customer entity, validation, repository, and service layer · `customer-service/src/main/java/org/mounanga/customerservice/service/implementation/CustomerServiceImpl.java`
- [Customer API](https://github.com/brodygaudel/bank/blob/main/customer-service/src/main/java/org/mounanga/customerservice/web/CustomerRestController.java): REST controller · Customer REST endpoints and DTO flow · `customer-service/src/main/java/org/mounanga/customerservice/web/CustomerRestController.java`
- [Notify core](https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/service/implementation/NotificationServiceImpl.java): email service · Notification rendering and delivery implementation · `notification-service/src/main/java/org/mounanga/notificationservice/service/implementation/NotificationServiceImpl.java`
- [Notify API](https://github.com/brodygaudel/bank/blob/main/notification-service/src/main/java/org/mounanga/notificationservice/web/NotificationRestController.java): REST controller · Notification request endpoint · `notification-service/src/main/java/org/mounanga/notificationservice/web/NotificationRestController.java`

### Account internals

CQRS/event-sourced account service structure

- [Command side](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/aggregate/AccountAggregate.java): Axon command model · Aggregates, commands, validation, and event emission · `account-service/src/main/java/org/mounanga/accountservice/commands/aggregate/AccountAggregate.java`
- [Query side](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/queries/service/AccountQueryHandlerService.java): read model · Event projections, repositories, and query handlers for materialized views · `account-service/src/main/java/org/mounanga/accountservice/queries/service/AccountQueryHandlerService.java`
- [Account events](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/common/event/AccountCreatedEvent.java): domain events · Event stream shared by projections and downstream effects · `account-service/src/main/java/org/mounanga/accountservice/common/event/AccountCreatedEvent.java`
- [Account API](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/web/AccountCommandRestController.java): REST controllers · Command and query HTTP entry points · `account-service/src/main/java/org/mounanga/accountservice/commands/web/AccountCommandRestController.java`
- [Service clients](https://github.com/brodygaudel/bank/blob/main/account-service/src/main/java/org/mounanga/accountservice/commands/web/CustomerRestClient.java): HTTP clients · Customer and notification REST clients used across flows · `account-service/src/main/java/org/mounanga/accountservice/commands/web/CustomerRestClient.java`

## Connections

- Root build → Discovery: includes · Root build composes the discovery service
- Root build → Gateway: includes · Root build composes the gateway service
- Root build → Auth service: includes · Root build composes the authentication service
- Root build → Customer service: includes · Root build composes the customer service
- Root build → Account service: includes · Root build composes the account service
- Root build → Notification: includes · Root build composes the notification service
- Gateway → Discovery: registers via · Gateway relies on service discovery for routing
- Auth service → Discovery: registers via · Auth service is discoverable through Eureka
- Customer service → Discovery: registers via · Customer service is discoverable through Eureka
- Account service → Discovery: registers via · Account service is discoverable through Eureka
- Notification → Discovery: registers via · Notification service is discoverable through Eureka
- Gateway → Auth API: routes to · Gateway exposes auth-related public traffic
- Gateway → Customer API: routes to · Gateway exposes customer traffic
- Gateway → Account API: routes to · Gateway exposes account traffic
- Gateway → Notify API: routes to · Gateway exposes notification traffic
- Auth API → JWT security: protected by · Authentication endpoints use JWT security
- Auth service → Identity model: owns · Auth service owns user, role, and verification data
- Customer API → Customer core: serves · Customer REST layer delegates to CRUD domain logic
- Account API → Command side: writes · Command endpoints dispatch account mutations
- Account API → Query side: reads · Query endpoints serve materialized views
- Command side → Account events: emits · Commands produce domain events instead of direct writes
- Account events → Query side: projects into · Events update read-side projections
- Command side → Service clients: calls · Command flows validate customers and other external state
- Query side → Service clients: calls · Read-side flows can notify or integrate externally
- Service clients → Customer service: checks · Account service consults customer existence and profile state
- Service clients → Notification: notifies · Account service sends outbound notifications through HTTP
- Auth service → Notification: notifies · Authentication flows can trigger outbound messaging
- Notify API → Notify core: delegates to · Notification controller delegates to delivery logic
- Customer service → JWT security: shares pattern · Customer service uses the same JWT-style security boundary
- Account service → JWT security: shares pattern · Account service uses JWT authorization filtering
