Build · 4h · ₹0
A full-stack personal finance platform combining multimodal Gemini receipt scanning with Inngest background event jobs, Arcjet rate-limiting, and automated Resend email digests.
What it does
The mechanics, data flow, and user interaction model behind AI Finance Manager.
Users manage multiple accounts (current, savings), track cashflow, and establish dynamic monthly budget thresholds. The core differentiator is multimodal receipt extraction: upload or photograph a physical receipt, and Gemini 2.0 Flash extracts the total amount, purchase date, merchant name, line items, and expense category automatically into structured Prisma database entries without manual typing. Recurring transaction cycles, monthly budget-limit evaluations, and personalized financial health digests run as asynchronous background jobs via Inngest. Budget threshold alerts and monthly financial reports are composed with React Email and delivered via Resend.
Technical Highlights
- Multimodal Gemini 2.0 vision extraction transforming raw camera receipt photos into validated JSON transactions
- Asynchronous background job engine (Inngest) managing recurring expenses, monthly rollover audits, and budget threshold checks
- Edge security & bot protection via Arcjet rate limiting and shield rules layered with Clerk authentication
- Transactional email pipeline (React Email + Resend) dispatching automated budget breach alerts and monthly PDF-style digests
- Next.js 15 App Router architecture with Prisma ORM, Neon serverless PostgreSQL, and Shadcn UI components
Why it matters
The architectural judgment, practical engineering decisions, and core problems solved.
Manual data entry is the primary failure mode of personal budgeting tools — the friction of typing in every grocery slip or coffee receipt causes user abandonment within weeks. Automating data capture with vision models directly solves the product's highest friction point rather than tacking on an unrelated chatbot. Backed by Inngest event queues, Clerk authentication, and Arcjet shield rate-limiting, it represents a production-grade blueprint for modern AI-driven financial SaaS.
Personal expense tracking and zero-friction receipt archival for freelancers and professionals
Family & household budget management across multiple bank accounts and debit cards
Small business expense reporting and tax categorization for paper receipt compliance
Reference architecture for building resilient event-driven AI SaaS apps with background queues
System architecture
End-to-end execution pipeline running across Next.js 15, Gemini Vision, Prisma, Inngest, Arcjet, Resend.
Client-side image compression and secure upload to temporary server action pipeline
Multimodal OCR and structured JSON schema extraction (amount, merchant, date, category, tax)
Relational transaction storage, account balance updates, and foreign key integrity
Background cron workers for recurring debits, monthly budget rollover, and threshold monitoring
Token bucket rate limiting on receipt parsing endpoints + React Email budget alert dispatches
The path
Step-by-step implementation guide. Verbatim code snippets, configurations, and prompts.
Prompting Gemini 2.0 Vision for Structured Receipt Extraction
Write a structured system prompt forcing Gemini 2.0 Flash to inspect receipt photos and output strict JSON with merchant, total, date, category, and line items.
Verbatim Code / Config
const model = genAI.getGenerativeModel({ model: 'gemini-2.0-flash' });
const result = await model.generateContent([
{ inlineData: { data: base64Image, mimeType: 'image/jpeg' } },
'Extract receipt details into strict JSON: { merchantName: string, amount: number, date: ISOString, category: ExpenseCategory, confidence: number }'
]);Prisma Data Modeling & Account Balance Sync
Define PostgreSQL schemas for User, Account, Transaction, and Budget models, wrapping transaction creation in ACID database transactions.
Verbatim Code / Config
await prisma.$transaction(async (tx) => {
const txn = await tx.transaction.create({ data: { accountId, amount, merchantName, category, date } });
await tx.account.update({ where: { id: accountId }, data: { balance: { decrement: amount } } });
return txn;
});Configuring Inngest Event-Driven Background Workers
Set up Inngest serverless functions for processing recurring subscription entries on schedule and firing budget alerts when spending exceeds 85% of target.
Verbatim Code / Config
export const checkBudgetLimits = inngest.createFunction(
{ id: 'check-budget-limits' },
{ event: 'transaction.created' },
async ({ event, step }) => {
const budget = await step.run('fetch-budget', () => getBudget(event.data.userId));
if (budget.spentPercentage >= 0.85) {
await step.run('send-alert', () => resend.emails.send({ ... }));
}
}
);Endpoint Hardening with Arcjet Rate Limiting
Shield AI scanning API routes against abuse using Arcjet token bucket rate limits (10 scans/hour per IP) and bot detection rules.
Verbatim Code / Config
const aj = arcjet({
key: process.env.ARCJET_KEY!,
rules: [tokenBucket({ mode: 'LIVE', characteristics: ['userId'], refillRate: 10, interval: 3600, capacity: 10 })]
});Where it broke
The failure mode, root-cause breakdown, and resolution discovered during development.
The Tell
“Creased or thermal receipts with faint text frequently caused the model to hallucinate missing total amounts or confuse total with subtotal.”
Why it failed
When receipt paper had folds or faint thermal printing, raw single-prompt extraction misidentified tax or discount lines as the final payable amount.
The Fix
Implemented a multi-line mathematical reconciliation validator in the prompt and backend: the engine sums extracted individual line items against the parsed total, prompting the user for confirmation only if the arithmetic difference exceeds ₹5.
What it cost
₹0 to build and run permanently within verified free tiers.
| Service / Tool | Cost | Free Tier Limits |
|---|---|---|
| Next.js 15 & Vercel | ₹0 | Hobby deployment on Vercel with free edge runtime |
| Neon Serverless PostgreSQL | ₹0 | Free tier 0.5GB database storage |
| Google Gemini API | ₹0 | Free tier (15 RPM / 1M TPM) covers receipt image analysis |
| Inngest Cloud | ₹0 | Free tier (25,000 monthly background step executions) |
| Clerk & Arcjet & Resend | ₹0 | Free tiers (10k MAU, 3k emails/mo, 100k requests/mo) |
Make it yours
Three concrete variations you can build and ship using this exact foundation.
- 01
Freelance Invoice & Tax Deduction Tracker: Automatically extracts GST / VAT numbers and generates quarterly expense reports.
- 02
Corporate Travel & Per-Diem Mileage Reconciler: Matches hotel, meal, and flight receipts against company travel policy allowances.
- 03
Split-Bill Apartment Expense Ledger: Scans group restaurant bills, calculates itemized tip/tax shares, and sends WhatsApp payment links.
Where next
Ready to ship AI Finance Manager?
Review the architecture, clone the prompt and implementation steps, and deploy your live URL for ₹0.