Series: Pokemon Api (14 posts)
- Part 1Project SetupAugust 31, 2026
Setting up the Cargo workspace, crates, git repo, rustfmt config, and Makefile the rest of the series builds on.
- Part 2ConfigurationAugust 31, 2026
Loading server config from the environment with envconfig, so nothing about the port or CORS rules lives in the binary.
- Part 3Setting Up the ServerAugust 31, 2026
Wiring the config from the last part into an Axum server, split across a binary entry point and a build_app function.
- Part 4Health ChecksAugust 31, 2026
A liveness endpoint the container orchestrator can poll before the service has any dependencies to check.
- Part 5MiddlewareAugust 31, 2026
Wiring CORS, request tracing, and a body size limit through tower-http, driven by the config we already loaded.
- Part 6Database Connection PoolingAugust 31, 2026
Adding a PostgreSQL connection pool with sqlx, config-driven like everything else, and running migrations on startup.
- Part 7Application StateAugust 31, 2026
Sharing the pool and config with every handler through Axum's typed state, and finally finishing the /readyz endpoint.
- Part 8The Repository LayerAugust 31, 2026
A trait-based repository in the pokemon_service crate, so the code that talks to Postgres never has to know it's serving HTTP.
- Part 9Service and Domain LogicAugust 31, 2026
A service layer that owns validation and business rules, depending on the repository trait instead of Postgres directly.
- Part 10HandlersAugust 31, 2026
The last layer: translating HTTP requests into service calls and service errors into status codes.
- Part 11OpenAPIAugust 31, 2026
Generating an OpenAPI schema and interactive docs from the handlers we already wrote, with utoipa.
- Part 12Error Handling & API ContractsAugust 31, 2026
Closing the gaps in ApiError so every failure, not just the ones the service produces, returns the same JSON shape.
- Part 13Docker & ProductionAugust 31, 2026
A pinned, multi-stage Dockerfile, graceful shutdown, and the gap between a container that runs and a service you could actually deploy.
- Part 14ObservabilityAugust 31, 2026
Request IDs and custom tracing spans, the two things Middleware explicitly deferred, plus structured logs for production.