Personal
project 7 of 7Architecture practice
Back-end pattern studies
Dec 2022 – Jun 2024 · 1y 7m · Author
Four small repositories that each try one back-end pattern in C# or TypeScript: a generic repository with a unit of work, CQRS with MediatR, a state machine read from the database and a repository over Prisma.
Highlights
- Repository and unit of work on EF Core: generic base classes that a concrete repository and unit of work extend.
- CQRS with MediatR in ASP.NET Core: controllers only send queries, and a handler per query calls the repository.
- State pattern in NestJS: the order of states is rows in the database, and each state name maps to a class.
- Repository pattern over Prisma in an Express API with JWT sign-in, request validation and a rate limit.
4
repos
26
commits
- C#
- ASP.NET Core (.NET 8)
- Entity Framework Core
- TypeScript
- Node.js
- NestJS
- Express
- Prisma
One pattern per repository
Each repository is small on purpose: enough code to wire one pattern end to end and see what it costs. The pictures are excerpts from the public source, copied as they are.
The C# pair covers data access. One has a generic repository and a unit of work on EF Core. The other puts MediatR between the controller and the repository, so a request becomes a query object with its own handler.
The NestJS study keeps a workflow's states as rows in the database. A transaction moves to the next state by sequence, and the state's name picks the class that handles it. The Prisma study hides the client behind a repository interface in an Express API.
The generic repository interface on EF Core. A controller that only sends queries to MediatR. Choosing the state class by a name stored in the database. A repository class over Prisma.