PouryaKit
Get started

Your first Host

Generate the monolith, start PostgreSQL, migrate, create a token, run the Host and call it.

What it is

The shortest path from an installed template package to a running Host that answers an authenticated call. It uses the monolith template, whose one Module is the Proving Sample's Catalog; the modular monolith runs the same way with more Modules to migrate.

The Host applies no migrations

Migrating is a step of its own, dotnet ef database update, run once per Module before the Host starts and again after each new migration. The Host also needs a bearer token's settings to start, which dotnet user-jwts writes for development.

When to use it

Right after you install the templates, with Docker running. Run each command from the folder you want the solution in, then from the solution's own folder as the steps say.

Run it

Generate the solution and restore its tools

Terminal
dotnet new pouryakit-monolith -n Acme.Shop
cd Acme.Shop
dotnet tool restore

Start PostgreSQL

The connection string in the generated appsettings.json reaches this container.

Terminal
docker run -d --name acme-shop-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:18.6

Migrate Catalog's database

The database need not exist: the update creates it before it applies the first migration.

Terminal
dotnet ef database update --project src/Modules/Catalog/Catalog --startup-project src/Acme.Shop.Host --context CatalogDbContext

Create a development token

It writes the bearer settings the Host needs and prints a token. The tenant claim matters: Catalog is tenant-scoped, so its commands and queries refuse a caller without a tenant.

Terminal
dotnet user-jwts create --project src/Acme.Shop.Host --claim tenant=acme

Run the Host

Trust ASP.NET Core's development certificate once per machine, since the https URL uses it, then run.

Terminal
dotnet dev-certs https --trust
dotnet run --project src/Acme.Shop.Host

It listens on its launch profile's https and http URLs, which Running the generated Host lists.

Call it

In a second terminal, with the token from the step before. The answer is 200 with an empty Page of products.

Terminal
curl -H "Authorization: Bearer <token>" http://localhost:5080/catalog/v2/products

In Development the Host also serves its OpenAPI documents and the Scalar reference over them: Documents and Scalar.

Run the smoke test

The generated test project hosts the same Host against PostgreSQL in a container of its own, so it needs Docker but not the container above.

Terminal
dotnet test --project tests/Acme.Shop.Tests/Acme.Shop.Tests.csproj

When you are done, remove the container and its data:

Terminal
docker rm -f -v acme-shop-postgres

What the smoke test proves

BehaviourStated in
A product created twice with one idempotency key is created once, and both calls get the same answerThe smoke test
The liveness endpoint answers a caller without a token from a Host composed as it is deployedThe smoke test
A Host whose permission checks are not registered does not buildThe smoke test

Failure messages

Next steps

On this page