How masanthimanshu/pookie-lambda works
What this project is (type + purpose)
From the file tree, this is an AWS Serverless (Node.js) project packaged/deployed via Serverless Framework (serverless.yaml). It implements an API-oriented Lambda service with a clear CQRS-ish split between:
• Read path: src/read/*
• Write path: src/write/*
It also provisions/depends on a DynamoDB table (likely) via infrastructure templates in aws/ (aws/database.yaml). The minimal README title (“Add Pookie Data Lambda Function”) suggests the Lambda’s purpose is to add/manage some “Pookie” data, but the architecture is the key: *Lambda + DynamoDB + HTTP entrypoints + validation/schema*.
Top-level
• serverless.yaml: primary service definition (functions, events like HTTP/API Gateway routes, IAM permissions, env vars).
• aws/database.yaml: CloudFormation/SAM-like infra for DynamoDB (table, indexes, streams, etc.).
• .github/workflows/*:
• lambda-deploy.yaml: CI/CD pipeline for deploying the Lambda (likely serverless deploy).
• check-issues.yaml: repo hygiene automation (not runtime, but include in “delivery” view if desired).
Runtime code
• src/read/handler.js, src/write/handler.js: Lambda entrypoints (each is a function handler).
• src/read/routes.js, src/write/routes.js: route definitions (suggests an internal router / mini web framework usage).
• src/write/controller.js: write orchestration/business logic.
• core/create_app.js: likely builds an app/router abstraction (Express-like) for Lambda handlers.
• core/dynamo_client.js: DynamoDB client wrapper (AWS SDK v2/v3).
• core/runtime_logs.js: logging utility (structured logs, correlation ids, etc.).
• data/schema.js, data/validator.js: domain schema + validation logic (input validation for writes, maybe output shaping).
Lambda Handler → App/Router → Route Handler/Controller → Validation/Schema → DynamoDB client → DynamoDB
Runtime/Request Flow (Container-level)
Main components to include:
Client (caller)
2. API Gateway (or Lambda Function URL) — *you confirm by reading serverless.yaml “events: http/httpApi”*
Lambda Functions
• ReadFunction (from src/read/handler.js)
• WriteFunction (from src/write/handler.js)
DynamoDB Table
• provisioned via aws/database.yaml
(Optional but recommended) CloudWatch Logs
• because core/runtime_logs.js indicates explicit runtime logging
Code/Module Architecture (Component-level inside Lambda)
• handler.js (entry)
• create_app.js (app bootstrap)
• routes.js (route mapping)
• controller.js (write side)
• validator.js + schema.js (data validation)
• dynamo_client.js (DB adapter)
• DynamoDB (external dependency)
This is where you “separate into as many components as possible” for clarity and correctness.
Important architectural patterns/design principles to highlight
• CQRS-like separation: distinct read/write functions and modules (src/read vs src/write)
• Layering:
• Entry/transport: handlers
• Routing: routes + create_app
• Business logic: controllers (write)
• Domain integrity: schema + validator
• Persistence adapter: dynamo_client
• Infrastructure as Code: serverless.yaml and aws/database.yaml
• CI/CD: GitHub Actions deploy workflow