Serverless Product Visits Web App

Full-Stack AWS Serverless Application | SQS, Lambda, DynamoDB, API Gateway, S3

Project Overview

A production-grade serverless application built on AWS to capture, process, and analyze product visit data. This project demonstrates end-to-end cloud architecture including event-driven processing, data streaming, API integration, and automated compliance monitoring.

Architecture Highlights

Technologies Used

AWS Services: Lambda (Node.js 22.x), DynamoDB, DynamoDB Streams, SQS, S3, API Gateway, CloudTrail, EventBridge, SNS, IAM, CloudWatch Logs

Development Tools: AWS CLI, CloudShell, API Gateway JavaScript SDK

Part 1: Event-Driven Data Processing Pipeline

Objective

Build the core data pipeline: SQS queue receives product order messages, triggers Lambda function, which writes to DynamoDB table. Establish CloudWatch Logs as the primary troubleshooting tool.

Implementation Details

DynamoDB Table Configuration

DynamoDB ProductVisits Table

SQS Queue Setup

SQS Queue Configuration

Lambda Function

Lambda Function Configuration Lambda DynamoDB Permissions Lambda SQS Permissions

Testing & Validation

Used AWS CLI from CloudShell to send JSON-formatted product order messages to the SQS queue. Each message contained product details (ProductId, ProductName, Category, Price, CustomerId, CustomerName, TimeOfVisit).

Sending Messages via CLI

Lambda function successfully processed messages from the queue and wrote to DynamoDB. Verified data integrity by scanning the table, confirming 5 product orders were stored correctly.

DynamoDB Data Verification

Key Learnings

Part 2: Data Lake Integration with DynamoDB Streams

Objective

Enable real-time data streaming from DynamoDB to S3 data lake. Capture item-level changes using DynamoDB Streams and trigger Lambda to write data to S3 in a partitioned folder structure.

Implementation Details

DynamoDB Streams Configuration

DynamoDB Stream Configuration

S3 Data Lake

S3 Data Lake Bucket

Lambda Function for Stream Processing

Data Lake Lambda Function

IAM Policy Configuration

Custom-managed policy productVisitsLoadingLambdaPolicy initially had incorrect S3 permissions.

Initial IAM Policy

CloudWatch Logs revealed AccessDenied error for S3 PutObject:

AccessDenied Error in CloudWatch

Fixed by updating policy with exact bucket ARN:

Corrected IAM Policy with Specific ARN

Testing & Validation

Re-sent messages to SQS queue via CloudShell to trigger DynamoDB writes, which in turn triggered the stream.

Testing with CloudShell

Verified S3 bucket contains date-partitioned folders with product visit data:

S3 Year Folder Structure S3 Month Folder Structure

Key Learnings

Part 3: Web Frontend with API Gateway Integration

Objective

Build a static web frontend that submits product visit data through API Gateway, which triggers Lambda to send messages to SQS, completing the end-to-end data flow.

Implementation Details

Lambda Function for API Integration

API Lambda Function Lambda Execution Role

IAM Policy for SQS Access

Custom-managed policy productVisitsSendMessageLambdaPolicy:

IAM Policy Creation IAM Policy Review

API Gateway REST API

API Gateway Creation API Gateway Resource API Gateway PUT Method Lambda Proxy Integration API Gateway Request Flow

Static Website Hosting

S3 Sync Upload Part 1 S3 Sync Upload Part 2 S3 Bucket Files

Web Form

Simple HTML form with fields for product visit data:

Product Visit Web Form

Testing & Validation

Submitted product visits through web form. Data flowed through API Gateway → Lambda → SQS → Lambda → DynamoDB. Verified 18 total items in DynamoDB (5 from CLI testing + 13 from web form):

DynamoDB with Web Form Data

Key Learnings

Part 4: Compliance Monitoring & Alerting

Objective

Implement automated change tracking and real-time alerting for S3 bucket configuration changes. Use CloudTrail for audit logging, EventBridge for event detection, and SNS for email notifications.

Implementation Details

CloudTrail Configuration

CloudTrail Multi-Region Trail

SNS Topic for Email Alerts

SNS Topic Configuration

EventBridge Rule

EventBridge Rule for S3 Changes

Testing & Validation

Deleted bucket policy on product-visits-webform bucket (then immediately restored it). CloudTrail captured the API call, EventBridge matched the event pattern, and SNS delivered email alert within seconds:

Email Alert from AWS Notifications

Key Learnings

Architecture Diagram

Data Flow:

  1. User submits product visit form → S3 static website
  2. JavaScript calls API Gateway → /productVisit PUT method
  3. API Gateway triggers productVisitsSendDataToQueue Lambda
  4. Lambda sends message to ProductVisitsDataQueue SQS
  5. SQS triggers productVisitsDataHandler Lambda
  6. Lambda writes to ProductVisits DynamoDB table
  7. DynamoDB Stream captures change
  8. Stream triggers productVisitsDatalakeLoadingHandler Lambda
  9. Lambda writes to product-visits-datalake S3 bucket
  10. CloudTrail logs all API calls
  11. EventBridge monitors S3 configuration changes
  12. EventBridge triggers SNS for email alerts

Components:

Skills Demonstrated

Lessons Learned

Future Enhancements

Conclusion

This serverless application demonstrates a complete, production-ready architecture for capturing, processing, and analyzing product visit data. By leveraging AWS managed services, the solution achieves:

The project showcases expertise in AWS cloud services, event-driven architecture, IAM security, and modern application development patterns. It represents the type of scalable, cost-effective solutions that drive business value in cloud-native environments.