# aws-samples/http-api-aws-fargate-cdk architecture

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

- Interactive diagram: https://gitdiagram.com/aws-samples/http-api-aws-fargate-cdk
- Repository: https://github.com/aws-samples/http-api-aws-fargate-cdk

## Overview

Key Components to Include:

##### Main Infrastructure Layers
- Consumer Layer (API Gateway & VPC)
- Producer Layer (Fargate Services & VPC)
- Networking Layer (PrivateLink & VPC Link)

##### Core Services to Highlight
- HTTP API Gateway
- Two VPCs (Consumer and Producer)
- AWS Fargate Services
- Application Load Balancer (ALB)
- VPC Link
- Amazon ECR Repositories
- CloudMap Service Discovery
- ECS Cluster

- Top Layer: Consumer-facing components (HTTP API Gateway)
- Middle Layer: Networking components (VPC Link, PrivateLink)
- Bottom Layer: Backend services (Fargate, ALB, etc.)

##### Component Grouping
a. Consumer VPC Zone:
- Public subnets
- Bastion host
- Security groups

b. Producer VPC Zone:
- Private subnets
- Public subnets
- ALB
- Fargate services
- Service discovery

##### Specific Details
- Two microservices (book-service and author-service)
- ALB listener rules
- Target groups
- Security group rules
- CloudMap namespace
- Task definitions

##### Stack Separation
- Use a clear visual boundary between FargateVpclinkStack and HttpApiStack
- Resource dependencies between stacks

##### Security Aspects
- Private vs public subnets
- Security group relationships
- IAM roles and permissions

##### Scaling Components
- Fargate service scaling
- ALB distribution
- Service discovery points

##### Data Flow
- Request path from API Gateway to services
- Health check paths
- Service discovery flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef vpc fill:#b3d1ff,stroke:#333
    classDef service fill:#90EE90,stroke:#333
    classDef api fill:#FFA07A,stroke:#333
    classDef lb fill:#DDA0DD,stroke:#333
    classDef support fill:#D3D3D3,stroke:#333
    
    %% Consumer Layer
    subgraph ConsumerLayer["Consumer Layer"]
        APIGW["HTTP API Gateway"]:::api
        click APIGW "https://github.com/aws-samples/http-api-aws-fargate-cdk/blob/master/cdk/singleAccount/lib/httpApi-stack.ts"
    end

    %% Networking Layer
    subgraph NetworkingLayer["Networking Layer"]
        VPCLink["VPC Link"]
        PrivateLink["AWS PrivateLink"]
    end

    %% Consumer VPC
    subgraph ConsumerVPC["Consumer VPC"]
        PublicSubnetsC["Public Subnets"]
        BastionHost["Bastion Host"]
        SecurityGroupsC["Security Groups"]
    end
    class ConsumerVPC vpc

    %% Producer VPC
    subgraph ProducerVPC["Producer VPC"]
        PrivateSubnetsP["Private Subnets"]
        PublicSubnetsP["Public Subnets"]
        
        subgraph Services["Fargate Services"]
            BookService["Book Service (Port 80)"]:::service
            AuthorService["Author Service (Port 80)"]:::service
            click BookService "https://github.com/aws-samples/http-api-aws-fargate-cdk/tree/master/src/book-service"
            click AuthorService "https://github.com/aws-samples/http-api-aws-fargate-cdk/tree/master/src/author-service"
        end
        
        ALB["Application Load Balancer"]:::lb
        ServiceDiscovery["CloudMap Service Discovery"]:::support
    end
    class ProducerVPC vpc

    %% ECR and Supporting Services
    subgraph SupportingServices["Supporting Services"]
        ECR["Amazon ECR"]:::support
        ECSCluster["ECS Cluster"]:::support
    end

    %% Define relationships
    APIGW --> VPCLink
    VPCLink --> ALB
    ALB --> BookService
    ALB --> AuthorService
    BookService --> ServiceDiscovery
    AuthorService --> ServiceDiscovery
    ECR --> BookService
    ECR --> AuthorService
    ECSCluster --> BookService
    ECSCluster --> AuthorService

    %% Legend
    subgraph Legend["Legend"]
        L1["VPC Components"]:::vpc
        L2["Services"]:::service
        L3["API Gateway"]:::api
        L4["Load Balancer"]:::lb
        L5["Supporting Services"]:::support
    end
```
