# cristiant71/task-master-api architecture

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

- Interactive diagram: https://gitdiagram.com/cristiant71/task-master-api
- Repository: https://github.com/cristiant71/task-master-api

## Overview

1. **Repository type and shape**  
   This is a single NestJS backend service, not a multi-service system. It exposes a REST API for managing **users** and **tasks**, with PostgreSQL as the persistent store and TypeORM as the ORM layer.

2. **Application entrypoint and API boundary**  
   `src/main.ts` is the bootstrap point. In a typical NestJS setup like this one, it creates the HTTP server, applies global configuration, and exposes the API under the `/api` prefix mentioned in the README. That makes the HTTP layer the outermost boundary of the system.

3. **Top-level composition**  
   `src/app.module.ts` is the root composition module. It wires together the feature modules, primarily `UserModule` and `TaskModule`, and serves as the central place where the application’s subsystems are registered.

4. **User feature subsystem**  
   `src/user/user.controller.ts`, `src/user/user.service.ts`, `src/user/user.module.ts`, and the files under `src/user/dto` and `src/user/entities` form the user bounded context.  
   - The **controller** handles REST endpoints.  
   - The **service** contains the application logic.  
   - The **entity** defines the TypeORM model for persistence.  
   - The **DTOs** define the input/output contract for create/update operations.

5. **Task feature subsystem**  
   `src/task/task.controller.ts`, `src/task/task.service.ts`, `src/task/task.module.ts`, and the matching DTO/entity folders implement the task side of the API. This follows the same controller-service-entity-DTO pattern as users, which keeps the architecture consistent across both domains.

6. **Relationship between users and tasks**  
   The README explicitly says there is a **ManyToOne** relationship between `Task` and `User`. Architecturally, this means tasks are not standalone records: each task is associated with one user, while a user can own many tasks. This relationship is modeled in the TypeORM entities and enforced through the service layer when creating or updating tasks.

7. **Validation and request contracts**  
   The DTO folders indicate the API uses explicit request models for create/update flows, and the README notes **class-validator**. That means validation is handled at the boundary before data reaches the services, helping keep business logic free from raw request parsing concerns.

8. **Persistence layer**  
   The `entities` directories are the persistence models, and TypeORM is the bridge between NestJS services and PostgreSQL. The architecture is therefore a fairly standard layered flow: **HTTP controller → service → TypeORM entity/repository → PostgreSQL**.

9. **Infrastructure and runtime dependencies**  
   `docker-compose.yml` is the main infrastructure artifact and is used to run PostgreSQL locally. This means the app depends on an external database service at runtime, but the database setup is packaged for local development and likely for repeatable onboarding.

10. **Testing boundary**  
   `test/app.e2e-spec.ts` and `test/jest-e2e.json` show there is at least one end-to-end test suite using Jest. These tests validate the full stack behavior through the HTTP boundary rather than only unit-testing isolated services.

11. **Tooling and project conventions**  
   The presence of `nest-cli.json`, `tsconfig*.json`, `eslint.config.mjs`, and `.prettierrc` shows a standard NestJS/TypeScript codebase with linting, formatting, and build tooling. These are supporting concerns, but they reinforce that the project is organized around Nest’s module-based architecture.

12. **Overall architectural diagram takeaway**  
   If you draw this repo, the key boxes are: **Client → NestJS API (/api) → Controllers → Services → TypeORM Entities/DB**, with two main feature modules (**User** and **Task**) and a direct **Task → User** many-to-one dependency in the data model. PostgreSQL sits outside the application boundary and is provisioned via Docker Compose.

Main entry points: [`src/app.module.ts`](https://github.com/cristiant71/task-master-api/blob/main/src/app.module.ts) (App module), [`src/user/user.module.ts`](https://github.com/cristiant71/task-master-api/blob/main/src/user/user.module.ts) (User module), [`src/task/task.module.ts`](https://github.com/cristiant71/task-master-api/blob/main/src/task/task.module.ts) (Task module), [`src/task/entities/task.entity.ts`](https://github.com/cristiant71/task-master-api/blob/main/src/task/entities/task.entity.ts) (Task model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_api["API<br/>http boundary<br/>[main.ts]"]
  node_main["Bootstrap<br/>[main.ts]"]
  node_app["App module<br/>root module<br/>[app.module.ts]"]
end

subgraph group_users["Users"]
  node_user_module["User module<br/>feature module<br/>[user.module.ts]"]
  node_user_controller["User controller<br/>REST controller<br/>[user.controller.ts]"]
  node_user_service["User service<br/>application service<br/>[user.service.ts]"]
  node_user_model["User model<br/>typeorm entity<br/>[user.entity.ts]"]
end

subgraph group_tasks["Tasks"]
  node_task_module["Task module<br/>feature module<br/>[task.module.ts]"]
  node_task_controller["Task controller<br/>REST controller<br/>[task.controller.ts]"]
  node_task_service["Task service<br/>application service<br/>[task.service.ts]"]
  node_task_model["Task model<br/>typeorm entity<br/>[task.entity.ts]"]
end

subgraph group_data["Data"]
  node_postgres[("PostgreSQL<br/>database<br/>[docker-compose.yml]")]
end

subgraph group_quality["Quality"]
  node_e2e["E2E tests<br/>jest suite<br/>[app.e2e-spec.ts]"]
end

node_client(("Client<br/>external"))

node_client -->|"requests"| node_api
node_api -->|"bootstraps"| node_main
node_main -->|"loads"| node_app
node_app -->|"registers"| node_user_module
node_app -->|"registers"| node_task_module
node_user_module -->|"exposes"| node_user_controller
node_user_module -->|"provides"| node_user_service
node_task_module -->|"exposes"| node_task_controller
node_task_module -->|"provides"| node_task_service
node_user_controller -->|"delegates"| node_user_service
node_task_controller -->|"delegates"| node_task_service
node_user_service -->|"persists"| node_user_model
node_task_service -->|"persists"| node_task_model
node_task_model -->|"many-to-one"| node_user_model
node_user_model -.->|"stores in"| node_postgres
node_task_model -.->|"stores in"| node_postgres
node_e2e -.->|"verifies"| node_api

click node_api "https://github.com/cristiant71/task-master-api/blob/main/src/main.ts"
click node_main "https://github.com/cristiant71/task-master-api/blob/main/src/main.ts"
click node_app "https://github.com/cristiant71/task-master-api/blob/main/src/app.module.ts"
click node_user_module "https://github.com/cristiant71/task-master-api/blob/main/src/user/user.module.ts"
click node_user_controller "https://github.com/cristiant71/task-master-api/blob/main/src/user/user.controller.ts"
click node_user_service "https://github.com/cristiant71/task-master-api/blob/main/src/user/user.service.ts"
click node_user_model "https://github.com/cristiant71/task-master-api/blob/main/src/user/entities/user.entity.ts"
click node_task_module "https://github.com/cristiant71/task-master-api/blob/main/src/task/task.module.ts"
click node_task_controller "https://github.com/cristiant71/task-master-api/blob/main/src/task/task.controller.ts"
click node_task_service "https://github.com/cristiant71/task-master-api/blob/main/src/task/task.service.ts"
click node_task_model "https://github.com/cristiant71/task-master-api/blob/main/src/task/entities/task.entity.ts"
click node_postgres "https://github.com/cristiant71/task-master-api/blob/main/docker-compose.yml"
click node_e2e "https://github.com/cristiant71/task-master-api/blob/main/test/app.e2e-spec.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_api,node_main,node_app toneBlue
class node_user_module,node_user_controller,node_user_service,node_user_model toneAmber
class node_task_module,node_task_controller,node_task_service,node_task_model toneMint
class node_postgres toneRose
class node_e2e toneIndigo
class node_client toneNeutral
```

## Components

### Runtime

NestJS bootstrap and HTTP boundary

- [API](https://github.com/cristiant71/task-master-api/blob/main/src/main.ts): http boundary · HTTP server exposed under the /api prefix · `src/main.ts`
- [Bootstrap](https://github.com/cristiant71/task-master-api/blob/main/src/main.ts): nest bootstrap · Application entrypoint and global setup · `src/main.ts`
- [App module](https://github.com/cristiant71/task-master-api/blob/main/src/app.module.ts): root module · Composes the feature modules · `src/app.module.ts`

### Users

User feature module and application flow

- [User module](https://github.com/cristiant71/task-master-api/blob/main/src/user/user.module.ts): feature module · Registers the user subsystem · `src/user/user.module.ts`
- [User controller](https://github.com/cristiant71/task-master-api/blob/main/src/user/user.controller.ts): REST controller · Handles user endpoints · `src/user/user.controller.ts`
- [User service](https://github.com/cristiant71/task-master-api/blob/main/src/user/user.service.ts): application service · Implements user use cases and validation-aware orchestration · `src/user/user.service.ts`
- [User model](https://github.com/cristiant71/task-master-api/blob/main/src/user/entities/user.entity.ts): typeorm entity · User persistence model and request DTO boundary · `src/user/entities/user.entity.ts`

### Tasks

Task feature module and application flow

- [Task module](https://github.com/cristiant71/task-master-api/blob/main/src/task/task.module.ts): feature module · Registers the task subsystem · `src/task/task.module.ts`
- [Task controller](https://github.com/cristiant71/task-master-api/blob/main/src/task/task.controller.ts): REST controller · Handles task endpoints · `src/task/task.controller.ts`
- [Task service](https://github.com/cristiant71/task-master-api/blob/main/src/task/task.service.ts): application service · Implements task use cases and user assignment rules · `src/task/task.service.ts`
- [Task model](https://github.com/cristiant71/task-master-api/blob/main/src/task/entities/task.entity.ts): typeorm entity · Task persistence model and request DTO boundary · `src/task/entities/task.entity.ts`

### Data

Persistence models and database

- [PostgreSQL](https://github.com/cristiant71/task-master-api/blob/main/docker-compose.yml): database · Persistent data store provisioned by Docker Compose · `docker-compose.yml`

### Quality

End-to-end verification

- [E2E tests](https://github.com/cristiant71/task-master-api/blob/main/test/app.e2e-spec.ts): jest suite · End-to-end tests through the HTTP API · `test/app.e2e-spec.ts`

### Other components

- **Client**: external · REST consumer of the API

## Connections

- Client → API: requests · External callers hit the REST boundary
- API → Bootstrap: bootstraps · Main starts and configures the HTTP server
- Bootstrap → App module: loads · Bootstrap initializes the root composition module
- App module → User module: registers · Root module wires in user features
- App module → Task module: registers · Root module wires in task features
- User module → User controller: exposes · User module binds the REST controller
- User module → User service: provides · User module binds application logic
- Task module → Task controller: exposes · Task module binds the REST controller
- Task module → Task service: provides · Task module binds application logic
- User controller → User service: delegates · Controller passes work to the service layer
- Task controller → Task service: delegates · Controller passes work to the service layer
- User service → User model: persists · User logic flows through the TypeORM model
- Task service → Task model: persists · Task logic flows through the TypeORM model
- Task model → User model: many-to-one · Each task belongs to one user
- User model → PostgreSQL: stores in · User records are saved in PostgreSQL
- Task model → PostgreSQL: stores in · Task records are saved in PostgreSQL
- E2E tests → API: verifies · End-to-end tests exercise the HTTP boundary
