C# Backend Development: Minimal APIs & PostgreSQL
A self-study course on backend development in C#. You’ll build a complete REST API running entirely on your own computer — no cloud accounts needed — but the technology and structure is the same as when developing for cloud deployment.
This material was originally written for 4th-semester engineering students at Aarhus University working on a telemedicine project that needed a backend server and database. It’s equally useful as a standalone introduction to backend development. It’s also on GitHub — comments and improvement suggestions are welcome.
What you’ll build
Section titled “What you’ll build”CLIENT (Browser/Postman) ↓ HTTP Requests (JSON)ASP.NET CORE MINIMAL API ├─ Authentication (JWT) ├─ Endpoints (/books, /authors, /auth) ├─ Validation (Data Annotations) └─ Entity Framework Core ↓ SQLPOSTGRESQL DATABASE (Docker) ├─ Users table ├─ Books table └─ Authors tableThe tech stack used is something you’ll also find in the software industry:
- ASP.NET Core 8
- PostgreSQL 16
- Entity Framework Core
- JWT
- xUnit
- Docker Compose
Prerequisites
Section titled “Prerequisites”- C# basics (classes, methods, LINQ)
- HTTP basics (GET, POST, PUT, DELETE)
- JSON format
- Command line basics
No prior experience with databases, Docker, or APIs is required.
Course structure
Section titled “Course structure”Install all required tools before starting Week 1. Takes about 30–60 minutes.
Build a Books API with in-memory storage. Learn endpoints, routing, status codes, and Swagger.
- Deliverable: CRUD API running locally in Swagger
- Key skills:
app.MapGet(),Resultshelper, route parameters
Replace the in-memory list with a real PostgreSQL database running in Docker.
- Deliverable: Books API backed by PostgreSQL with an Authors table
- Key skills: Docker, DbContext, EF Core migrations, one-to-many relationships
Add Data Annotations to entities. Optionally complete validation error responses and pagination now, or defer them to the extension page before the capstone.
- Mandatory core: Data Annotations on all entities (1–2 hours)
- Extension (now or later): Structured validation responses,
pagination with
Skip()/Take() - Key skills: Data Annotations,
Results.ValidationProblem(), query parameters
Standalone page covering validation error responses and pagination. Complete this before starting the capstone if it was deferred in Week 5.
Add user registration and login. Protect write endpoints so only logged-in users can use them.
- Deliverable: Users can register and login; write endpoints require a JWT token
- Key skills: BCrypt, JWT generation,
.RequireAuthorization()
Write integration tests using WebApplicationFactory and an in-memory database.
- Deliverable: Test project with 5–8 passing integration tests
- Key skills: xUnit, WebApplicationFactory, in-memory database, HttpClient testing
Containerize the full application so it starts with a single command.
- Deliverable:
docker-compose upruns everything; Swagger has descriptions - Key skills: Dockerfile, docker-compose.yml, Swagger descriptions
Build a complete API from scratch applying all course skills. Choose from Blog API, Task Tracker, or Recipe App.
- Deliverable: Working API with authentication, tests, and Docker deployment
- Minimum: 3 entities, user authentication, 5 passing tests, runs in Docker
What to learn after completing the course. Includes code organization, advanced auth, complex databases, production features, and DevOps.
Priority summary
Section titled “Priority summary”| Priority | Skills |
|---|---|
| Must know | Minimal API endpoints, PostgreSQL in Docker, EF Core CRUD, JWT auth, Docker Compose |
| Should know | Data validation, pagination, basic testing, one-to-many relationships, Swagger |
| Nice to know | Code organization, logging, search and filter |
| Learn later | Roles and policies, unit testing with Moq, performance, production deployment |