Skip to content

SalZaki/Bank

Repository files navigation

Commitizen friendly

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

dotnet docker seq

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

Open https://localhost:5001

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

Docker

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;
}

Structured Logging

Seq

Seq

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

Application Architecture

License

Fun Quote

As you start to walk on the way, the way appears.

Rumi

About

Bank Microservice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published