How anacke8996/splitty works
Project type and purpose
• Splitty is a full-stack web application for splitting bills by scanning receipts and assigning items to users.
• The frontend is built with Next.js (React + TypeScript), serving both UI pages and API routes.
• There is no separate traditional backend folder; the project uses Next.js serverless functions (located under src/pages/api) to implement “backend” logic.
• It integrates with two external services: Mistral AI for OCR and ExchangeRate API for currency conversion.
File structure
Top-level:
• .gitignore, package.json, package-lock.json
• .venv (Python virtual env—likely unused or vestigial)
• README.md
splitty-frontend/ (Next.js app)
• .next/ (build output)
• public/ (static assets)
• src/
– pages/
• index.js (landing page)
• api/ (Next.js API routes)
– process-receipt.ts
– split-bill.ts
– test.ts
• _document.tsx, _app.tsx (Next.js wrappers)
– components/ (UI pieces: CurrencySelector, ReceiptProcessor)
– services/api.ts (HTTP helpers)
– config/api.ts (endpoint URLs)
– theme.ts, tailwind.config.js (styling)
• next.config.js, tsconfig.json
Key insights from README
• Describes features: image upload ➔ OCR ➔ currency detection/conversion ➔ assign items ➔ calculate splits
• Mentions Python/Flask backend and server.py, but file tree shows Next.js APIs instead
• Requires MISTRAL_API_KEY and EXCHANGE_API_KEY as env vars
Main system components
A. Client (Browser/Mobile via Web)
• Next.js UI (React pages + components)
• Tailwind CSS theme
B. API Layer (Next.js serverless functions)
• /api/process-receipt: accepts image, calls OCR service
• /api/split-bill: accepts item assignments, computes splits
C. External Services
• Mistral AI OCR API (image → text + line items)
• ExchangeRate API (currency code → USD rate)
D. (Optional) Data store or in-memory state
• No persistent DB—state lives in request/response; optional enhancement
Relationships and interactions
1. User uploads receipt from UI →
2. Browser performs POST to /api/process-receipt →
3. Next.js function forwards image to Mistral API →
4. Mistral returns parsed items + currencies →
5. Function calls ExchangeRate API (if needed) →
6. Normalized data sent back to UI →
7. User assigns items within React UI →
8. Browser POSTs assignments to /api/split-bill →
9. Serverless function computes per-person totals →
10. Results returned and rendered
Architectural patterns and principles
• Full-stack Next.js (UI + API co-located)
• Serverless backend functions (scalable, no server management)
• Single-page application routing with dynamic API endpoints
• Separation of concerns: UI components vs. service calls vs. config vs. styling