# aws-samples/getting-started-with-amazon-redshift-data-api architecture

> Architecture diagram of the GitHub repository aws-samples/getting-started-with-amazon-redshift-data-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/getting-started-with-amazon-redshift-data-api
- Repository: https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api

## Overview

##### Main Components
- Client Code Samples: Represented in the “quick-start” directory, which includes language-specific implementations. These clients illustrate how to execute SQL operations using the Redshift Data API.
- Use-Case Implementations: Under the “use-cases” directory, you have several real-world scenarios such as event-driven analytical reporting, ETL orchestration, EC2-redshift access, Lambda chaining, REST API integration, and SageMaker notebooks integration.
- AWS Lambda: As highlighted in the README, Lambda is a primary compute resource used. Represent AWS Lambda functions as a component that encapsulates the code samples and ETL orchestration.
- Amazon Redshift & Redshift Data API: This is the core service being accessed. Clearly show Redshift and, optionally, the Data API as a middleware service supporting asynchronous and synchronous SQL execution.
- CloudFormation and Deployment Scripts: Indicate the presence of CloudFormation templates (and additional YAML scripts) that help create the required AWS environment for the use cases.
- External Clients: Include potential connections from other AWS services (Amazon EC2, SageMaker, etc.) and on-premises applications as per the tutorial description.

##### Relationships and Data Flow
- Use Supplies: In the event-driven and orchestration cases, show how configuration or CloudFormation templates deploy the infrastructure, and how Lambda or Step Functions orchestrate ETL or chained calls.
- Both synchronous and asynchronous communication models (with annotations indicating query IDs and delayed result fetching for asynchronous operations).

##### Architectural Patterns and Design Principles
- Serverless Design: Since AWS Lambda is a recurring execution environment, indicate the decoupled, event-driven nature of this design.
- Infrastructure-as-Code: Mark areas where CloudFormation templates and deployment scripts come into play, signifying the automated provisioning and management of AWS resources.
- Modularity: Showcase the separation between data ingestion, processing, and data retrieval within the overall system design.

##### Relevant Technologies
- Programming Languages: Label sample components for Go, Java, JavaScript/TypeScript, and Python.
- AWS Services: Highlight AWS Lambda, Amazon Redshift, CloudFormation, AWS Step Functions, and optionally AWS Cognito (as referenced in the analytical reporting web app).
- Additional Deployment & Orchestration Interfaces: For use cases like ETL with Lambda and Step Functions, indicate both Lambda and Step Functions as interacting components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Quick Start Clients
    subgraph "Quick Start Clients"
        QSGo["Quick Start - Go"]:::client
        QSJava["Quick Start - Java"]:::client
        QSJS["Quick Start - JavaScript"]:::client
        QSPython["Quick Start - Python"]:::client
        QSTypescript["Quick Start - TypeScript"]:::client
    end

    %% Use-Case Implementations
    subgraph "Use-Case Implementations"
        UAWebApp["Analytical Reporting: EventDriven Web App"]:::usecase
        USETL["AWS Lambda Redshift ETL"]:::usecase
        UEC2["EC2 Redshift Access"]:::usecase
        USETLO["ETL Orchestration with Lambda&StepFunctions"]:::usecase
        ULLC["Lambda Chaining with Redshift Data API"]:::usecase
        USagemaker["Sagemaker Notebook Redshift ML"]:::usecase
    end

    %% AWS Lambda Functions
    subgraph "AWS Lambda Functions"
        LambdaETL["Lambda ETL Functions"]:::lambda
        LambdaChain["Lambda Chaining Functions"]:::lambda
    end

    %% CloudFormation & Deployment Scripts
    subgraph "CloudFormation & Deployment"
        CFWebApp["CloudFormation: EventDriven Web App"]:::cf
        CFEC2["CloudFormation: EC2 Redshift Access"]:::cf
        CFETL["CloudFormation: ETL Orchestration with Lambda&StepFunctions"]:::cf
        CFChain["CloudFormation: Lambda Chaining with Redshift Data API"]:::cf
        CFSagemaker["CloudFormation: Sagemaker Notebook Redshift ML"]:::cf
    end

    %% External Clients
    subgraph "External Clients"
        WebApp["Web App (HTML/CSS/JS)"]:::external
    end

    %% Core AWS Services
    RedshiftAPI["Redshift Data API"]:::api
    Redshift["Amazon Redshift Cluster"]:::database

    %% Connections from Quick Start Clients to AWS Lambda Functions
    QSGo -->|"invoke"| LambdaETL
    QSJava -->|"invoke"| LambdaETL
    QSPython -->|"invoke"| LambdaETL
    QSJS -->|"invoke"| LambdaChain
    QSTypescript -->|"invoke"| LambdaChain

    %% Connections from Use-Case Implementations
    UAWebApp -->|"triggers"| WebApp
    UAWebApp -->|"calls"| LambdaChain
    USETL -->|"executes"| LambdaETL
    UEC2 -->|"accesses"| Redshift
    USETLO -->|"orchestrates"| LambdaETL
    ULLC -->|"invokes"| LambdaChain
    USagemaker -->|"queries"| Redshift

    %% AWS Lambda Functions to Redshift Data API
    LambdaETL -->|"async"| RedshiftAPI
    LambdaChain -->|"sync"| RedshiftAPI

    %% Redshift Data API to Amazon Redshift
    RedshiftAPI -->|"SQLqueries"| Redshift

    %% CloudFormation Connections (dashed lines)
    CFWebApp -.-> WebApp
    CFEC2 -.-> Redshift
    CFETL -.-> LambdaETL
    CFChain -.-> LambdaChain
    CFSagemaker -.-> Redshift

    %% External Client to AWS Lambda Functions
    WebApp -->|"triggers"| LambdaChain

    %% Click Events for Quick Start Clients
    click QSGo "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/quick-start/go"
    click QSJava "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/quick-start/java"
    click QSJS "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/quick-start/javascript"
    click QSPython "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/quick-start/python"
    click QSTypescript "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/quick-start/typescript"

    %% Click Events for Use-Case Implementations
    click UAWebApp "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/analytical-reporting-event-driven-web-app"
    click USETL "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/aws-lambda-redshift-event-driven-etl"
    click UEC2 "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/ec2-redshift-access"
    click USETLO "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/etl-orchestration-with-step-functions"
    click ULLC "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/lambda-chaining-with-redshift-data-api"
    click USagemaker "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/sagemaker-notebook-redshift-ml"

    %% Click Events for AWS Lambda Functions
    click LambdaETL "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/aws-lambda-redshift-event-driven-etl"
    click LambdaChain "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/lambda-chaining-with-redshift-data-api"

    %% Click Events for CloudFormation & Deployment Scripts
    click CFWebApp "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/analytical-reporting-event-driven-web-app"
    click CFEC2 "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/ec2-redshift-access/cloud_formation_template"
    click CFETL "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/etl-orchestration-with-lambda-and-step-functions/cloud_formation_template"
    click CFChain "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/lambda-chaining-with-redshift-data-api/cloud_formation_template"
    click CFSagemaker "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/sagemaker-notebook-redshift-ml"

    %% Click Event for External Client
    click WebApp "https://github.com/aws-samples/getting-started-with-amazon-redshift-data-api/tree/main/use-cases/analytical-reporting-event-driven-web-app/Src_directory"

    %% Styling
    classDef client fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef usecase fill:#ffa500,stroke:#333,stroke-width:2px;
    classDef lambda fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef cf fill:#fdfd96,stroke:#333,stroke-width:2px;
    classDef external fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef api fill:#ffb6c1,stroke:#333,stroke-width:2px;
    classDef database fill:#ffcccb,stroke:#333,stroke-width:2px;
```
