# rupeshmutha/aws_cdk_mini_project architecture

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

- Interactive diagram: https://gitdiagram.com/rupeshmutha/aws_cdk_mini_project
- Repository: https://github.com/rupeshmutha/aws_cdk_mini_project

## Overview

##### Project type and purpose
- This is an Infrastructure-as-Code project using AWS CDK (Python) to deploy AWS resources.
- The README states: “Deploying lambda and s3 using aws cdk via github repo.”
- It’s neither a full-stack web app nor a library, but a deployment tool that provisions cloud infrastructure (Lambda function, S3 bucket, IAM roles) via CDK.

##### File structure
- Top-level CI directory
- .github/workflows/main.yml: GitHub Actions pipeline for build/deploy
- CDK-AWS directory (the CDK app)
- app.py: entry point that synthesizes/stages CDK stacks
- cdk.json: CLI configuration
- setup.py & pipe-requirements.txt: Python packaging and dependencies
- config/demo_config.ini: environment/config parameters
- source.bat: Windows helper to set environment
- cdk_aws subdirectory (construct definitions)
- cdk_aws_stack.py: defines the Stack (S3 bucket, Lambda, permissions)
- iam_construct.py: reusable IAM role/permission setup
- lambda_construct.py: reusable Lambda function setup
- lambda_codes directory
- demo_lambda_module.py: the handler code for the Lambda function

##### README for additional insights
- No extra tooling or integrations mentioned beyond Python, AWS CDK, GitHub Actions.

a. Main components:
- Developer Workstation (Python/CDK)
- GitHub Repo (source code, CI definitions)
- GitHub Actions Runner (CI/CD pipeline)
- AWS CDK App (app.py & constructs)
- AWS CloudFormation (deploys stacks)
- AWS Services:
- IAM (roles/policies)
- S3 Bucket
- Lambda Function
b. Relationships & interactions:
- Developer pushes code → GitHub Repo → triggers GitHub Actions.
- GitHub Actions uses pipe-requirements.txt to install CDK, runs `cdk synth` & `cdk deploy`.
- CDK App (app.py) calls constructs which generate CloudFormation template.
- CloudFormation provisions S3, Lambda, and IAM roles in AWS.
- Lambda code is uploaded from lambda_codes/demo_lambda_module.py.
c. Architectural patterns/design principles:
- Infrastructure-as-Code pattern via AWS CDK (constructs, stacks).
- Reusable constructs for IAM and Lambda (separation of concerns).
- CI/CD pipeline for automated, reproducible deployments.
d. Key technologies:
- AWS CDK (Python)
- GitHub Actions
- Python packaging (setup.py, requirements file)
- AWS CloudFormation
- AWS Lambda & S3 services

##### Elements
- Clear labels for each component (Dev, Repo, Actions, CDK App, CloudFormation, AWS Services).
- Developer → Git push → Repo
- Repo → trigger → GitHub Actions
- Actions → executes → CDK App
- CDK App → produces → CloudFormation template
- CloudFormation → provisions → Lambda, S3, IAM
- Use rectangles for compute components (Actions Runner, CDK App).

##### Detailed capture of essential architectural elements
- CDK constructs module hierarchy:
- app.py instantiates cdk_aws_stack
- cdk_aws_stack imports iam_construct and lambda_construct
- Configuration loaded from demo_config.ini.
- Windows helper (source.bat) for local developers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Local Development Layer
    subgraph "Local Development"
        Dev["Developer Workstation"]:::external
        SourceBat["source.bat"]:::tool
    end
    Dev -->|runs helper| SourceBat

    %% CI/CD Pipeline Layer
    subgraph "CI/CD Pipeline"
        Repo["GitHub Repo"]:::repo
        Actions["GitHub Actions Runner"]:::ci
    end
    Dev -->|push code| Repo
    Repo -->|triggers CI| Actions

    %% CDK Application Layer
    subgraph "CDK Application"
        App["app.py"]:::iac
        CdkJson["cdk.json"]:::iac
        SetupPy["setup.py"]:::iac
        ReqTxt["pipe-requirements.txt"]:::iac
        ConfigIni["demo_config.ini"]:::iac
        subgraph "Construct Definitions"
            Stack["cdk_aws_stack.py"]:::iac
            IAMConstruct["iam_construct.py"]:::iac
            LambdaConstruct["lambda_construct.py"]:::iac
        end
    end
    Actions -->|installs deps & runs CDK| ReqTxt
    Actions -->|executes CDK App| App
    App -->|config from| ConfigIni
    App -->|loads CLI config| CdkJson
    App -->|packages| SetupPy
    App -->|imports constructs| Stack
    Stack -->|uses| IAMConstruct
    Stack -->|uses| LambdaConstruct

    %% CloudFormation Layer
    CF["CloudFormation Template"]:::cf
    App -->|synthesizes| CF

    %% AWS Resources Layer
    subgraph "AWS Resources"
        IAM["IAM Roles & Policies"]:::aws
        S3["S3 Bucket"]:::aws
        Lambda["Lambda Function"]:::aws
    end
    CF -->|provisions| IAM
    CF -->|provisions| S3
    CF -->|provisions| Lambda

    %% Lambda Code Link
    Lambda -->|code from| DemoCode["demo_lambda_module.py"]:::code

    %% Click Events
    click Actions "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/.github/workflows/main.yml"
    click Repo "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/README.md"
    click App "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/app.py"
    click CdkJson "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/cdk.json"
    click SetupPy "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/setup.py"
    click ReqTxt "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/pipe-requirements.txt"
    click ConfigIni "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/config/demo_config.ini"
    click SourceBat "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/source.bat"
    click Stack "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/cdk_aws/cdk_aws_stack.py"
    click IAMConstruct "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/cdk_aws/iam_construct.py"
    click LambdaConstruct "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/cdk_aws/lambda_construct.py"
    click DemoCode "https://github.com/rupeshmutha/aws_cdk_mini_project/blob/main/CDK-AWS/lambda_codes/demo_lambda_module.py"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px
    classDef tool fill:#ff9,stroke:#333,stroke-width:2px
    classDef repo fill:#9cf,stroke:#333,stroke-width:2px
    classDef ci fill:#fc9,stroke:#333,stroke-width:2px
    classDef iac fill:#cfc,stroke:#333,stroke-width:2px
    classDef cf fill:#ccc,stroke:#333,stroke-width:2px,stroke-dasharray: 5 5
    classDef aws fill:#ccf,stroke:#333,stroke-width:2px
    classDef code fill:#eef,stroke:#333,stroke-width:2px
```
