How anomalyinnovations/serverless-stack-demo-api works
Project type and purpose
• This is a serverless backend API (built with the Serverless Framework) that supports a note-taking application.
• It exposes REST endpoints for CRUD operations on notes (create, list, get, update, delete) plus a billing endpoint.
• It relies on AWS Lambda functions, DynamoDB for persistence, Cognito for authentication/authorization, S3 (for attachments), and integrates with an external billing provider.
File structure
• Top-level Lambda handlers:
– billing.js, create.js, delete.js, get.js, list.js, update.js
• libs/: common utility code used by all handlers (dynamodb-lib.js, handler-lib.js, response-lib.js, billing-lib.js, debug-lib.js)
• resources/: standalone CloudFormation/YAML fragments (API Gateway error mappings, Cognito user & identity pools, DynamoDB table, S3 bucket)
• serverless.yml: ties it all together, defining functions, events (HTTP, authorizers), permissions, environment variables
• mocks/ & tests/: local function invocation events and Jest test cases
• package.json / .env reference: Node.js runtime, npm dependencies, secret config
README for additional insights
• Confirms use of Serverless Framework for deploying AWS resources
• Shows local invocation via serverless invoke local --function <name>
• Mentions a separate React frontend that calls this API
• Notes use of Cognito authorizer in API Gateway
a. Main components to represent
• React Frontend (external client)
• API Gateway
– HTTP endpoints for /notes (GET, POST, PUT, DELETE) and /billing
– Cognito User Pool authorizer
• AWS Lambda Functions
– Note CRUD handlers
– Billing handler
– Shared libs (DynamoDB helper, response helper, billing helper, etc.)
• Cognito
– User Pool (authentication)
– Identity Pool (temporary credentials)
• DynamoDB Table (notes)
• S3 Bucket (note attachments)
• External Billing Service (e.g., Stripe)
• Deployment layer: Serverless Framework / CloudFormation
b. Relationships & data flow
1. Frontend → HTTP request → API Gateway
2. API Gateway → Cognito authorizer (validate JWT)
3. API Gateway → invokes the corresponding Lambda function
4. Lambda function reads/writes DynamoDB and/or S3
5. Billing function → calls external billing provider API
6. Lambdas emit logs to CloudWatch Logs
c. Architectural patterns & principles
• Serverless / FaaS: each handler is a single-purpose Lambda
• Shared utility library to enforce common patterns (error handling, DynamoDB access)
• Infrastructure as Code: resources defined in serverless.yml and YAML fragments
• Event-driven: HTTP requests trigger events processed by functions
d. Technologies & frameworks
• Node.js Lambdas
• Serverless Framework (serverless.yml)
• AWS API Gateway
• AWS Lambda
• Amazon DynamoDB
• Amazon S3
• Amazon Cognito (User + Identity Pools)
• External billing SDK (stripe or similar)
• Jest for unit testing