How ingluispalacio/task-manager-api works
Purpose and runtime
A NestJS REST API for authenticated task management. It runs as a Node.js service, exposes Swagger documentation at /docs, persists data in PostgreSQL through TypeORM, and uses JWT bearer authentication. Containerized local deployment is supported by Dockerfile and docker-compose.yml.
Entry/bootstrap points:
• src/main.ts
• src/app.module.ts
• src/common/database/data-source.ts
Application composition
AppModule composes the cross-cutting database setup and the two business modules:
• Authentication: src/modules/auth/auth.module.ts
• Tasks: src/modules/tasks/tasks.module.ts
• Root assembly: src/app.module.ts
The module boundary keeps auth identity concerns separate from task lifecycle concerns while allowing authenticated task operations to depend on the resolved user context.
HTTP API boundary
Controllers are the REST ingress layer. They accept request DTOs, invoke application use cases, and return response DTOs:
• Auth routes (register, login, me): src/modules/auth/presentation/auth.controller.ts
• Task CRUD routes: src/modules/tasks/presentation/tasks.controller.ts
• Request/response contracts: src/modules/auth/application/dto, src/modules/tasks/application/dto
Global exception translation is centralized so domain/application failures become consistent HTTP responses:
• src/common/filters/http-exception.filter.ts
• src/common/exceptions/domain.exception.ts
Authentication and identity flow
Registration and login route through dedicated use cases, which operate against the user repository abstraction. Login produces a JWT; protected requests are authenticated by the JWT strategy and provide identity for profile and task operations.
• Use cases: src/modules/auth/application/use-cases/register-user.use-case.ts, src/modules/auth/application/use-cases/login-user.use-case.ts, src/modules/auth/application/use-cases/get-profile.use-case.ts
• JWT validation boundary: src/modules/auth/infrastructure/strategies/jwt.strategy.ts
• Repository contract and adapter: src/modules/auth/domain/user.repository.ts, src/modules/auth/infrastructure/repositories/typeorm-user.repository.ts
Task lifecycle flow
Authenticated task requests enter TasksController, then dispatch to focused application use cases for create, list, get, update, or delete. Use cases depend on the task repository interface rather than TypeORM directly, preserving domain/application isolation from persistence.
• Controller: src/modules/tasks/presentation/tasks.controller.ts
• Core orchestration: src/modules/tasks/application/use-cases/create-task.use-case.ts, src/modules/tasks/application/use-cases/list-tasks.use-case.ts, src/modules/tasks/application/use-cases/update-task.use-case.ts
• Domain contract/model: src/modules/tasks/domain/task.repository.ts, src/modules/tasks/domain/task.model.ts
Delete behavior is architecturally significant: the schema includes a soft-delete migration, so deleted tasks are expected to remain persisted but excluded from normal access paths.
• src/modules/tasks/application/use-cases/delete-task.use-case.ts
• src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts
Persistence boundary and schema evolution
TypeORM adapters translate domain repository operations to PostgreSQL entities. Entities represent database mapping; migrations define the durable schema history and must be applied before service startup.
• User persistence: src/modules/auth/infrastructure/entities/user.entity.ts, src/modules/auth/infrastructure/repositories/typeorm-user.repository.ts
• Task persistence: src/modules/tasks/infrastructure/entities/task.entity.ts, src/modules/tasks/infrastructure/repositories/typeorm-task.repository.ts
• Schema history: src/common/database/migrations/1710000000000-InitialSchema.ts, src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts
Operational boundaries
Environment configuration supplies database and JWT settings; PostgreSQL is the required external service. Logging and error filtering are shared infrastructure rather than module-specific behavior.
• Database initialization: src/common/database/data-source.ts
• Logger setup: src/common/logger/logger.config.ts
• Environment template: .env.example
• Deployment assets: Dockerfile, docker-compose.yml
Main entry points: main.ts NestJS API · app.module.ts App module · data-source.ts TypeORM data source · auth.controller.ts Auth routes
Components 16
Runtime
- Container deployment · Builds the API and provisions local PostgreSQL.
docker-compose.yml - NestJS API · Authenticated REST API with Swagger at /docs.
src/main.ts - App module
src/app.module.ts - HTTP error filter · Maps domain failures to consistent HTTP responses.
src/common/filters/http-exception.filter.ts - Logger setup
src/common/logger/logger.config.ts
Authentication
- Auth routes · Handles registration, login, and profile requests.
src/modules/auth/presentation/auth.controller.ts - Identity use cases · Registers users, issues JWTs, and retrieves profiles.
src/modules/auth/application/use-cases/login-user.use-case.ts - JWT strategy · Validates bearer tokens and resolves request identity.
src/modules/auth/infrastructure/strategies/jwt.strategy.ts - User repository · Application-facing user persistence abstraction implemented with TypeORM.
src/modules/auth/domain/user.repository.ts
Task lifecycle
- Task routes · Protected CRUD endpoint ingress.
src/modules/tasks/presentation/tasks.controller.ts - Task use cases · Creates, lists, reads, updates, and soft-deletes tasks.
src/modules/tasks/application/use-cases/create-task.use-case.ts - Task repository · Keeps task use cases isolated from TypeORM.
src/modules/tasks/domain/task.repository.ts
Persistence
- TypeORM adapters · Maps user and task domain operations to entities.
src/modules/tasks/infrastructure/repositories/typeorm-task.repository.ts - TypeORM data source · Configures database connectivity and migrations.
src/common/database/data-source.ts - Schema migrations · Includes task soft-delete schema support.
src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts - PostgreSQL
Connections 20
- Container deployment → NestJS API: runs
- Container deployment → PostgreSQL: provisions
- NestJS API → App module: boots
- NestJS API → HTTP error filter: uses
- NestJS API → Logger setup: configures
- App module → Auth routes: includes
- App module → Task routes: includes
- App module → TypeORM data source: configures
- Auth routes → Identity use cases: dispatches
- Auth routes → JWT strategy: protects profile
- Task routes → JWT strategy: requires identity
- Task routes → Task use cases: dispatches
- Identity use cases → User repository: depends on
- Task use cases → Task repository: depends on
- User repository → TypeORM adapters: implemented by
- Task repository → TypeORM adapters: implemented by
- TypeORM adapters → TypeORM data source: uses
- TypeORM data source → Schema migrations: applies
- TypeORM data source → PostgreSQL: connects to
- Task use cases → Schema migrations: relies on soft delete