# yasir2000/aws-tutorial-1 architecture

> Architecture diagram of the GitHub repository yasir2000/aws-tutorial-1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yasir2000/aws-tutorial-1
- Repository: https://github.com/yasir2000/aws-tutorial-1

## Overview

This is a serverless CRUD API for users, products, orders, authentication, files, and notifications, with AWS-backed production services and local mocks. Requests reach the relevant Lambda handlers, which validate input, enforce user-scoped access where implemented, persist records or files, and publish events; authentication also supports signup, signin, confirmation, and profile lookup. The README documents API Gateway/Lambda routing and SNS/SQS notification processing, but the deployment configuration and notification wiring were not sampled, so those relationships are shown only where documented or left unverified.

Main entry points: [`handlers/users.js`](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/users.js) (User CRUD), [`handlers/products.js`](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/products.js) (Product CRUD), [`handlers/orders.js`](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/orders.js) (Order CRUD), [`utils/response.js`](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/response.js) (HTTP Responses)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Handlers"]
  node_users["User CRUD<br/>[users.js]"]
  node_products["Product CRUD<br/>[products.js]"]
  node_orders["Order CRUD<br/>[orders.js]"]
  node_files["File API<br/>[files.js]"]
  node_admin["Admin API<br/>[admin.js]"]
  node_health["Health API<br/>[health.js]"]
end

subgraph group_identity["Identity &amp; Access"]
  node_auth_handler["Auth API<br/>[auth.js]"]
  node_token_auth["Token Auth<br/>[auth.js]"]
  node_user_extract["User Extraction<br/>[extractUser.js]"]
  node_mock_auth[("Mock Auth State<br/>[mockAuth.js]")]
end

subgraph group_storage["Persistence"]
  node_dynamodb["DynamoDB Adapter<br/>[dynamodb.js]"]
  node_mockdb[("Memory Database<br/>[mockdb.js]")]
  node_s3_adapter["S3 Adapter<br/>[s3.js]"]
end

subgraph group_events["Events &amp; Monitoring"]
  node_notifications["Notifications<br/>[notifications.js]"]
  node_sns_sqs["SNS / SQS"]
  node_metrics["Metrics<br/>[metrics.js]"]
end

subgraph group_shared["Shared Runtime"]
  node_logger["Logger<br/>[logger.js]"]
  node_error_handler["Error Middleware<br/>[error-handler.js]"]
  node_response["HTTP Responses<br/>[response.js]"]
  node_validation["Input Validation<br/>[validation.js]"]
end

node_client(("API Client"))
node_gateway{{"API Gateway"}}
node_cognito{{"Cognito"}}
node_s3_service[("AWS S3")]

node_client -->|"sends requests"| node_gateway
node_gateway -.->|"routes requests"| node_users
node_gateway -.->|"routes requests"| node_products
node_gateway -.->|"routes requests"| node_orders
node_gateway -.->|"routes requests"| node_files
node_gateway -.->|"routes requests"| node_auth_handler
node_users -->|"validates input"| node_validation
node_users -->|"extracts identity"| node_user_extract
node_users -->|"reads and writes"| node_dynamodb
node_users -->|"publishes events"| node_sns_sqs
node_products -->|"validates input"| node_validation
node_products -->|"extracts identity"| node_user_extract
node_products -->|"reads and writes"| node_dynamodb
node_products -->|"publishes events"| node_sns_sqs
node_orders -->|"validates input"| node_validation
node_orders -->|"extracts identity"| node_user_extract
node_orders -->|"reads and writes"| node_dynamodb
node_orders -->|"publishes events"| node_sns_sqs
node_files -->|"uses file storage"| node_s3_adapter
node_files -->|"extracts identity"| node_user_extract
node_s3_adapter -.->|"stores objects"| node_s3_service
node_auth_handler -->|"stores user records"| node_dynamodb
node_auth_handler -->|"uses local state"| node_mock_auth
node_auth_handler -->|"authenticates users"| node_cognito
node_token_auth -.->|"verifies production tokens"| node_cognito
node_user_extract -->|"extracts claims"| node_token_auth
node_dynamodb -->|"uses offline store"| node_mockdb
node_notifications -.->|"processes messages"| node_sns_sqs
node_error_handler -->|"logs failures"| node_logger
node_error_handler -->|"formats errors"| node_response
node_users -->|"formats responses"| node_response
node_products -->|"formats responses"| node_response
node_orders -->|"formats responses"| node_response
node_files -->|"formats responses"| node_response
node_auth_handler -->|"formats responses"| node_response
node_admin -->|"accesses records"| node_dynamodb
node_admin -->|"uses authorization"| node_token_auth
node_health -->|"formats responses"| node_response

click node_users "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/users.js"
click node_products "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/products.js"
click node_orders "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/orders.js"
click node_files "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/files.js"
click node_admin "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/admin.js"
click node_health "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/health.js"
click node_auth_handler "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/auth.js"
click node_notifications "https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/notifications.js"
click node_token_auth "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/auth.js"
click node_user_extract "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/extractUser.js"
click node_mock_auth "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/mockAuth.js"
click node_dynamodb "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/dynamodb.js"
click node_mockdb "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/mockdb.js"
click node_s3_adapter "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/s3.js"
click node_metrics "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/metrics.js"
click node_logger "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/logger.js"
click node_error_handler "https://github.com/yasir2000/aws-tutorial-1/blob/master/middleware/error-handler.js"
click node_response "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/response.js"
click node_validation "https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/validation.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_users,node_products,node_orders,node_files,node_admin,node_health,node_client toneBlue
class node_auth_handler,node_token_auth,node_user_extract,node_mock_auth,node_s3_service toneAmber
class node_dynamodb,node_mockdb,node_s3_adapter,node_gateway toneMint
class node_notifications,node_sns_sqs,node_metrics toneRose
class node_logger,node_error_handler,node_response,node_validation,node_cognito toneIndigo
```

## Components

### API Handlers

- [User CRUD](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/users.js): `handlers/users.js`
- [Product CRUD](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/products.js): `handlers/products.js`
- [Order CRUD](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/orders.js): `handlers/orders.js`
- [File API](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/files.js): `handlers/files.js`
- [Admin API](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/admin.js): `handlers/admin.js`
- [Health API](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/health.js): `handlers/health.js`

### Identity & Access

- [Auth API](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/auth.js): `handlers/auth.js`
- [Token Auth](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/auth.js): `utils/auth.js`
- [User Extraction](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/extractUser.js): `utils/extractUser.js`
- [Mock Auth State](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/mockAuth.js): `utils/mockAuth.js`

### Persistence

- [DynamoDB Adapter](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/dynamodb.js): `utils/dynamodb.js`
- [Memory Database](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/mockdb.js): `utils/mockdb.js`
- [S3 Adapter](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/s3.js): `utils/s3.js`

### Events & Monitoring

- [Notifications](https://github.com/yasir2000/aws-tutorial-1/blob/master/handlers/notifications.js): `handlers/notifications.js`
- **SNS / SQS**
- [Metrics](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/metrics.js): `utils/metrics.js`

### Shared Runtime

- [Logger](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/logger.js): `utils/logger.js`
- [Error Middleware](https://github.com/yasir2000/aws-tutorial-1/blob/master/middleware/error-handler.js): `middleware/error-handler.js`
- [HTTP Responses](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/response.js): `utils/response.js`
- [Input Validation](https://github.com/yasir2000/aws-tutorial-1/blob/master/utils/validation.js): `utils/validation.js`

### Other components

- **API Client**
- **API Gateway**
- **Cognito**
- **AWS S3**

## Connections

- API Client → API Gateway: sends requests (evidence: `README.md`)
- API Gateway → User CRUD: routes requests
- API Gateway → Product CRUD: routes requests
- API Gateway → Order CRUD: routes requests
- API Gateway → File API: routes requests
- API Gateway → Auth API: routes requests
- User CRUD → Input Validation: validates input (evidence: `handlers/users.js`)
- User CRUD → User Extraction: extracts identity (evidence: `handlers/users.js`)
- User CRUD → DynamoDB Adapter: reads and writes (evidence: `handlers/users.js`)
- User CRUD → SNS / SQS: publishes events (evidence: `handlers/users.js`)
- Product CRUD → Input Validation: validates input (evidence: `handlers/products.js`)
- Product CRUD → User Extraction: extracts identity (evidence: `handlers/products.js`)
- Product CRUD → DynamoDB Adapter: reads and writes (evidence: `handlers/products.js`)
- Product CRUD → SNS / SQS: publishes events (evidence: `handlers/products.js`)
- Order CRUD → Input Validation: validates input (evidence: `handlers/orders.js`)
- Order CRUD → User Extraction: extracts identity (evidence: `handlers/orders.js`)
- Order CRUD → DynamoDB Adapter: reads and writes (evidence: `handlers/orders.js`)
- Order CRUD → SNS / SQS: publishes events (evidence: `handlers/orders.js`)
- File API → S3 Adapter: uses file storage (evidence: `handlers/files.js`)
- File API → User Extraction: extracts identity (evidence: `handlers/files.js`)
- S3 Adapter → AWS S3: stores objects
- Auth API → DynamoDB Adapter: stores user records (evidence: `handlers/auth.js`)
- Auth API → Mock Auth State: uses local state (evidence: `handlers/auth.js`)
- Auth API → Cognito: authenticates users (evidence: `handlers/auth.js`)
- Token Auth → Cognito: verifies production tokens
- User Extraction → Token Auth: extracts claims (evidence: `utils/extractUser.js`)
- DynamoDB Adapter → Memory Database: uses offline store (evidence: `utils/dynamodb.js`)
- Notifications → SNS / SQS: processes messages
- Error Middleware → Logger: logs failures (evidence: `middleware/error-handler.js`)
- Error Middleware → HTTP Responses: formats errors (evidence: `middleware/error-handler.js`)
- User CRUD → HTTP Responses: formats responses (evidence: `handlers/users.js`)
- Product CRUD → HTTP Responses: formats responses (evidence: `handlers/products.js`)
- Order CRUD → HTTP Responses: formats responses (evidence: `handlers/orders.js`)
- File API → HTTP Responses: formats responses (evidence: `handlers/files.js`)
- Auth API → HTTP Responses: formats responses (evidence: `handlers/auth.js`)
- Admin API → DynamoDB Adapter: accesses records (evidence: `handlers/admin.js`)
- Admin API → Token Auth: uses authorization (evidence: `handlers/admin.js`)
- Health API → HTTP Responses: formats responses (evidence: `handlers/health.js`)
