# ngl321/aws-cdk-examples architecture

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

- Interactive diagram: https://gitdiagram.com/ngl321/aws-cdk-examples
- Repository: https://github.com/ngl321/aws-cdk-examples

## Overview

##### Project type and purpose
- This is a monorepo containing AWS CDK example applications in multiple languages (TypeScript, Python, Java, C#, Go).
- Its purpose is to demonstrate common AWS infrastructure patterns (load balancers, Lambda functions, ECS, Step Functions, etc.) for learners and contributors.

##### File structure
- Top-level directories:
- .github/workflows – CI/CD pipeline definitions (build, test, extract snippets)
- scripts – language-specific build & synth scripts
- csharp, go, java, python, typescript – language-scoped example sets
- Under each language directory:
- Multiple example subdirectories, each containing a self-contained CDK app (cdk.json, source code, optional test or asset folder)
- README.md describing that example
- CI/CD config files (.github/workflows) orchestrate build → synth → test across languages using scripts/build-*.sh

##### README
- Explains the repository as an official AWS CDK Examples collection, organized by language, each example showing a single AWS pattern.
- No single runtime system; it’s an educational monorepo.

##### Diagramming guidance
a. Main components
1. Monorepo root
– Metadata & config (.editorconfig, LICENSE, NOTICE)
– CI/CD workflows (.github/workflows)
– Build & support scripts (scripts/)
2. Language workspaces (csharp/, go/, java/, python/, typescript/)
3. Example CDK apps (subfolders under each language)
4. External services: AWS CDK CLI, AWS account (for deploy), GitHub Actions
b. Relationships & interactions
– Developer commits → GitHub → triggers Actions workflows → runs scripts/build-*.sh → `cdk synth` / compile / test in each language workspace → outputs CloudFormation templates (synth) or test results
– Each language workspace interacts with AWS CDK library & language runtime (Node.js for TS, Python interpreter, .NET for C#, JVM for Java, Go compiler for Go)
c. Architectural patterns & principles
– Monorepo pattern: shared CI/CD for multiple language modules
– Consistent example scaffold: one CDK stack per example
– Modularization by language
d. Key technologies & frameworks
– AWS CDK library in each language
– GitHub Actions for CI
– Bash/PowerShell scripts for build orchestration
– Language-specific package managers (npm, pip, Maven, NuGet, Go modules)

##### Detailed capture of essential elements
- Directory layering: monorepo → languages → examples
- CI workflow sequence (checkout, install deps per language, synth, test)
- Examples by AWS service type (Lambda-based, ECS-based, Load Balancer-based) if desired for clarity

## Diagram (Mermaid)

```mermaid
flowchart TD
    Commit["Developer Commit"]:::external -->|push/pull request| GitHub["GitHub Actions"]:::ci
    GitHub -->|trigger workflows| CI["CI/CD Pipelines"]
    CI -->|run snippet extraction| ExtractPy["extract-snippets.py"]
    CI --> ExtractSh["extract-snippets.sh"]
    CI -->|orchestrate builds| Scripts["Build & Support Scripts"]
    Scripts -->|invoke| Workspaces["Language Workspaces"]
    Workspaces -->|synth/test| AWSCDK["AWS CDK CLI"]:::aws
    AWSCDK -->|deploy| AWSAccount["AWS Account"]:::aws

    subgraph "CI/CD Pipelines"
        BP1["build-pull-request.yml"]
        BP2["extract-snippets.yml"]
        BP3["close-stale-issues.yml"]
        BP4["closed-issue-message.yml"]
        BP5["extract-snippets-dryrun.yml"]
        ExtractPy
        ExtractSh
    end

    subgraph "Build & Support Scripts"
        B1["build-csharp.sh"]
        B2["build-go.sh"]
        B3["build-java.sh"]
        B4["build-python.sh"]
        B5["build-typescript.sh"]
        B6["synth.sh"]
    end

    subgraph "Language Workspaces"
        subgraph "csharp" 
            C1["cdk.json"]
            C2["ApplicationLoadBalancerStack.cs"]
        end
        subgraph "go"
            G1["cdk.json"]
            G2["classic-load-balancer.go"]
        end
        subgraph "java"
            J1["cdk.json"]
            J2["ClassicLoadBalancerStack.java"]
        end
        subgraph "python"
            P1["cdk.json"]
            P2["app.py"]
        end
        subgraph "typescript"
            T1["cdk.json"]
            T2["index.ts"]
        end
    end

    classDef repoComponents fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef ci fill:#D5F5E3,stroke:#145A32,color:#1B2631
    classDef lang fill:#FAD7A0,stroke:#B9770E,color:#1B2631
    classDef aws fill:#E8DAEF,stroke:#512E5F,color:#1B2631
    classDef external fill:#F2F3F4,stroke:#7B7D7D,color:#1B2631

    class GitHub,CI,Scripts repoComponents
    class BP1,BP2,BP3,BP4,BP5,ExtractPy,ExtractSh ci
    class B1,B2,B3,B4,B5,B6 ci
    class C1,C2,G1,G2,J1,J2,P1,P2,T1,T2 lang
    class AWSCDK,AWSAccount aws

    click BP1 "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/workflows/build-pull-request.yml"
    click BP2 "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/workflows/extract-snippets.yml"
    click BP3 "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/workflows/close-stale-issues.yml"
    click BP4 "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/workflows/closed-issue-message.yml"
    click BP5 "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/workflows/extract-snippets-dryrun.yml"
    click ExtractPy "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/extract-snippets/extract-snippets.py"
    click ExtractSh "https://github.com/ngl321/aws-cdk-examples/blob/master/.github/extract-snippets/extract-snippets.sh"

    click B1 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/build-csharp.sh"
    click B2 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/build-go.sh"
    click B3 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/build-java.sh"
    click B4 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/build-python.sh"
    click B5 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/build-typescript.sh"
    click B6 "https://github.com/ngl321/aws-cdk-examples/blob/master/scripts/synth.sh"

    click C1 "https://github.com/ngl321/aws-cdk-examples/blob/master/csharp/application-load-balancer/cdk.json"
    click C2 "https://github.com/ngl321/aws-cdk-examples/blob/master/csharp/application-load-balancer/src/ApplicationLoadBalancer/ApplicationLoadBalancerStack.cs"

    click G1 "https://github.com/ngl321/aws-cdk-examples/blob/master/go/classic-load-balancer/cdk.json"
    click G2 "https://github.com/ngl321/aws-cdk-examples/blob/master/go/classic-load-balancer/classic-load-balancer.go"

    click J1 "https://github.com/ngl321/aws-cdk-examples/blob/master/java/classic-load-balancer/cdk.json"
    click J2 "https://github.com/ngl321/aws-cdk-examples/blob/master/java/classic-load-balancer/src/main/java/software/amazon/awscdk/examples/ClassicLoadBalancerStack.java"

    click P1 "https://github.com/ngl321/aws-cdk-examples/blob/master/python/application-load-balancer/cdk.json"
    click P2 "https://github.com/ngl321/aws-cdk-examples/blob/master/python/application-load-balancer/app.py"

    click T1 "https://github.com/ngl321/aws-cdk-examples/blob/master/typescript/application-load-balancer/cdk.json"
    click T2 "https://github.com/ngl321/aws-cdk-examples/blob/master/typescript/application-load-balancer/index.ts"
```
