# thula-w/taskflow architecture

> Architecture diagram of the GitHub repository thula-w/taskflow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thula-w/taskflow
- Repository: https://github.com/thula-w/taskflow

## Overview

TaskFlow is a task-management HTTP API backed by PostgreSQL. Its main workflow routes client requests through Express to validated task operations and returns database-backed responses; startup initializes the schema before accepting traffic. The repository also contains AWS infrastructure definitions, Ansible host configuration, and an SNS-triggered ECS task-size scaler. Those deployment files were not sampled, so their internal wiring is not asserted here.

Main entry points: [`app/src/db/index.ts`](https://github.com/thula-w/taskflow/blob/main/app/src/db/index.ts) (Database pool), [`app/src/controllers/taskController.ts`](https://github.com/thula-w/taskflow/blob/main/app/src/controllers/taskController.ts) (Task controller), [`app/src/index.ts`](https://github.com/thula-w/taskflow/blob/main/app/src/index.ts) (Application startup), [`app/src/app.ts`](https://github.com/thula-w/taskflow/blob/main/app/src/app.ts) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Task API"]
  node_entry["Application startup<br/>[index.ts]"]
  node_app["Express app<br/>[app.ts]"]
  node_routes["Task routes<br/>[taskRoutes.ts]"]
  node_controller["Task controller<br/>[taskController.ts]"]
  node_config["Runtime config<br/>[index.ts]"]
end

subgraph group_data["Task data"]
  node_schemas["Task validation<br/>[task.ts]"]
  node_db["Database pool<br/>[index.ts]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_infra["AWS infrastructure"]
  node_prod["Production Terraform"]
  node_alb["Load balancer module"]
  node_ecs["ECS module"]
  node_rds["RDS module"]
  node_iam["IAM module"]
  node_network["VPC module"]
  node_security["Security module"]
  node_scaling["Scaling module"]
end

subgraph group_ops["Operations"]
  node_logger["Application logger<br/>[logger.ts]"]
  node_scale_lambda["ECS scaler<br/>[scale_handler.py]"]
  node_ansible["Ansible site config<br/>[site.yml]"]
  node_cloudwatch_role["CloudWatch role"]
  node_ecs_role["Ansible ECS role"]
  node_docker_role["Docker role"]
  node_common_role["Common role"]
  node_security_role["Ansible security role"]
end

node_client(("API client"))
node_sns["SNS alarm event"]
node_ecs_api["Amazon ECS"]

node_client -->|"sends HTTP"| node_app
node_entry -->|"reads settings"| node_config
node_entry -->|"initializes schema"| node_db
node_entry -->|"starts server"| node_app
node_app -->|"mounts routes"| node_routes
node_routes -->|"dispatches requests"| node_controller
node_controller -->|"validates input"| node_schemas
node_controller -->|"queries tasks"| node_db
node_db -->|"reads connection"| node_config
node_db -->|"queries"| node_postgres
node_controller -->|"logs errors"| node_logger
node_db -->|"logs errors"| node_logger
node_sns -->|"delivers alarm"| node_scale_lambda
node_scale_lambda -->|"reads and updates service"| node_ecs_api

click node_entry "https://github.com/thula-w/taskflow/blob/main/app/src/index.ts"
click node_app "https://github.com/thula-w/taskflow/blob/main/app/src/app.ts"
click node_routes "https://github.com/thula-w/taskflow/blob/main/app/src/routes/taskRoutes.ts"
click node_controller "https://github.com/thula-w/taskflow/blob/main/app/src/controllers/taskController.ts"
click node_schemas "https://github.com/thula-w/taskflow/blob/main/app/src/types/task.ts"
click node_config "https://github.com/thula-w/taskflow/blob/main/app/src/config/index.ts"
click node_db "https://github.com/thula-w/taskflow/blob/main/app/src/db/index.ts"
click node_logger "https://github.com/thula-w/taskflow/blob/main/app/src/utils/logger.ts"
click node_prod "https://github.com/thula-w/taskflow/tree/main/terraform/envs/prod"
click node_alb "https://github.com/thula-w/taskflow/tree/main/terraform/modules/alb"
click node_ecs "https://github.com/thula-w/taskflow/tree/main/terraform/modules/ecs"
click node_rds "https://github.com/thula-w/taskflow/tree/main/terraform/modules/rds"
click node_iam "https://github.com/thula-w/taskflow/tree/main/terraform/modules/iam"
click node_network "https://github.com/thula-w/taskflow/tree/main/terraform/modules/vpc"
click node_security "https://github.com/thula-w/taskflow/tree/main/terraform/modules/security"
click node_scaling "https://github.com/thula-w/taskflow/tree/main/terraform/modules/scaling"
click node_scale_lambda "https://github.com/thula-w/taskflow/blob/main/terraform/modules/scaling/lambda/scale_handler.py"
click node_ansible "https://github.com/thula-w/taskflow/blob/main/ansible/site.yml"
click node_cloudwatch_role "https://github.com/thula-w/taskflow/tree/main/ansible/roles/cloudwatch"
click node_ecs_role "https://github.com/thula-w/taskflow/tree/main/ansible/roles/ecs"
click node_docker_role "https://github.com/thula-w/taskflow/tree/main/ansible/roles/docker"
click node_common_role "https://github.com/thula-w/taskflow/tree/main/ansible/roles/common"
click node_security_role "https://github.com/thula-w/taskflow/tree/main/ansible/roles/security"

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_entry,node_app,node_routes,node_controller,node_config,node_client toneBlue
class node_schemas,node_db,node_postgres toneAmber
class node_prod,node_alb,node_ecs,node_rds,node_iam,node_network,node_security,node_scaling toneMint
class node_logger,node_scale_lambda,node_ansible,node_cloudwatch_role,node_ecs_role,node_docker_role,node_common_role,node_security_role toneRose
class node_sns,node_ecs_api toneIndigo
```

## Components

### Task API

- [Application startup](https://github.com/thula-w/taskflow/blob/main/app/src/index.ts): `app/src/index.ts`
- [Express app](https://github.com/thula-w/taskflow/blob/main/app/src/app.ts): `app/src/app.ts`
- [Task routes](https://github.com/thula-w/taskflow/blob/main/app/src/routes/taskRoutes.ts): `app/src/routes/taskRoutes.ts`
- [Task controller](https://github.com/thula-w/taskflow/blob/main/app/src/controllers/taskController.ts): `app/src/controllers/taskController.ts`
- [Runtime config](https://github.com/thula-w/taskflow/blob/main/app/src/config/index.ts): `app/src/config/index.ts`

### Task data

- [Task validation](https://github.com/thula-w/taskflow/blob/main/app/src/types/task.ts): `app/src/types/task.ts`
- [Database pool](https://github.com/thula-w/taskflow/blob/main/app/src/db/index.ts): `app/src/db/index.ts`
- **PostgreSQL**

### AWS infrastructure

- [Production Terraform](https://github.com/thula-w/taskflow/tree/main/terraform/envs/prod): `terraform/envs/prod`
- [Load balancer module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/alb): `terraform/modules/alb`
- [ECS module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/ecs): `terraform/modules/ecs`
- [RDS module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/rds): `terraform/modules/rds`
- [IAM module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/iam): `terraform/modules/iam`
- [VPC module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/vpc): `terraform/modules/vpc`
- [Security module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/security): `terraform/modules/security`
- [Scaling module](https://github.com/thula-w/taskflow/tree/main/terraform/modules/scaling): `terraform/modules/scaling`

### Operations

- [Application logger](https://github.com/thula-w/taskflow/blob/main/app/src/utils/logger.ts): `app/src/utils/logger.ts`
- [ECS scaler](https://github.com/thula-w/taskflow/blob/main/terraform/modules/scaling/lambda/scale_handler.py): `terraform/modules/scaling/lambda/scale_handler.py`
- [Ansible site config](https://github.com/thula-w/taskflow/blob/main/ansible/site.yml): `ansible/site.yml`
- [CloudWatch role](https://github.com/thula-w/taskflow/tree/main/ansible/roles/cloudwatch): `ansible/roles/cloudwatch`
- [Ansible ECS role](https://github.com/thula-w/taskflow/tree/main/ansible/roles/ecs): `ansible/roles/ecs`
- [Docker role](https://github.com/thula-w/taskflow/tree/main/ansible/roles/docker): `ansible/roles/docker`
- [Common role](https://github.com/thula-w/taskflow/tree/main/ansible/roles/common): `ansible/roles/common`
- [Ansible security role](https://github.com/thula-w/taskflow/tree/main/ansible/roles/security): `ansible/roles/security`

### Other components

- **API client**
- **SNS alarm event**
- **Amazon ECS**

## Connections

- API client → Express app: sends HTTP
- Application startup → Runtime config: reads settings
- Application startup → Database pool: initializes schema
- Application startup → Express app: starts server
- Express app → Task routes: mounts routes
- Task routes → Task controller: dispatches requests
- Task controller → Task validation: validates input
- Task controller → Database pool: queries tasks
- Database pool → Runtime config: reads connection
- Database pool → PostgreSQL: queries
- Task controller → Application logger: logs errors
- Database pool → Application logger: logs errors
- SNS alarm event → ECS scaler: delivers alarm
- ECS scaler → Amazon ECS: reads and updates service
