The project was built as a test solution for further practical exploration of the capabilities of MassTransit in combination with RabbitMQ, as well as .NET8 Minimal API and FluentAssertions with xUnit.
The solution consists of two services SuperTracker.PixelApi and SuperTracker.Storage communicating with each other using MassTransit and RabbitMQ Transport underneath.
.NET 8 Minimal API with just one endpoint, GET /track
, which captures certain information from the request (Referrer
& User-Agent
headers + Visitor IP
), publishes the corresponding notification in MassTransit containing this information, and returns a 'dummy' 1-pixel GIF image as a response.
.NET 8 service responsible for consuming and processing notifications from the SuperTracker.PixelApi service, ensuring the thread-safe storage of the received information in a log file.
- Make sure you have RabbitMQ up and running.
- Replace the corresponding RabbitMQ settings in
src/SuperTracker.PixelApi/appsettings.json
andsrc/SuperTracker.Storage/appsettings.json
. - Run the Api service:
dotnet run --project "src/SuperTracker.PixelApi"
- Run the Storage service:
dotnet run --project "src/SuperTracker.Storage"
- Open
requests/PixelTrack/PixelTrack.http
and send requests toGET /track
directly from VS Code (REST Client Extension is needed).
...Or with just a single command using docker-compose: docker-compose up
Both services are covered by unit tests using xUnit. Other types of tests were omitted for simplicity. To run the tests, execute the following commands:
dotnet test "tests/SuperTracker.PixelApi.UnitTests"
dotnet test "tests/SuperTracker.Storage.UnitTests"
Both services contain Dockerfiles with build and runtime split into two stages. To build Docker images, execute the following commands:
docker build -t supertracker.storage -f "src/SuperTracker.Storage/Dockerfile" .
docker build -t supertracker.pixelapi -f "src/SuperTracker.PixelApi/Dockerfile" .