# arshyasharifian/aws_api_crud_template architecture

> Architecture diagram of the GitHub repository arshyasharifian/aws_api_crud_template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arshyasharifian/aws_api_crud_template
- Repository: https://github.com/arshyasharifian/aws_api_crud_template

## Overview

##### Main Components

a. Client Layer:
- External clients/users making API requests
- Custom domain (Route 53) integration

b. API Layer:
- API Gateway as the entry point
- Custom domain configuration
- REST endpoints (GET, PUT, POST, DELETE)

c. Compute Layer:
- Four Lambda functions (create, read, update, delete)
- Shared utilities package

d. Data Layer:
- DynamoDB table
- IAM roles and permissions

**[Clients] → [DNS/Route 53] → [API Gateway] → [Lambda Functions] → [DynamoDB]**

##### Key Relationships to Highlight

- Four distinct Lambda functions (create, get, put, delete) connecting to API Gateway
- Shared utils package being used by all Lambda functions
- IAM role connections between services
- Custom domain flow from Route 53 to API Gateway

##### Implementation Details

a. Technical specifications:
- Node.js runtime environment
- TypeScript implementation
- Terraform deployment flow
- Workspace separation (dev, stage, prod)

b. Annotations for:
- API endpoints
- Lambda function names
- DynamoDB table details
- IAM role specifications

##### Infrastructure as Code Layer

- Terraform configuration files
- Resource relationships
- Environment separation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        Client((External Client)):::client
    end

    %% DNS Layer
    subgraph DNS
        Route53[Route 53]:::aws
    end

    %% API Layer
    subgraph API
        APIG[API Gateway]:::aws
    end

    %% Lambda Functions Layer
    subgraph "Lambda Functions"
        Create["Create Lambda"]:::lambda
        Read["Read Lambda"]:::lambda
        Update["Update Lambda"]:::lambda
        Delete["Delete Lambda"]:::lambda
        Utils["Shared Utils"]:::utils
    end

    %% Infrastructure Layer
    subgraph "Infrastructure as Code"
        TF_Main["Main Config"]:::terraform
        TF_IAM["IAM Config"]:::terraform
        TF_DDB["DynamoDB Config"]:::terraform
        TF_Lambda["Lambda Config"]:::terraform
        TF_Vars["Variables"]:::terraform
    end

    %% Data Layer
    subgraph "Data Store"
        DDB[(DynamoDB)]:::database
    end

    %% Connections
    Client --> Route53
    Route53 --> APIG
    APIG --> Create
    APIG --> Read
    APIG --> Update
    APIG --> Delete
    
    Create --> Utils
    Read --> Utils
    Update --> Utils
    Delete --> Utils
    
    Utils --> DDB
    
    TF_Main --> TF_IAM
    TF_Main --> TF_DDB
    TF_Main --> TF_Lambda
    TF_Main --> TF_Vars

    %% Click Events
    click Create "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/lambda-create/src/handler.ts"
    click Read "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/lambda-get/src/handler.ts"
    click Update "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/lambda-put/src/handler.ts"
    click Delete "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/lambda-delete/src/handler.ts"
    click Utils "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/lambda-shared-utils/src/dynamodb.ts"
    click TF_DDB "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/terraform/dynamodb.tf"
    click TF_IAM "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/terraform/iam.tf"
    click TF_Lambda "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/terraform/lambda.tf"
    click TF_Main "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/terraform/main.tf"
    click TF_Vars "https://github.com/arshyasharifian/aws_api_crud_template/blob/main/terraform/variables.tf"

    %% Styles
    classDef client fill:#FF9900,stroke:#333,stroke-width:2px
    classDef aws fill:#232F3E,stroke:#FF9900,stroke-width:2px,color:#fff
    classDef lambda fill:#009639,stroke:#333,stroke-width:2px
    classDef utils fill:#1A73E8,stroke:#333,stroke-width:2px
    classDef database fill:#C925D1,stroke:#333,stroke-width:2px
    classDef terraform fill:#7B42BC,stroke:#333,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1((Client)):::client
        L2[AWS Service]:::aws
        L3[Lambda]:::lambda
        L4[(Database)]:::database
        L5[Terraform]:::terraform
    end
```
