# thabawss/cicd-todo-api architecture

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

- Interactive diagram: https://gitdiagram.com/thabawss/cicd-todo-api
- Repository: https://github.com/thabawss/cicd-todo-api

## Overview

todo-api is a small REST service for managing tasks. A client sends health checks or list, create, and completion requests to the Express app; creation validates and normalizes the title before repository operations. The server wires the app to a PostgreSQL-backed repository, which uses a connection pool to query the database. The repository abstraction also has an in-memory implementation, documented for unit tests. The graph follows relationships shown in the sampled source and README; it omits migration internals because their implementation was not sampled.

Main entry points: [`src/pg-repository.ts`](https://github.com/thabawss/cicd-todo-api/blob/main/src/pg-repository.ts) (PostgreSQL Repository), [`src/app.ts`](https://github.com/thabawss/cicd-todo-api/blob/main/src/app.ts) (HTTP Routes), [`src/server.ts`](https://github.com/thabawss/cicd-todo-api/blob/main/src/server.ts) (Server Bootstrap), [`src/repository.ts`](https://github.com/thabawss/cicd-todo-api/blob/main/src/repository.ts) (Repository Contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["Server Bootstrap<br/>[server.ts]"]
  node_app["HTTP Routes<br/>[app.ts]"]
end

subgraph group_domain["Task Domain"]
  node_validator["Title Validation<br/>[todo.ts]"]
  node_todo["Task Model<br/>[todo.ts]"]
end

subgraph group_storage["Persistence"]
  node_contract["Repository Contract<br/>[repository.ts]"]
  node_memory["Memory Repository<br/>[repository.ts]"]
  node_pgrepo["PostgreSQL Repository<br/>[pg-repository.ts]"]
  node_pool["Connection Pool<br/>[db.ts]"]
end

node_client(("API Client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_app
node_server -->|"creates"| node_app
node_server -->|"creates"| node_pool
node_server -->|"configures"| node_pgrepo
node_app -->|"validates titles"| node_validator
node_app -->|"calls repository"| node_contract
node_pgrepo -->|"implements"| node_contract
node_memory -->|"implements"| node_contract
node_pgrepo -->|"queries"| node_pool
node_pgrepo -->|"reads and writes"| node_postgres

click node_server "https://github.com/thabawss/cicd-todo-api/blob/main/src/server.ts"
click node_app "https://github.com/thabawss/cicd-todo-api/blob/main/src/app.ts"
click node_validator "https://github.com/thabawss/cicd-todo-api/blob/main/src/todo.ts"
click node_todo "https://github.com/thabawss/cicd-todo-api/blob/main/src/todo.ts"
click node_contract "https://github.com/thabawss/cicd-todo-api/blob/main/src/repository.ts"
click node_memory "https://github.com/thabawss/cicd-todo-api/blob/main/src/repository.ts"
click node_pgrepo "https://github.com/thabawss/cicd-todo-api/blob/main/src/pg-repository.ts"
click node_pool "https://github.com/thabawss/cicd-todo-api/blob/main/src/db.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_server,node_app,node_client toneBlue
class node_validator,node_todo,node_postgres toneAmber
class node_contract,node_memory,node_pgrepo,node_pool toneMint
```

## Components

### HTTP API

- [Server Bootstrap](https://github.com/thabawss/cicd-todo-api/blob/main/src/server.ts): `src/server.ts`
- [HTTP Routes](https://github.com/thabawss/cicd-todo-api/blob/main/src/app.ts): `src/app.ts`

### Task Domain

- [Title Validation](https://github.com/thabawss/cicd-todo-api/blob/main/src/todo.ts): `src/todo.ts`
- [Task Model](https://github.com/thabawss/cicd-todo-api/blob/main/src/todo.ts): `src/todo.ts`

### Persistence

- [Repository Contract](https://github.com/thabawss/cicd-todo-api/blob/main/src/repository.ts): `src/repository.ts`
- [Memory Repository](https://github.com/thabawss/cicd-todo-api/blob/main/src/repository.ts): `src/repository.ts`
- [PostgreSQL Repository](https://github.com/thabawss/cicd-todo-api/blob/main/src/pg-repository.ts): `src/pg-repository.ts`
- [Connection Pool](https://github.com/thabawss/cicd-todo-api/blob/main/src/db.ts): `src/db.ts`

### Other components

- **API Client**
- **PostgreSQL**

## Connections

- API Client → HTTP Routes: sends requests (evidence: `README.md`)
- Server Bootstrap → HTTP Routes: creates (evidence: `src/server.ts`)
- Server Bootstrap → Connection Pool: creates (evidence: `src/server.ts`)
- Server Bootstrap → PostgreSQL Repository: configures (evidence: `src/server.ts`)
- HTTP Routes → Title Validation: validates titles (evidence: `src/app.ts`)
- HTTP Routes → Repository Contract: calls repository (evidence: `src/app.ts`)
- PostgreSQL Repository → Repository Contract: implements (evidence: `src/pg-repository.ts`)
- Memory Repository → Repository Contract: implements (evidence: `src/repository.ts`)
- PostgreSQL Repository → Connection Pool: queries (evidence: `src/pg-repository.ts`)
- PostgreSQL Repository → PostgreSQL: reads and writes (evidence: `src/pg-repository.ts`)
