Bank System Microservices
A modern, cloud-native banking system built with .NET 9 microservices architecture, designed for Azure deployment with Clean Architecture, CQRS, and Event-Driven Architecture patterns.
๐๏ธ Architecture Overview
This system implements a distributed banking platform using microservices that communicate through Azure Service Bus events, following Domain-Driven Design (DDD) principles and the CQRS pattern for optimal scalability and maintainability.
Core Microservices
- ๐ Security Service: Handles authentication, authorization, and user management
- ๐ฆ Account Service: Manages customer accounts, balances, and account operations
- ๐ธ Transaction Service: Processes financial transactions (deposits, withdrawals) - Write operations
- ๐ Movement Service: Provides transaction history and reporting - Read operations
- ๐ Notification Service: Manages multi-channel notifications and alerts
- ๐ Reporting Service: Handles analytics, reports, and business intelligence
Architecture Patterns
- Clean Architecture: Clear separation of concerns across layers
- CQRS (Command Query Responsibility Segregation): Separate read and write operations
- Event-Driven Architecture: Asynchronous communication via Azure Service Bus
- Domain-Driven Design: Rich domain models with business logic encapsulation
- Microservices: Independently deployable and scalable services
๐ Technology Stack
Backend
- .NET 9: Latest framework with improved performance and features
- ASP.NET Core: Web API framework
- Entity Framework Core: ORM for data access
- MediatR: CQRS and Mediator pattern implementation
- FluentValidation: Input validation
- AutoMapper: Object-to-object mapping
- Serilog: Structured logging
Azure Services
- Azure Service Bus: Message broker for event-driven communication
- Azure SQL Database: Primary database for transactions and accounts
- Azure Cosmos DB: Document database for movement history (read-optimized)
- Azure Key Vault: Secrets and configuration management
- Azure Application Insights: Monitoring and telemetry
- Azure API Management: API Gateway and management
- Azure Container Apps: Container hosting platform
Development Tools
- Docker: Containerization
- .NET Aspire: Local development orchestration and monitoring (Local Development Only)
- YARP: Reverse proxy for API Gateway (Local Development Only)
- Terraform/Bicep: Infrastructure as Code
- Azure DevOps: CI/CD pipelines
- xUnit: Unit testing framework
- FluentAssertions: Assertion library
Environment Architecture
Local Development Environment
- API Gateway: YARP-based reverse proxy for service routing
- .NET Aspire Dashboard: Local orchestration and monitoring
- ServiceDefaults: Aspire-based service configuration and telemetry
Production Environment (Azure)
- Azure API Management: Replaces local API Gateway for enterprise-grade routing, policies, and security
- Azure Application Insights Dashboard: Replaces .NET Aspire Dashboard for production monitoring
- Azure Service Discovery: Native Azure service discovery and load balancing
๐๏ธ System Architecture
graph TB
%% Client Layer
Client[๐ฑ Client App<br/>Angular]
%% Gateway Layer
Gateway[๐ API Management<br/>Gateway]
%% Core Services Layer
Security[๐ Security<br/>Service]
Account[๐ฆ Account<br/>Service]
Transaction[๐ธ Transaction<br/>Service]
%% Event Bus
ServiceBus[๐ Azure Service Bus<br/>Event Distribution]
%% Read Services Layer
Movement[๐ Movement<br/>Service]
Notification[๐ Notification<br/>Service]
Reporting[๐ Reporting<br/>Service]
%% Data Layer
SqlDB[(๐๏ธ Azure SQL<br/>Database)]
CosmosDB[(๐ Azure Cosmos DB<br/>Movement History)]
%% Client to Gateway
Client --> Gateway
%% Gateway to Core Services
Gateway --> Security
Gateway --> Account
Gateway --> Transaction
%% Core Services to Event Bus
Security -.-> ServiceBus
Account -.-> ServiceBus
Transaction -.-> ServiceBus
%% Event Bus to Read Services
ServiceBus -.-> Movement
ServiceBus -.-> Notification
ServiceBus -.-> Reporting
%% Data Connections
Security --> SqlDB
Account --> SqlDB
Transaction --> SqlDB
Movement --> CosmosDB
Reporting --> SqlDB
Reporting --> CosmosDB
%% Styling - Darker backgrounds with white text for optimal contrast
classDef clientStyle fill:#0277bd,stroke:#01579b,stroke-width:2px,color:#ffffff
classDef gatewayStyle fill:#6a1b9a,stroke:#4a148c,stroke-width:2px,color:#ffffff
classDef coreServiceStyle fill:#388e3c,stroke:#2e7d32,stroke-width:2px,color:#ffffff
classDef readServiceStyle fill:#f57c00,stroke:#e65100,stroke-width:2px,color:#ffffff
classDef eventStyle fill:#ad1457,stroke:#c2185b,stroke-width:2px,color:#ffffff
classDef dataStyle fill:#689f38,stroke:#558b2f,stroke-width:2px,color:#ffffff
class Client clientStyle
class Gateway gatewayStyle
class Security,Account,Transaction coreServiceStyle
class Movement,Notification,Reporting readServiceStyle
class ServiceBus eventStyle
class SqlDB,CosmosDB dataStyle
๐ Event-Driven Flow
Transaction Processing Flow
- Client initiates a deposit/withdrawal request
- API Gateway routes to Transaction Service
- Transaction Service validates and processes the transaction
- Transaction Service publishes
TransactionCreatedEvent
- Account Service subscribes to update account balance
- Movement Service subscribes to create movement history record
Benefits
- Loose Coupling: Services communicate through events
- Scalability: Each service can scale independently
- Resilience: Failure in one service doesn't affect others
- Eventual Consistency: Data consistency across services
๐ Project Structure