Repo of the Day
pvarentsov/typescript-clean-architecture
Published: Mar 1, 2024
Open repository ↗Clean Architecture based application in TypeScript. Could be useful for looking at for codestuff-api work.
Summary
typescript-clean-architecture is a TypeScript sample back-end that demonstrates how to structure a Node.js project around Clean Architecture principles. It implements a fictional "IPoster" service, where users can register, authors can manage media and posts, and guests can read published posts, and it is built on NestJS with TypeORM and PostgreSQL.
What it is useful for
The repository works as a reference for engineers who want to see Clean Architecture applied to a TypeScript back-end rather than only read about it. The IPoster domain is small but representative: three entities (User, Post, Media) and a documented set of use cases, such as creating a Guest or Author account, editing own Media, attaching an image Media to a draft Post, publishing a Post, and listing published Posts for both Authors and Guests.
The listed topics (clean-architecture, clean-code, e2e-testing, unit-testing, nestjs, typeorm, nodejs, typescript) indicate it is intended as a template for separating domain logic from persistence and adapters, not as a production SaaS. The project is released under the MIT license and includes both unit and end-to-end testing scripts, so it can be cloned, read, and adapted as a starting point by teams evaluating Clean Architecture in a Node.js stack.
How engineers can use it
The README documents a Docker-plus-npm local workflow:
- Start the supporting services:
docker-compose -f docker-compose.local.yaml up -d(PostgreSQL and Minio, with credentials in./env). - Install dependencies with
npm installand build withnpm run build. - Configure the app via environment variables listed in
./env/local.app.env. - Run with
npm run start, ornpm run start:localto auto-load the local env file. The API documentation is then served athttp://localhost:3005/documentation/. - Lint with
npm run lint. - Run tests by first preparing the test stack with
docker-compose -f docker-compose.test.yaml up -d, thennpm run test, ornpm run test:covfor coverage.
Launch and test configurations are also provided for IntelliJ IDEA and VSCode.
Documented limitations: the README only covers local development, and the project's own description calls it an "attempt" at Clean Architecture, so the code is best treated as illustrative. Production configuration, CI pipelines, and deployment steps are not described, so consult the source directly for anything beyond the local setup.