Skip to content

jenishk20/splitwise-splitter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SplitMate – AI Powered Expense Splitter

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.


Features

Core

  • 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.

Admin Dashboard

  • User analytics and activity
  • File processing logs
  • Bug reporting and resolution tracking

Serverless Architecture Overview

Backend Powerhouse (AI Parsing Pipeline)

  1. Upload Invoice
    Frontend receives a signed S3 URL from a Lambda function and uploads the invoice image.

  2. S3 Trigger
    S3 triggers a Lambda (s3-to-sqs-dispatcher) which sends a message to SQS (decouples upload from processing).

  3. SQS Consumer Lambda
    Another Lambda (invoice-processor) polls SQS → fetches the image from S3 → sends it to Claude via Amazon Bedrock.

  4. Parsing & Storage
    Claude responds with structured JSON → Result is saved in MongoDB and marked as Done.

  5. Error Handling
    Failed processing jobs are automatically retried and eventually sent to a Dead Letter Queue (DLQ) for manual inspection.

Flow Diagram ( Generated from User Flow and Business Logic )

Flow Diagram

Architecture Diagram ( Generated from Cloudformation Template )

Architecture


AWS Lambda & Layers

  • 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

Lambda Layers

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

SQS & Dead Letter Queue Architecture

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

Tech Stack

Frontend

  • Next.js 13+
  • Tailwind CSS + Shadcn UI
  • Lucide Icons

Backend

  • 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

Challenges We Ran Into

  • 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

Accomplishments

  • 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

What We Learned

  • 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

What's Next

  • 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

About

SplitMate is an AI-powered expense manager that automates group bill splitting using OCR, AWS Lambda, Textract, Claude, and MongoDB. Upload receipts, parse them instantly, and let friends opt in/out of individual items — all in a clean UI. Built for real-world collaboration and financial fairness.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors