How guid-dev/nestjs-fastify-typeorm works
Project Type and Purpose
• Full-stack backend service (no distinct “frontend” here).
• Uses NestJS as the framework with Fastify as HTTP adapter, TypeORM for persistence, and PostgreSQL via Docker.
• Layered architecture (Presentation → Application → Infrastructure).
File Structure
• Top-level: configuration files (Dockerfiles, Nest CLI, ESLint, tsconfig), source folder (src/), tests, Makefile.
• src/ subdivided into:
• presentation/ – HTTP controllers (entry points).
• application/ – business logic services.
• infra/ – data layer, TypeORM entities, database config.
• Cross-cutting: logger.middleware.ts, constants.ts.
• docker/ holds Dockerfiles for development and PostgreSQL.
README
• Confirms purpose: exercise and validate knowledge of NestJS + Fastify + TypeORM stack.
• No pre-drawn architecture, so we must derive from code structure.
Main Components & Interactions
a. Components
• Fastify HTTP Server (NestJS adapter)
• NestJS Application Module (wires components)
• Presentation Layer: HotelController
• Application Layer: HotelService
• Infrastructure Layer: TypeORM Repository wrapping HotelEntity
• PostgreSQL Database (Docker container)
• Cross-cutting Middleware: Logger
• External: Docker environment, test harness.
b. Relationships/Data Flow
1. Client → HTTP Request → Fastify Server
2. Fastify → NestJS Router → HotelController
3. Controller calls HotelService (application logic)
4. HotelService uses TypeORM Repository (in infra layer)
5. Repository → PostgreSQL via database driver
6. Response travels back up to controller → client
7. LoggerMiddleware intercepts incoming requests
c. Architectural Patterns/Principles
• Layered (Separation of concerns)
• Dependency Injection (NestJS modules)
• Domain-Driven Structure (entities in infra, services in application)
• Containerization (Docker).
d. Key Technologies/Libraries
• NestJS (app framework)
• Fastify (HTTP adapter)
• TypeORM (ORM)
• PostgreSQL
• Docker & Docker-compose/Makefile orchestration
Detail
• Port mappings (e.g., 3000:80 on Docker).