# vijaypratapsinghhada/fetch-data-with-aws-lambda architecture

> Architecture diagram of the GitHub repository vijaypratapsinghhada/fetch-data-with-aws-lambda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vijaypratapsinghhada/fetch-data-with-aws-lambda
- Repository: https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda

## Overview

##### Project type and purpose
- This is a small serverless data-tier project demonstrating how to fetch user data from Amazon DynamoDB via an AWS Lambda function.
- There is no web client or “frontend” in the code; it’s purely a backend compute and data-storage example.

##### File structure
- Top-level files:
- Add_Table.json – sample payload to load a user record into the “UserData” DynamoDB table.
- Add_function_code.js – the Lambda function code using the AWS SDK to call DynamoDB.
- Images/PH – screenshots used in the README.
- README.md – full project description, AWS services used, and configuration.
- No build scripts or CI/CD files here; deployment is implied via the AWS console or CloudFormation.

##### Extract architecture details from the README
- Primary AWS services:
- AWS Lambda (compute)
- Amazon DynamoDB (NoSQL data store)
- Amazon CloudWatch (logging)
- IAM (execution-role and inline policy)
- Code dependencies: AWS SDK for JavaScript (pre-installed in Lambda runtime).
- Execution flow: Test event → Lambda invocation → DynamoDB.GetItem → return payload → CloudWatch logs.

##### Main components to illustrate
a. Event source / Test harness
b. AWS Lambda function (Add_function_code.js)
c. IAM Role & Policies (AmazonDynamoDBReadOnlyAccess or inline policy)
d. Amazon DynamoDB table (“UserData”)
e. Amazon CloudWatch Logs
f. Sample data loader (Add_Table.json)

##### Relationships and interactions
- Optionally, show a one-time process loading Add_Table.json into DynamoDB as a sample-data ingestion step.

##### Architectural patterns & design principles
- Serverless architecture: no servers to manage; pay-per-use compute.
- Three-tier separation:
- Presentation/Test harness (invoker)
- Compute/API layer (Lambda)
- Data tier (DynamoDB)
- Principle of least privilege: use a read-only policy scoped to the “UserData” table.

##### Relevant technologies and libraries
- AWS SDK for JavaScript (Node.js runtime)
- DynamoDB JSON data model (schemaless design)
- Inline JSON policy examples for IAM
- CloudWatch for observability

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Invoker
    TestHarness["Test Harness\n(Add_Table.json)"]:::external

    %% AWS Cloud Boundary
    subgraph "AWS Cloud"
        direction TB
        LambdaFunc["AWS Lambda\n(fetchUserData)"]:::lambda
        IAMRole["IAM Role & Policies"]:::security
        DynamoDB["Amazon DynamoDB\n(UserData)"]:::database
        CloudWatch["Amazon CloudWatch Logs"]:::logging
        Loader["Sample Data Loader\n(Add_Table.json)"]:::external
        Docs["Project Docs"]:::docs
        ImagesPH["Screenshots"]:::docs
    end

    %% Connections
    TestHarness -->|"1 Invoke"| LambdaFunc
    Loader -->|"Load sample data"| DynamoDB
    LambdaFunc -->|"2 GetItem"| DynamoDB
    LambdaFunc -->|"3 Log"| CloudWatch
    IAMRole -.-> LambdaFunc

    %% Click Events
    click TestHarness "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/blob/main/Add_Table.json"
    click Loader "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/blob/main/Add_Table.json"
    click LambdaFunc "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/blob/main/Add_function_code.js"
    click IAMRole "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/blob/main/README.md"
    click Docs "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/blob/main/README.md"
    click ImagesPH "https://github.com/vijaypratapsinghhada/fetch-data-with-aws-lambda/tree/main/Images/PH"

    %% Styles
    classDef external fill:#f2f2f2,stroke:#333,stroke-width:1px;
    classDef lambda fill:#6e5494,stroke:#333,stroke-width:1px,color:#fff;
    classDef database fill:#00a36c,stroke:#333,stroke-width:1px,color:#fff;
    classDef logging fill:#f90,stroke:#333,stroke-width:1px;
    classDef security fill:#999,stroke:#333,stroke-width:1px,color:#fff;
    classDef docs fill:#eef,stroke:#333,stroke-width:1px;
```
