How atharvm2504/fairsplit works
Project type and purpose
• This is a full-stack web application built with Next.js (React) that replicates Splitwise functionality: group expense tracking, balances, reimbursements, receipt scanning, and optional AI-powered expense categorization.
• It targets both end users (browser/PWA) and operators (self-hosting via Docker or Vercel).
File structure
• Top-level:
• src/app – Next.js 13 “App Router” pages, layouts, API routes
• src/components & src/components/ui – shared React components / design system
• src/trpc – tRPC client & server routers for typed RPC endpoints
• prisma – database schema and migrations (PostgreSQL via Prisma ORM)
• public – static assets (logo)
• scripts & Dockerfiles – local-dev, container build, DB startup
• .github/workflows – CI/CD pipelines
• Key configuration:
• next.config.mjs, tailwind.config.js, postcss.config.js – build & styling
• .env.example, container.env.example – runtime feature flags (S3, OpenAI)
• Dockerfile & compose.yaml – container orchestration
README for additional insights
• Stack: Next.js + Tailwind + shadcn/UI, Prisma + PostgreSQL, Vercel hosting.
• Features: health checks (/api/health), optional S3 upload (/api/s3-upload), OpenAI GPT-4 integration.
• Deployment modes: local dev, Docker container, Vercel serverless.
• CI/CD: GitHub Actions (ci.yml, cd.yml) build, test, deploy.
a. Main components
• Client: Browser / PWA
• Next.js application (Pages + API routes + tRPC server)
• React component library (shadcn/UI)
• Database: PostgreSQL (hosted via Vercel or local Docker)
• Storage: AWS S3 (or S3-compatible endpoint) for expense documents
• External AI: OpenAI GPT-4 Vision for receipt extraction / category inference
• CI/CD & Hosting: GitHub Actions, Docker, Vercel
b. Relationships & interactions
• Browser → Next.js pages (SSR/CSR) & tRPC client
• Next.js → tRPC routers → Prisma Client → PostgreSQL
• Next.js API route /api/s3-upload → S3 SDK → S3 bucket
• Next.js server → OpenAI API when feature flag enabled
• GitHub → CI pipeline → Docker image → Vercel deployment
c. Architectural patterns
• Monorepo single-codebase full-stack (Next.js App Router)
• RPC pattern (tRPC) for type-safe client-server comms
• ORM layer (Prisma) for DB abstraction & migrations
• Feature flags via environment variables
• Progressive Web App support (manifest, splash, offline)
d. Key technologies / frameworks
• Next.js 13 (App Router, server components)
• React + shadcn/UI + TailwindCSS
• tRPC for backend APIs
• Prisma + PostgreSQL
• AWS S3 or compatible for file storage
• OpenAI GPT-4 Vision
• Docker & GitHub Actions for CI/CD
• Vercel for hosting