
Weekend Annoying Task Challenge: Expense Sorter - AI That Turns Receipt Chaos Into Organized Expenses in Seconds
AI-powered expense tracker that automatically categorizes receipts using AWS Textract + Bedrock. Built for AWS Weekend Challenge.
Vision & What the App Does :
As someone who juggles multiple expenses daily groceries, fuel, subscriptions, dining out one of my most dreaded monthly tasks is sorting through a pile of receipts to figure out where my money went. With 30-40 receipts per month, manually entering each one into a spreadsheet takes 2-3 hours not because it's hard, but because it's mind-numbingly repetitive and easy to procrastinate.
Expense Sorter is an AI-powered receipt categorization app that automates this exact pain point. Users upload a receipt image (photo of a bill, screenshot of an order), and the AI instantly:
- Extracts all text from the receipt using OCR
- Identifies the vendor, date, and total amount
- Categorizes the expense automatically (Food, Transport, Shopping, Utilities, Subscriptions, Entertainment, Health, Other)
- Lists individual items with their prices
- Stores everything in a searchable, filterable dashboard
- Exports to CSV for spreadsheet use
Expense Sorter doesn't require manual data entry it acts as an intelligent receipt scanner. Upload a receipt photo, and within 15 seconds you have a fully categorized expense entry. What previously took 2-3 hours of spreadsheet work now takes zero effort. Just snap
How I Built It :
Development Process
I started by identifying the core workflow:
Receipt Image → Text Extraction → AI Analysis → Structured Expense Data → Dashboard Display.
The key architectural decision was chaining two AI services — Amazon Textract for OCR and Amazon Bedrock for intelligent categorization — to handle the full pipeline from raw image to structured, categorized data.
Key Decisions:
- Amazon Textract for OCR — it handles crumpled, blurry, and angled receipt photos surprisingly well, extracting text line by line
- Amazon Bedrock Nova Lite as the categorization engine — fast, cheap (~$0.0002/request), and returns clean structured JSON when prompted correctly
- Serverless architecture — Lambda + API Gateway means zero infrastructure management and pay-per-use pricing (perfect for a personal finance tool that's used daily but not continuously)
- Event-driven processing — S3 upload automatically triggers the processing Lambda via S3 event notifications, eliminating the need for polling or manual triggers
- Pre-signed URLs for upload — secure, direct-to-S3 uploads without routing large image files through API Gateway (which has a 10MB limit)
- Single-page frontend — no build tooling needed; vanilla HTML/CSS/JS hosted on S3 keeps deployment simple and fast
DynamoDB with on-demand capacity — stores all expense records with PAY_PER_REQUEST billing, meaning zero cost when not in use
Challenges & Solutions :
Challenge 1: Consistent JSON output from LLM The AI sometimes wrapped responses in markdown code blocks (
json ... ) or added explanatory text before/after the JSON. I added defensive parsing logic that strips markdown wrappers, handles both clean JSON and wrapped JSON, and falls back gracefully if parsing fails.Challenge 2: Prompt engineering for accurate categorization Early prompts confused "Starbucks" as Shopping instead of Food, and "Amazon" as always Shopping even for grocery deliveries. I refined the system prompt to explicitly define each category with examples and instructed the model to analyze the actual items purchased rather than just the vendor name.
Challenge 3: Receipt image quality variation Real-world receipts are crumpled, faded, photographed at angles, and sometimes partially cut off. Textract handles this remarkably well out of the box, but I added error handling for cases where no text is extracted (corrupted images, blank uploads, non-receipt images).
Challenge 4: Processing time and user experience The full pipeline (S3 trigger → Lambda cold start → Textract → Bedrock → DynamoDB) takes 10-15 seconds. Without feedback, users think the app is broken. I added progressive status messages in the UI (" Uploading...", " AI is analyzing...", " Done!") so users know exactly what's happening.
Challenge 5: CORS configuration Cross-origin requests between the S3-hosted frontend and API Gateway required careful CORS setup. Both the API Gateway and S3 bucket needed proper CORS headers. This was the last bug I fixed as is tradition with web development.
AWS Services Used / Architecture Overview :
Architecture Diagram :
┌──────────────────┐ ┌─────────────────┐ ┌──────────────────────┐│ Frontend │────▶│ API Gateway │────▶│ AWS Lambda ││ (S3 Static) │ │ (REST API) │ │ (Python 3.13) ││ │ │ │ │ ││ Drag & Drop │ │ GET /expenses │ │ - process_receipt ││ Upload Area │ │ GET /export │ │ - get_expenses ││ Dashboard │ │ GET /upload-url│ │ - export_expenses ││ Filters │ │ │ │ - get_upload_url │└──────────────────┘ └─────────────────┘ └───────────┬──────────┘ │ ┌─────────▼──────────┐ │ Amazon Textract │ │ (OCR Engine) │ │ Extracts text │ │ from receipt │ └─────────┬──────────┘ │ ┌─────────▼──────────┐ │ Amazon Bedrock │ │ (Nova Lite v1) │ │ AI categorization │ └─────────┬──────────┘ │ ┌─────────▼──────────┐ │ Amazon DynamoDB │ │ ExpenseSorterTable│ │ (PAY_PER_REQUEST) │ └────────────────────┘AWS Services :
AWS Service | Role | Free Tier |
|---|---|---|
Amazon S3 | Two buckets — receipt image storage + static website hosting for frontend | 5GB free |
AWS Lambda (Python 3.13) | Four serverless functions handling processing, querying, exporting, and URL generation | 1M requests/month free |
Amazon Textract | OCR engine — extracts text from receipt images (handles photos, scans, screenshots) | 1,000 pages/month free |
Amazon Bedrock (Nova Lite) | AI categorization engine — analyzes extracted text and returns structured expense data | ~$0.0002/request |
Amazon API Gateway | REST API with CORS support, connecting frontend to Lambda functions | 1M calls/month free |
Amazon DynamoDB | NoSQL database storing all expense records with on-demand capacity | 25GB free |
AWS SAM | Infrastructure as Code — entire stack defined in one template.yaml | Free |
AWS CloudFormation | Resource provisioning and management (used by SAM under the hood) | Free |
How the Agent is Triggered :
- The user drops a receipt image on the web frontend
- Frontend requests a pre-signed URL from the
/upload-urlLambda endpoint
- Image uploads directly to S3 (bypassing API Gateway size limits)
- S3 automatically triggers the
ProcessReceiptLambda function via S3 Event Notification (event-driven no polling!)
- Lambda calls Textract to extract text from the receipt image
- Lambda sends extracted text to Bedrock Nova Lite with a structured prompt
- Bedrock returns categorized expense data as JSON
- Lambda parses and stores the result in DynamoDB
- Frontend polls
/expensesendpoint and displays the new entry in the dashboard
Deployment
The entire infrastructure is defined as Infrastructure-as-Code using AWS SAM (
template.yaml ). A single sam deploy command provisions all resources — S3 buckets, Lambda functions, DynamoDB table, API Gateway, IAM roles, S3 event triggers, and bucket policies.# Buildcd backendsam build
# Deploy (creates ALL resources automatically)sam deploy --guided
# Upload frontendaws s3 sync frontend/ s3://expense-sorter-frontend-ACCOUNT_ID/Three commands. Entire app is live. ✅

What I Learned :
- Chaining AI services creates powerful pipelines — Textract for OCR + Bedrock for intelligence creates a system that's greater than the sum of its parts. Neither service alone could handle the full receipt-to-categorized-expense pipeline, but together they're remarkably effective.
- SAM CLI makes serverless deployment trivial — defining Lambda functions, API Gateway, DynamoDB, S3 buckets, IAM policies, and event triggers in a single YAML file and deploying with one command is a massive productivity boost. What would take 20+ console screens takes 3 terminal commands.
- Structured output from LLMs requires defensive parsing — you can't assume the model will always return clean JSON. Building in fallback parsing (handling markdown code blocks, trailing text, malformed responses) made the system robust in production.
- Pre-signed URLs are the right pattern for file uploads — routing large image files through API Gateway + Lambda is slow, hits size limits, and wastes compute. Direct-to-S3 uploads with pre-signed URLs are fast, secure, and infinitely scalable.
- Event-driven architecture eliminates complexity — S3 triggers Lambda automatically on upload. No cron jobs, no polling loops, no wasted compute. The system only runs (and costs money) when there's actual work to do.
- Starting simple wins — I initially planned to add user authentication (Cognito), monthly reports with charts, budget alerts, and duplicate detection. By focusing on the core workflow (upload receipt → get categorized expense), I shipped a working tool in one weekend that solves my actual problem today.
- Serverless is perfect for personal tools — I use this app daily but not continuously. Pay-per-use means my monthly cost is under $0.05, compared to running an EC2 instance 24/7 for a tool I use for 5 minutes a day.
Link to App & Repo
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article