TransferHub is an HTTP API that exposes endpoints for participant registration, individual account deposits, statements, and transfers between participants. My intention with TransferHub is to showcase a production-level project on GitHub, utilizing the tools with which I have the most experience.
Feel free to leave suggestions or to make a contribution.
The project is using .NET 8 with Minimal APIs and PostgreSQL for the database. It has unit and integration tests using NUnit and uses some common libraries from the .NET ecosystem like Entity Framework, Fluent Validation, Fluent Assertions and Bogus.
For the integration tests, it uses the built-in WebApplicationFactory
from .NET and uses TestContainers to spin up a PostgreSQL Docker container.
As for database migrations, I've opted to create a separate project that acts as a Command Line Tool, facilitating the process of running migrations on a pipeline. The project is using Fluent Migrator to describe and execute the migrations.
This project offers support for running inside Kubernetes, it has a Helm chart for the API inside the helm
folder.
This project can run locally in two ways:
The first way would be running the project inside a local Kubernetes cluster using Kind and Kindxt. In order to run using this option you need Docker, Helm, Kind, Kindxt and Powershell.
First, open a terminal. Then navigate to the scripts
folder and run the kind-dev-up.ps1
script. After running the script, open your browser at http://localhost:8080/transfer-hub/swagger/index.html
.
kind-dev-up.ps1
The script has the following steps to get the dev environment up and running:
- Create the Kubernetes cluster using Kindxt with two dependencies: Nginx Ingress and PostgreSQL
- Build the API Docker image
- Load the image to Kind
- Execute the migrations pointing to the PostgreSQL database inside the Kubernetes cluster.
- Install the API helm chart
This is an easier way of setting up the environment and it requires Docker and Powershell only. This option exclusively runs a PostgreSQL docker container and the migrations, so you can run the API using Visual Studio or the .NET CLI using the dotnet run
command.
First, open a terminal. Then navigate to the scripts
folder and run the db-up.ps1
script.
db-up.ps1
This diagram shows all the dependencies and how they interact, the Domain layer is isolated to promote maintainability and testability. As for database interactions, only the infrastructure and the migrations project can create database connections.
Creates a new participant.
POST /api/v1/participants
Gets a statement with transactions from a participant.
GET /api/v1/participants/{id}/statement?page=1&pageSize=20
Creates a new deposit for a participant.
POST /api/v1/transactions/credit
Transfers money from one participant to another.
POST /api/v1/transactions/transfer
- Create Load Testing scripts using K6. My goal is to learn some strategies for load testing and how to execute them.
- Create a production environment using Terraform on Azure. I want to learn how to use an infrastructure-as-code tool, and Terraform looks like a good option.
MIT License © Lucas Rufo