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.
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.
- π 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
- 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
- .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 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
- 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
- API Gateway: YARP-based reverse proxy for service routing
- .NET Aspire Dashboard: Local orchestration and monitoring
- ServiceDefaults: Aspire-based service configuration and telemetry
- 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
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
- 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
- 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
BankSystemMicroservices/
βββ π README.md # Main documentation
βββ π LICENSE # MIT License
βββ π docker-compose.yml # Docker orchestration
βββ π docker-compose.infrastructure.yml # Infrastructure services
βββ π src/ # Source code
β βββ π BankSystem.sln # Main solution file
β βββ π coverlet.runsettings # Test coverage settings
β βββ π aspire-app/ # π LOCAL DEVELOPMENT ONLY
β β βββ π AppHost/ # .NET Aspire orchestration
β β β βββ π AppHost.cs # Aspire host configuration
β β β βββ π BankSystem.AppHost.csproj # AppHost project file
β β β βββ π appsettings.json # Aspire settings
β β βββ π ServiceDefaults/ # Aspire service defaults
β β βββ π Extensions.cs # Service extensions
β β βββ π BankSystem.ServiceDefaults.csproj
β βββ π gateway/ # π LOCAL DEVELOPMENT ONLY
β β βββ π ApiGateway/ # YARP-based API Gateway
β β βββ π Program.cs # Gateway entry point
β β βββ π BankSystem.ApiGateway.csproj # Gateway project
β β βββ π appsettings.json # Gateway configuration
β βββ π services/ # ποΈ Microservices
β β βββ π Security/ # π Authentication & Authorization
β β β βββ π src/
β β β β βββ π Security.Api/ # Web API layer
β β β β βββ π Security.Application/ # Application layer (CQRS)
β β β β βββ π Security.Domain/ # Domain layer (DDD)
β β β β βββ π Security.Infrastructure/ # Infrastructure layer
β β β βββ π tests/ # Service-specific tests
β β β βββ π Security.Application.UnitTests/
β β β βββ π Security.Domain.UnitTests/
β β β βββ π Security.Infrastructure.IntegrationTests/
β β βββ π Account/ # π¦ Account Management
β β β βββ π src/ # Same structure as Security
β β β βββ π tests/ # Same test structure
β β βββ π Transaction/ # πΈ Transaction Processing (Write)
β β β βββ π src/ # Same structure as Security
β β β βββ π tests/ # Same test structure
β β βββ π Movement/ # π Movement History (Read)
β β β βββ π src/ # Same structure as Security
β β β βββ π tests/ # Same test structure
β β βββ π Notification/ # π Notifications
β β β βββ π src/ # Same structure as Security
β β β βββ π tests/ # Same test structure
β β βββ π Reporting/ # π Reporting & Analytics
β β βββ π src/ # Same structure as Security
β β βββ π tests/ # Same test structure
β βββ π shared/ # π Shared Components
β βββ π src/
β β βββ π BankSystem.Shared.Application/ # Application layer components
β β βββ π BankSystem.Shared.Domain/ # Common domain logic
β β βββ π BankSystem.Shared.Infrastructure/ # Common infrastructure
β β βββ π BankSystem.Shared.Kernel/ # Core domain abstractions
β β βββ π BankSystem.Shared.WebApiDefaults/ # Web API configurations
β βββ π tests/
β βββ π BankSystem.Shared.Domain.UnitTests/
β βββ π BankSystem.Shared.Infrastructure.IntegrationTests/
βββ π docs/ # π Documentation
β βββ π dotnet-development-guidelines.md # Development guidelines
β βββ π health-checks-configuration.md # Health checks guide
β βββ π sonarqube-integration-guide.md # SonarQube setup
β βββ π guidelines/ # Detailed guidelines
β βββ π clean-code.md # Clean code practices
β βββ π api-design.md # API design patterns
β βββ π cqrs-implementation.md # CQRS patterns
β βββ π ... # Other guidelines
βββ π scripts/ # π§ Build & Deployment Scripts
β βββ π build-local.bat # Windows build script
β βββ π build-local.ps1 # PowerShell build script
β βββ π run-unit-tests.ps1 # Test execution script
β βββ π BUILD_SCRIPTS.md # Scripts documentation
βββ π tests/ # π§ͺ Cross-Service Integration Tests
β βββ π integration/ # End-to-end test scenarios
βββ π build/ # π CI/CD Configurations
βββ π azure-pipelines/ # Azure DevOps pipelines
β βββ π ci-build-test.yml # CI/CD pipeline definition
βββ π terraform/ # Infrastructure as Code
βββ π main.tf # Main Terraform config
βββ π variables.tf # Terraform variables
- aspire-app/ and gateway/: Used only for local development
- Production: Azure API Management and Azure Application Insights replace these components
- .NET 9 SDK
- Docker Desktop
- Azure CLI
- Visual Studio 2022 or VS Code
-
Clone the repository
git clone https://github.com/your-org/bank-system-microservices.git cd bank-system-microservices
-
Start infrastructure services
docker-compose -f docker-compose.infrastructure.yml up -d
-
Update connection strings
# Update appsettings.Development.json in each service
-
Run database migrations
dotnet ef database update --project src/services/Account/src/Account.Infrastructure dotnet ef database update --project src/services/Transaction/src/Transaction.Infrastructure
-
Start services
# Terminal 1 - Security Service dotnet run --project src/services/Security/src/Security.Api # Terminal 2 - Account Service dotnet run --project src/services/Account/src/Account.Api # Terminal 3 - Transaction Service dotnet run --project src/services/Transaction/src/Transaction.Api # Terminal 4 - Movement Service dotnet run --project src/services/Movement/src/Movement.Api # Terminal 5 - Notification Service dotnet run --project src/services/Notification/src/Notification.Api # Terminal 6 - Reporting Service dotnet run --project src/services/Reporting/src/Reporting.Api
# Database Connections
CONNECTIONSTRINGS__DEFAULTCONNECTION="Server=localhost;Database=BankSystem;Trusted_Connection=true;"
# Azure Service Bus
AZURE__SERVICEBUS__CONNECTIONSTRING="Endpoint=sb://your-namespace.servicebus.windows.net/..."
# JWT Settings
JWT__KEY="your-super-secret-key"
JWT__ISSUER="https://localhost:5001"
JWT__AUDIENCE="bank-system-api"
Each microservice exposes its own OpenAPI/Scalar documentation:
- Security API:
https://localhost:5001/scalar
- Account API:
https://localhost:5002/scalar
- Transaction API:
https://localhost:5003/scalar
- Movement API:
https://localhost:5004/scalar
- Notification API:
https://localhost:5005/scalar
- Reporting API:
https://localhost:5006/scalar
Basic unit test execution:
dotnet test
Run unit tests with code coverage (recommended):
# Use the provided PowerShell script
./scripts/run-unit-tests.ps1
This will:
- Run all unit test projects in the solution
- Generate code coverage reports in multiple formats (HTML, Cobertura, JSON)
- Open the HTML coverage report automatically
- Results are saved to
TestResults/
directory
Manual coverage command:
dotnet test --configuration Debug --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory TestResults /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/coverage.cobertura.xml
dotnet test --configuration Release --filter Category=Integration
# Using k6 or Azure Load Testing
k6 run tests/load/transaction-load-test.js
See scripts/README.md for detailed information about available build and test scripts.
# Deploy infrastructure
terraform apply -var-file="environments/prod.tfvars"
# Deploy applications
az acr build --registry bankSystemRegistry --image security-service:latest ./src/services/Security
az containerapp update --name security-service --image bankSystemRegistry.azurecr.io/security-service:latest
- Application Insights: Performance monitoring and telemetry
- Azure Monitor: Infrastructure monitoring
- Structured Logging: Centralized logging with Serilog
- Health Checks: Service health monitoring
- Distributed Tracing: Request flow tracking
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Follow the Development Guidelines
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.