Bank Microservice
This microservice provides banking functionalities through a clean architecture approach, utilizing Domain-Driven Design (DDD) principles, built using the latest version of .NET Core i.e. .NET 8.0
Features
- Create a new bank account
- Retrieve an existing bank account
- Activate an existing bank account
- Deactivate an existing bank account
Technologies Used
Solution Structure
π bank/
β
βββ src/
β βββ Payment.Bank.Api/
β β βββ Controllers/
β β βββ Extensions/
β β βββ Middlewares/
β β βββ Options/
β β βββ Swagger/
β β βββ Program.cs
β β βββ appsettings.json
β β βββ Startup.cs
β β
β βββ Payment.Bank.Application/
β β βββ Accounts/
β β βββ Features/
β β β βββ ActivateAccount/
β β β βββ CreateAccount/
β β β βββ DeactivateAccount/
β β β βββ GetAccount/
β β βββ Repositories/
β β βββ Services/
β β
β βββ Payment.Bank.Common/
β β βββ Abstractions/
β β βββ Exceptions/
β β βββ Extensions/
β β βββ Mappers/
β β βββ Utilities/
β β
β βββ Payment.Bank.Domain/
β β βββ Entities/
β β βββ Exceptions/
β β βββ ValueObjects/
β β
β βββ Payment.Bank.Infrastructure/
β βββ Repositories/
β
βββ README.md
βββ LICENSE
βββ .gitignore
Getting Started
Prerequisites
- .NET Core SDK 8.0
- Docker installed on your machine.
Installation
Clone the repository:
git clone https://github.com/salzaki/bank.git
Navigate to the project directory:
cd bank
Makefile Reference
build-docs π¨ Builds docs on local machine
check-certs π Checks development certs
check π Checks installed dependencies on local machine
clean-certs π€ Cleans up development certs
clean-docs π§Ή Cleans docs site
clean π§Ή Cleans up project
docker-build π Builds container using Docker compose
docker-lint π³ Lints Dockerfile
docker-start π Stars container using Docker compose
docker-stop π Stops container using Docker compose
help π¬ This help message
install-certs π Installs development certs
install-docs π οΈ Installs necessary dependencies to build docs in Ruby
lint-fix π§ Lints & formats, fixes errors and modifies code
lint π Checks for linting and formatting errors in code
run-docs π€ Runs project docs (this listens for changes)
serve-docs ποΈ Runs project docs (this does not listen for changes)
Quick Start
Build the project using make, from the root of the project run:
make check-certs # run this to check is dev certs are installed
make install-certs # install dev certs
make docker-start
Config Certificate
You can also configure certs manually by running the following commands to Configure SSL in your system:
Windows using Linux containers
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p password
dotnet dev-certs https --trust
Note: for running this command in powershell use $env:USERPROFILE instead of %USERPROFILE%
macOS or Linux
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p $CREDENTIAL_PLACEHOLDER$
dotnet dev-certs https --trust

AppSettings
Api Settings
"Api": {
"Name": "Bank-Api",
"Version": "1.0",
"ApiVersionHeader": "x-api-version",
"ReportApiVersions": true,
"BaseUrl": "/api",
"DocumentationUrl": "api/v1/documentation/",
"BannerEnabled": true,
"Authorization": {
"ApiKey": "607F6A23-D130-46CD-A93C-6D9A6E5A8FB2"
}
}
Swagger Settings
"Swagger": {
"Enabled": true,
"Name": "Bank-Api",
"RoutePrefix": "api-docs",
"RouteTemplate": "/api-docs/swagger/{documentName}/swagger.json",
"EndpointPath": "/api-docs/swagger/{0}/swagger.json",
"Info": {
"Title": "Bank Api documentation",
"Description": "Provides documentation for Bank Api.",
"License": {
"Name": "MIT License",
"Url": "https://en.wikipedia.org/wiki/MIT_License"
},
"Contact": {
"Name": "Sal Zaki",
"Email": "salzaki@hotmail.com"
}
}
}
Feature Management Settings
"FeatureManagement": {
"CreateAccount": true,
"GetAccount": true,
"DeactivateAccount": true,
"ActivateAccount": true
}
Account Controller with Feature Gate
[HttpGet("{accountNumber:int}", Name = "GetByAccountNumber")]
[FeatureGate(Constants.Features.GetAccount)]
[SwaggerOperation(
OperationId = nameof(GetByAccountNumberAsync),
Description = "Gets an account by account number.",
Tags = ["Account"])]
[SwaggerResponse(StatusCodes.Status200OK, Type = typeof(GetAccountResponse))]
[SwaggerResponse(StatusCodes.Status400BadRequest, Type = typeof(BadRequest<ProblemDetails>))]
[SwaggerResponse(StatusCodes.Status404NotFound, Type = typeof(NotFound))]
[SwaggerResponse(StatusCodes.Status500InternalServerError, Type = typeof(ProblemDetails))]
public async Task<Results<Ok<GetAccountResponse>, BadRequest<ProblemDetails>, NotFound>> GetByAccountNumberAsync(
[FromServices] IAccountService accountService,
[Required][FromRoute] int accountNumber,
CancellationToken cancellationToken = default)
{
...
}
Business Policies - Not implemented Yet
public void Deposit(decimal amount)
{
this.CheckPolicy(DepositCannotBeMadeToDeactivatedAccountPolicy);
this.AccountBalance += amount;
}
Api Documentation
Structured Logging


Roadmap
List of features/tasks/approaches to add:
| Name | Status | Release date |
|---|---|---|
| Domain Unit Tests | To do | TBA |
| Application Unit Tests | To do | TBA |
| Integration Automated Tests | To do | TBA |
Resources and References
Seq
Domain-Driven Design
- βDomain-Driven Design: Tackling Complexity in the Heart of Softwareβ book, Eric Evans
- βImplementing Domain-Driven Designβ book, Vaughn Vernon
- βDomain-Driven Design Distilledβ book, Vaughn Vernon
- βPatterns, Principles, and Practices of Domain-Driven Designβ book, Scott Millett, Nick Tune
Application Architecture
- βPatterns of Enterprise Application Architectureβ book, Martin Fowler
- βDependency Injection Principles, Practices, and Patternsβ book, Steven van Deursen, Mark Seemann
- βClean Architecture: A Craftsmanβs Guide to Software Structure and Design (Robert C. Martin Seriesβ book, Robert C. Martin
- βThe Clean Architectureβ article, Robert C. Martin
License
Fun Quote
As you start to walk on the way, the way appears.