# ajitnk-lab/flask-todo-cdk architecture

> Architecture diagram of the GitHub repository ajitnk-lab/flask-todo-cdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ajitnk-lab/flask-todo-cdk
- Repository: https://github.com/ajitnk-lab/flask-todo-cdk

## Overview

##### Project type and purpose
- This is a serverless, infrastructure-as-code project implementing a RESTful “todo” API.
- It uses AWS CDK (Python) to provision AWS resources: API Gateway, Lambda (running a Flask app), and DynamoDB.
- The goal is to demonstrate modern serverless patterns: CRUD APIs, automatic scaling, and IaC best practices.

##### File structure
- Top level
- app.py          – CDK application entry point
- cdk.json        – CDK CLI configuration
- requirements*.txt – Python dependencies for CDK and development
- scripts/        – deployment helper (deploy.sh)
- tests/          – unit tests for stacks and Lambda API
- infrastructure/
- database_stack.py – defines the DynamoDB table
- todo_stack.py     – defines the API Gateway and Lambda resources, wired to the database stack
- lambda/
- todo_api/         – Flask application code (app.py, models.py) packaged for Lambda
- requirements.txt  – dependencies for the Lambda environment
- scripts/            – CI/deployment automation
- tests/              – pytest tests covering infrastructure and API behavior

##### Extract architectural insights from README
- It calls out REST API with CORS, Python 3.11, serverless scaling, and IaC.
- Dependencies: AWS CDK (v2+), Python 3.11, Node.js 18+ for the CDK CLI.

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "CDK Deployment Pipeline"
    CLI["Developer / CDK CLI"]:::tool
    App["app.py"]:::code
    Config["cdk.json"]:::code
    DeployScript["deploy.sh"]:::code
  end

  subgraph "CloudFormation"
    CF["CloudFormation"]:::infra
  end

  CLI -->|"synth/deploy"| App
  App --> CF
  Config --> CF
  DeployScript --> CLI

  subgraph "AWS Resources"
    APIGW["API Gateway"]:::service
    Lambda["Lambda (Flask)"]:::compute
    Dynamo["DynamoDB Table"]:::db
    Logs["CloudWatch Logs"]:::obs
    XRay["AWS X-Ray"]:::obs
  end

  CF --> APIGW
  CF --> Lambda
  CF --> Dynamo

  subgraph "Runtime Flow"
    Client["Client (Browser/cURL)"]:::external
    Client -->|"HTTP Request"| APIGW
    APIGW -->|"Invoke"| Lambda
    Lambda -->|"boto3"| Dynamo
    Dynamo -->|"Response"| Lambda
    Lambda -->|"HTTP Response"| APIGW
    APIGW --> Client
    Lambda -->|"Log"| Logs
    Lambda -->|"Trace"| XRay
  end

  subgraph "Lambda Code"
    CodeInit["__init__.py"]:::code
    CodeMain["app.py"]:::code
    CodeReq["requirements.txt"]:::code
  end

  Lambda -.-> CodeMain
  Lambda -.-> CodeInit
  Lambda -.-> CodeReq

  subgraph "Infrastructure Code"
    DBStack["database_stack.py"]:::code
    TodoStack["todo_stack.py"]:::code
    ReqCDK["requirements.txt"]:::code
    ReqDev["requirements-dev.txt"]:::code
  end

  DBStack --> TodoStack

  subgraph "Tests"
    TestInfra["test_database_stack.py"]:::test
    TestAPI["test_todo_api.py"]:::test
  end

  classDef tool fill:#E3F2FD,stroke:#90CAF9,color:#0D47A1;
  classDef infra fill:#FFF3E0,stroke:#FFB74D,color:#E65100;
  classDef service fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20;
  classDef compute fill:#F3E5F5,stroke:#BA68C8,color:#4A148C;
  classDef db fill:#E0F7FA,stroke:#4DD0E1,color:#006064;
  classDef obs fill:#FBE9E7,stroke:#FF8A65,color:#BF360C;
  classDef code fill:#ECEFF1,stroke:#B0BEC5,color:#263238;
  classDef test fill:#FFFDE7,stroke:#FFF176,color:#F57F17;
  classDef external fill:#FFFFFF,stroke:#BDBDBD,color:#424242;

  click App "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/app.py"
  click Config "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/cdk.json"
  click DeployScript "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/scripts/deploy.sh"
  click DBStack "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/infrastructure/database_stack.py"
  click TodoStack "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/infrastructure/todo_stack.py"
  click CodeMain "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/lambda/todo_api.py"
  click CodeInit "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/lambda/todo_api/__init__.py"
  click CodeReq "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/lambda/requirements.txt"
  click ReqCDK "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/requirements.txt"
  click ReqDev "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/requirements-dev.txt"
  click TestInfra "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/tests/test_database_stack.py"
  click TestAPI "https://github.com/ajitnk-lab/flask-todo-cdk/blob/main/tests/test_todo_api.py"
```
