<HC />
Back to Projects
Cloud & Serverless ArchitectureCompleted

Pulse — Real-Time Emotion Detection on AWS

A real-time facial recognition and emotion detection platform built on AWS serverless architecture that indexes face identities, detects emotional states, infers drowsiness, and surfaces live leaderboards and CloudWatch dashboards.

AWS LambdaAWS RekognitionAWS DynamoDBAWS S3AWS CloudWatchAWS SNSAWS SQSAWS EC2PythonFlaskboto3PowerShell

Key Metrics

Event-Driven Serverless Pipeline

80% Confidence

O(1) Atomic Reads

S3 ObjectCreated Event

~2,500 Captures/Month

Overview

Pulse is a real-time emotion detection and facial recognition platform hosted on AWS. The system captures webcam photos or uploads, indexes identities via Amazon Rekognition face collections, detects emotional states and derived drowsiness metrics, and maintains live leaderboards using DynamoDB atomic counters and CloudWatch dashboards.

Problem

Building high-throughput facial analysis systems traditionally requires running persistent machine learning servers for image processing and executing expensive database aggregation queries on every page load to display live analytics and leaderboards.

Solution

Architected an event-driven serverless processing pipeline using AWS S3, Lambda, and boto3. Image uploads asynchronously trigger a Lambda processor where Rekognition identifies users and detects emotions, updating atomic DynamoDB counters for O(1) leaderboard reads while pushing custom metrics to CloudWatch.

Architecture

Event-driven serverless cloud architecture. A Flask application hosted on AWS EC2 handles user capture and uploads images to S3. Uploads trigger an asynchronous S3 ObjectCreated event that executes an AWS Lambda processor. Lambda invokes Amazon Rekognition (IndexFaces, SearchFacesByImage, detect_faces), updates 3 DynamoDB tables (Faces, Detections, Stats), emits custom metrics to CloudWatch dashboards, routes alerts via SNS for negative or sleepy states, and redirects failed invocations to an SQS Dead-Letter Queue (DLQ).

Challenges

  • Inferring drowsiness ("sleepy" state) from Rekognition's native EyesOpen attribute confidence scores to overcome managed API limitations.
  • Designing an event-driven S3-to-Lambda pipeline that processes image uploads asynchronously without blocking user interactions.
  • Eliminating database scan-and-aggregate overhead on page loads by using DynamoDB ADD atomic counters for O(1) leaderboard reads.
  • Automated provisioning and teardown of 8 interconnected AWS services using python boto3 scripts (setup_infrastructure.py & teardown_infrastructure.py).
  • Implementing reliable dead-letter queue (DLQ) patterns with AWS SQS for unprocessable image payloads.

Lessons Learned

  • Event-driven serverless architecture patterns using S3 triggers and Lambda.
  • Identity matching and face collection indexing using Amazon Rekognition.
  • Atomic counter modeling in DynamoDB for real-time leaderboard performance.
  • Infrastructure-as-code automation using Python and boto3 SDK.
  • Custom metric reporting and operational dashboarding in AWS CloudWatch.
  • Failure management strategies with SQS Dead-Letter Queues.

Future Improvements

  • AWS API Gateway integration to make the read path completely serverless.
  • Serving captured assets via AWS CloudFront CDN with signed URLs.
  • Automated SQS Dead-Letter Queue drainage and retry processor.
  • Automated CloudWatch Alarms for sleepiness thresholds connected to SNS alerts.
  • AWS Cognito authentication for Flask API endpoints.