# ingluispalacio/task-manager-api architecture

> Architecture diagram of the GitHub repository ingluispalacio/task-manager-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ingluispalacio/task-manager-api
- Repository: https://github.com/ingluispalacio/task-manager-api

## Overview

#### 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: [`src/main.ts`](https://github.com/ingluispalacio/task-manager-api/blob/main/src/main.ts) (NestJS API), [`src/app.module.ts`](https://github.com/ingluispalacio/task-manager-api/blob/main/src/app.module.ts) (App module), [`src/common/database/data-source.ts`](https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/database/data-source.ts) (TypeORM data source), [`src/modules/auth/presentation/auth.controller.ts`](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/presentation/auth.controller.ts) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_container["Container deployment<br/>Docker assets<br/>[docker-compose.yml]"]
  node_api{{"NestJS API<br/>Node service<br/>[main.ts]"}}
  node_app_module["App module<br/>root composition<br/>[app.module.ts]"]
  node_error_filter["HTTP error filter<br/>exception translation"]
  node_logger["Logger setup<br/>shared logging<br/>[logger.config.ts]"]
end

subgraph group_auth["Authentication"]
  node_auth_controller["Auth routes<br/>REST controller<br/>[auth.controller.ts]"]
  node_auth_use_cases["Identity use cases<br/>application layer"]
  node_jwt_strategy["JWT strategy<br/>auth guard<br/>[jwt.strategy.ts]"]
  node_user_repository["User repository<br/>domain contract + adapter<br/>[user.repository.ts]"]
end

subgraph group_tasks["Task lifecycle"]
  node_tasks_controller["Task routes<br/>REST controller"]
  node_task_use_cases["Task use cases<br/>application layer"]
  node_task_repository["Task repository<br/>domain contract<br/>[task.repository.ts]"]
end

subgraph group_persistence["Persistence"]
  node_typeorm_adapters["TypeORM adapters<br/>repository adapters"]
  node_data_source["TypeORM data source<br/>database initialization<br/>[data-source.ts]"]
  node_migrations["Schema migrations<br/>schema history"]
  node_postgres[("PostgreSQL<br/>external database")]
end

node_container -->|"runs"| node_api
node_container -->|"provisions"| node_postgres
node_api -->|"boots"| node_app_module
node_api -->|"uses"| node_error_filter
node_api -->|"configures"| node_logger
node_app_module -->|"includes"| node_auth_controller
node_app_module -->|"includes"| node_tasks_controller
node_app_module -->|"configures"| node_data_source
node_auth_controller -->|"dispatches"| node_auth_use_cases
node_auth_controller -->|"protects profile"| node_jwt_strategy
node_tasks_controller -->|"requires identity"| node_jwt_strategy
node_tasks_controller -->|"dispatches"| node_task_use_cases
node_auth_use_cases -->|"depends on"| node_user_repository
node_task_use_cases -->|"depends on"| node_task_repository
node_user_repository -.->|"implemented by"| node_typeorm_adapters
node_task_repository -.->|"implemented by"| node_typeorm_adapters
node_typeorm_adapters -->|"uses"| node_data_source
node_data_source -->|"applies"| node_migrations
node_data_source -->|"connects to"| node_postgres
node_task_use_cases -.->|"relies on soft delete"| node_migrations

click node_container "https://github.com/ingluispalacio/task-manager-api/blob/main/docker-compose.yml"
click node_api "https://github.com/ingluispalacio/task-manager-api/blob/main/src/main.ts"
click node_app_module "https://github.com/ingluispalacio/task-manager-api/blob/main/src/app.module.ts"
click node_error_filter "https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/filters/http-exception.filter.ts"
click node_logger "https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/logger/logger.config.ts"
click node_auth_controller "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/presentation/auth.controller.ts"
click node_auth_use_cases "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/application/use-cases/login-user.use-case.ts"
click node_jwt_strategy "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/infrastructure/strategies/jwt.strategy.ts"
click node_user_repository "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/domain/user.repository.ts"
click node_tasks_controller "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/presentation/tasks.controller.ts"
click node_task_use_cases "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/application/use-cases/create-task.use-case.ts"
click node_task_repository "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/domain/task.repository.ts"
click node_typeorm_adapters "https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/infrastructure/repositories/typeorm-task.repository.ts"
click node_data_source "https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/database/data-source.ts"
click node_migrations "https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_container,node_api,node_app_module,node_error_filter,node_logger toneBlue
class node_auth_controller,node_auth_use_cases,node_jwt_strategy,node_user_repository toneAmber
class node_tasks_controller,node_task_use_cases,node_task_repository toneMint
class node_typeorm_adapters,node_data_source,node_migrations,node_postgres toneRose
```

## Components

### Runtime

- [Container deployment](https://github.com/ingluispalacio/task-manager-api/blob/main/docker-compose.yml): Docker assets · Builds the API and provisions local PostgreSQL. · `docker-compose.yml`
- [NestJS API](https://github.com/ingluispalacio/task-manager-api/blob/main/src/main.ts): Node service · Authenticated REST API with Swagger at /docs. · `src/main.ts`
- [App module](https://github.com/ingluispalacio/task-manager-api/blob/main/src/app.module.ts): root composition · `src/app.module.ts`
- [HTTP error filter](https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/filters/http-exception.filter.ts): exception translation · Maps domain failures to consistent HTTP responses. · `src/common/filters/http-exception.filter.ts`
- [Logger setup](https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/logger/logger.config.ts): shared logging · `src/common/logger/logger.config.ts`

### Authentication

- [Auth routes](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/presentation/auth.controller.ts): REST controller · Handles registration, login, and profile requests. · `src/modules/auth/presentation/auth.controller.ts`
- [Identity use cases](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/application/use-cases/login-user.use-case.ts): application layer · Registers users, issues JWTs, and retrieves profiles. · `src/modules/auth/application/use-cases/login-user.use-case.ts`
- [JWT strategy](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/infrastructure/strategies/jwt.strategy.ts): auth guard · Validates bearer tokens and resolves request identity. · `src/modules/auth/infrastructure/strategies/jwt.strategy.ts`
- [User repository](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/auth/domain/user.repository.ts): domain contract + adapter · Application-facing user persistence abstraction implemented with TypeORM. · `src/modules/auth/domain/user.repository.ts`

### Task lifecycle

- [Task routes](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/presentation/tasks.controller.ts): REST controller · Protected CRUD endpoint ingress. · `src/modules/tasks/presentation/tasks.controller.ts`
- [Task use cases](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/application/use-cases/create-task.use-case.ts): application layer · Creates, lists, reads, updates, and soft-deletes tasks. · `src/modules/tasks/application/use-cases/create-task.use-case.ts`
- [Task repository](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/domain/task.repository.ts): domain contract · Keeps task use cases isolated from TypeORM. · `src/modules/tasks/domain/task.repository.ts`

### Persistence

- [TypeORM adapters](https://github.com/ingluispalacio/task-manager-api/blob/main/src/modules/tasks/infrastructure/repositories/typeorm-task.repository.ts): repository adapters · Maps user and task domain operations to entities. · `src/modules/tasks/infrastructure/repositories/typeorm-task.repository.ts`
- [TypeORM data source](https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/database/data-source.ts): database initialization · Configures database connectivity and migrations. · `src/common/database/data-source.ts`
- [Schema migrations](https://github.com/ingluispalacio/task-manager-api/blob/main/src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts): schema history · Includes task soft-delete schema support. · `src/common/database/migrations/1783715231019-AddSoftDeleteToTasks.ts`
- **PostgreSQL**: external database

## Connections

- 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
