← Back to archive

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:

  1. Start the supporting services: docker-compose -f docker-compose.local.yaml up -d (PostgreSQL and Minio, with credentials in ./env).
  2. Install dependencies with npm install and build with npm run build.
  3. Configure the app via environment variables listed in ./env/local.app.env.
  4. Run with npm run start, or npm run start:local to auto-load the local env file. The API documentation is then served at http://localhost:3005/documentation/.
  5. Lint with npm run lint.
  6. Run tests by first preparing the test stack with docker-compose -f docker-compose.test.yaml up -d, then npm run test, or npm run test:cov for 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.