Infinitely Scalable Serverless System for Receipt Parsing and Group Expense Management
SplitMate is a modern web application that transforms how groups split bills. Whether you're managing groceries, dining out, or any shared expense, SplitMate uses AI and serverless infrastructure to automatically parse receipts, handle opt-in logic, and finalize splits via Splitwise.
Built on an event-driven, serverless architecture that scales effortlessly using AWS Lambda, S3, and SQS.
- AI-Driven Receipt Parsing: Upload an invoice → Claude Vision (via Amazon Bedrock) extracts items → Group members opt-in/out → Final split on Splitwise.
- Infinitely Scalable Backend: Async, event-driven pipeline using AWS Lambda, SQS, and S3.
- Job Queuing System: Background tasks decoupled via SQS for high-throughput workloads.
- Real-Time Status Tracking: MongoDB keeps track of parsing progress and completion.
- Opt-In Based Splits: Every group member sees parsed items and marks what they consumed.
- User analytics and activity
- File processing logs
- Bug reporting and resolution tracking
-
Upload Invoice
Frontend receives a signed S3 URL from a Lambda function and uploads the invoice image. -
S3 Trigger
S3 triggers a Lambda (s3-to-sqs-dispatcher) which sends a message to SQS (decouples upload from processing). -
SQS Consumer Lambda
Another Lambda (invoice-processor) polls SQS → fetches the image from S3 → sends it to Claude via Amazon Bedrock. -
Parsing & Storage
Claude responds with structured JSON → Result is saved in MongoDB and marked asDone. -
Error Handling
Failed processing jobs are automatically retried and eventually sent to a Dead Letter Queue (DLQ) for manual inspection.
- upload-handler – Generates signed S3 upload URLs
- s3-to-sqs-dispatcher – Triggered on image upload to S3; sends job info to SQS
- invoice-processor – Polls SQS, retrieves image, calls Claude, updates MongoDB
SplitMate leverages Lambda Layers to optimize deployment size and promote code reuse across multiple Lambda functions:
-
MongoDB SDK Layer:
- Contains MongoDB driver and connection utilities
- Provides standardized database access patterns and error handling
- Reduces individual Lambda deployment sizes by ~15MB
- Enables consistent connection pooling across all database operations
-
Bedrock SDK Layer:
- Encapsulates AWS Bedrock SDK and Claude 3 Vision integration logic
- Handles multimodal inference payloads and response parsing
- Provides retry mechanisms and error handling for AI service calls
- Includes prompt engineering utilities and response validation
To ensure robust processing of invoice uploads, SplitMate implements a comprehensive queue-based system:
-
Primary SQS Queue:
- Receives invoice processing jobs from S3 trigger Lambda
- Configured with visibility timeout of 5 minutes
- Enables automatic retry of failed processing attempts (up to 3 retries)
-
Dead Letter Queue (DLQ):
- Captures invoices that fail processing after maximum retry attempts
- Enables manual inspection and debugging of problematic uploads
- Prevents infinite retry loops and resource waste
- Integrates with CloudWatch alarms for operational monitoring
-
Failure Scenarios Handled:
- Bedrock service timeouts or rate limiting
- MongoDB connection failures
- Corrupted or unreadable invoice images
- Invalid S3 object permissions or missing files
- Next.js 13+
- Tailwind CSS + Shadcn UI
- Lucide Icons
- ExpressJS API (deployed on Render)
- MongoDB Atlas
- AWS Lambda for asynchronous job processing
- S3 for file storage
- SQS for decoupling uploads and processing
- Bedrock Claude for image parsing
- Understanding and formatting Bedrock payloads for image-based inference
- Handling S3 event listener conflicts when multiple Lambdas target the same bucket
- CloudFormation rollbacks when buckets weren't empty or had conflicting configs
- Built a cleanly decoupled and infinitely scalable MVP
- Integrated Claude Vision in production-grade workflow
- Enabled real-time item opt-in/out per user with backend sync
- Building event-driven serverless apps with AWS Lambda, SQS, S3
- Secret management using AWS SecretsManager
- Bedrock Claude 3 Vision usage for multimodal inference
- Async job orchestration in production-like environments
- Build a mobile version with camera-based invoice uploads
- Add item-level heuristics (weights, discounts, etc.) to improve splitting logic
- Implement audit trails and confirmation flows for group members

