Skip to content

afifn11/finsight

Repository files navigation

FinSight β€” Personal Finance Dashboard

Next.js TypeScript PostgreSQL Prisma Tailwind CSS Deployed on Vercel CI

Full-stack personal finance dashboard with AI-powered insights, receipt scanning, and PWA support.

Live Demo β†’


Screenshots

Dashboard Dashboard


Transactions & Add Modal Transactions


OCR Receipt Scanning OCR Scan


Financial Goals Financial Goals


PDF Export with Receipts Mobile View (PWA)
PDF Export Mobile View

Overview

FinSight is a production-ready personal finance application that helps users track transactions, manage budgets, set financial goals, and understand their spending patterns through AI-powered analysis. Built as a portfolio project demonstrating modern full-stack development with real-world features across the entire stack.

Highlights:

  • πŸ€– AI spending analysis powered by Google Gemini 2.5 Flash
  • πŸ“Έ OCR receipt scanning β€” photograph a receipt to auto-fill transaction forms
  • 🎯 Financial goals tracking with progress visualization
  • πŸ“± Progressive Web App β€” installable on mobile and desktop
  • πŸ”” Smart budget alerts with automatic threshold notifications
  • πŸ“„ PDF & CSV export with receipt image attachments

Features

πŸ“Š Dashboard

Real-time financial overview with summary cards (income, expense, net balance, saving rate), 6-month income vs expense trend chart, category spending breakdown pie chart, budget progress strips, recent transactions, and AI-generated spending insights.

πŸ’³ Transactions

Full CRUD with OCR receipt scanning via Gemini Vision, file attachment support (images/PDF stored in Supabase Storage), full-text search with 300ms debounce, category/date/type filters, recurring transactions (daily/weekly/monthly/yearly), and paginated list.

πŸ’° Budget Management

Per-category monthly spending limits with real-time progress bars, configurable alert thresholds, and automatic toast notifications when a budget is exceeded β€” deduplicated to one alert per budget per month.

🎯 Financial Goals

Set savings targets with deadlines, track progress manually, and mark goals as complete. Supports custom icons, colors, and motivational notes per goal.

πŸ€– AI Insights

Queries real transaction data to generate 3 personalized insights per month β€” spending patterns, budget warnings, and saving tips. Results cached in PostgreSQL to minimize API costs.

πŸ“Έ OCR Receipt Scanning

Upload or photograph a receipt. Gemini Vision extracts amount, date, merchant, and category to pre-fill the transaction form automatically.

πŸ“„ Export

CSV for spreadsheet analysis (includes receipt filename column). PDF with full transaction table, summary section, and a receipt image appendix β€” each transaction's receipt embedded at actual size.

πŸ” Authentication

Email/password and Google OAuth via NextAuth.js. JWT sessions with 30-day persistence. Route protection via Next.js middleware with public path exclusions.

πŸ“± PWA

Installable on Android, iOS (Safari), and desktop Chrome. Service worker for offline fallback. Add to Home Screen works across all supported platforms.


Tech Stack

Category Technology
Framework Next.js 16 (App Router, Turbopack)
Language TypeScript 5.9 β€” strict mode
Styling Tailwind CSS v4
Database PostgreSQL via Supabase
ORM Prisma 7 with @prisma/adapter-pg
Auth NextAuth.js v4
AI Google Gemini 2.5 Flash (@google/genai)
File Storage Supabase Storage (receipts)
Validation Zod v4
Forms React Hook Form v7
Charts Recharts v3
PDF jsPDF + jsPDF-AutoTable
Testing Vitest (165 tests)
CI/CD GitHub Actions β†’ Vercel

Project Structure

finsight/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/                 # Login, Register, Onboarding
β”‚   β”œβ”€β”€ (dashboard)/            # Protected dashboard routes
β”‚   β”‚   β”œβ”€β”€ page.tsx            # Dashboard overview
β”‚   β”‚   β”œβ”€β”€ transactions/       # Transaction management
β”‚   β”‚   β”œβ”€β”€ budgets/            # Budget management
β”‚   β”‚   β”œβ”€β”€ goals/              # Financial goals
β”‚   β”‚   β”œβ”€β”€ analytics/          # Detailed analytics
β”‚   β”‚   └── settings/           # User settings
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/               # NextAuth + registration
β”‚   β”‚   β”œβ”€β”€ transactions/       # CRUD + receipt upload API
β”‚   β”‚   β”œβ”€β”€ budgets/            # CRUD + alert checking
β”‚   β”‚   β”œβ”€β”€ goals/              # Financial goals CRUD
β”‚   β”‚   β”œβ”€β”€ categories/         # System + custom categories
β”‚   β”‚   β”œβ”€β”€ dashboard/summary/  # Aggregated dashboard data
β”‚   β”‚   β”œβ”€β”€ ai/insight/         # Gemini AI integration
β”‚   β”‚   β”œβ”€β”€ ocr/                # Receipt OCR via Gemini Vision
β”‚   β”‚   β”œβ”€β”€ export/             # CSV + PDF export
β”‚   β”‚   └── user/               # Settings, onboarding, delete account
β”‚   └── manifest.ts             # PWA manifest (Next.js native)
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ dashboard/              # Summary cards, charts, AI insight card
β”‚   β”œβ”€β”€ transactions/           # List, form modal, OCR scanner, receipt uploader
β”‚   β”œβ”€β”€ budgets/                # Budget manager, alert bell
β”‚   β”œβ”€β”€ goals/                  # Goals manager + goal cards
β”‚   β”œβ”€β”€ settings/               # Settings form with delete account
β”‚   β”œβ”€β”€ shared/                 # Sidebar, Header, BottomNav, Providers
β”‚   └── ui/                     # Skeleton loaders
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ prisma.ts               # Prisma client singleton (pg adapter)
β”‚   β”œβ”€β”€ supabase.ts             # Supabase Storage client
β”‚   β”œβ”€β”€ auth.ts                 # NextAuth configuration
β”‚   β”œβ”€β”€ utils.ts                # Formatting, color helpers
β”‚   └── validations.ts          # Zod schemas (shared client/server)
β”œβ”€β”€ hooks/                      # useTransactions, useDebounce, etc.
β”œβ”€β”€ types/                      # TypeScript interfaces
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma           # Database schema
β”‚   └── seed.ts                 # Demo data seeder
β”œβ”€β”€ public/
β”‚   └── sw.js                   # Service worker (PWA)
└── middleware.ts               # Auth + onboarding route protection

Key Engineering Decisions

Prisma 7 driver adapter β€” Uses @prisma/adapter-pg with connection pooling for Supabase pgBouncer compatibility, preventing "too many clients" errors on free tier. Schema defined separately in prisma.config.ts.

Parallel data fetching β€” Dashboard endpoint uses Promise.all() to run 3 aggregation queries concurrently instead of sequentially, cutting response time by ~60%.

AI cost optimization β€” Gemini insights are cached in PostgreSQL with @@unique([userId, month, year]). The model is only called once per user per month regardless of how many times the dashboard is visited.

Supabase Storage with signed URLs β€” Receipts stored privately under {userId}/{transactionId}/ path structure. Signed URLs (1-hour expiry) generated server-side on every access β€” files are never directly public.

Budget alert deduplication β€” BudgetAlert has @@unique([budgetId, month, year]) constraint. Alerts triggered client-side after every expense transaction, but only one notification fires per budget per calendar month.

OCR without a separate Vision API β€” Receipt scanning reuses the existing GOOGLE_AI_API_KEY with Gemini's multimodal capability (text + image in the same request), avoiding a separate Google Cloud Vision billing account.

TypeScript exactOptionalPropertyTypes β€” Enforces strict distinction between undefined and null throughout the codebase, preventing subtle bugs in optional form fields and Prisma update payloads.


Local Development

Prerequisites

Setup

git clone https://github.com/afifn11/finsight.git
cd finsight

npm install

cp .env.example .env.local
# Fill in all values β€” see below

npx prisma db push
npm run db:seed   # optional demo data

npm run dev

Environment Variables

# App
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=           # openssl rand -base64 32
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Database β€” Supabase PostgreSQL
DATABASE_URL=              # Pooler URL  (port 6543, ?pgbouncer=true)
DIRECT_URL=                # Direct URL  (port 5432)

# Google OAuth β€” console.cloud.google.com
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

# Google Gemini AI β€” aistudio.google.com
GOOGLE_AI_API_KEY=

# Supabase Storage β€” project Settings β†’ API
NEXT_PUBLIC_SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=

Testing & Quality

npm run test:run     # 165 unit tests (Vitest)
npm run type-check   # TypeScript strict check
npm run lint         # ESLint
npm run build        # Full production build

GitHub Actions runs all four checks on every push to main. The CI badge at the top reflects the current status.


Deployment

Deployed on Vercel with automatic deployments triggered by pushes to main. Build command: prisma generate && next build.

Database schema changes are applied manually via npx prisma db push against the production Supabase instance before merging.


Scripts

npm run dev           # Dev server (Turbopack)
npm run build         # Production build
npm run type-check    # tsc --noEmit
npm run lint          # ESLint
npm run db:push       # Push schema to database
npm run db:studio     # Prisma Studio GUI
npm run db:seed       # Seed demo data
npm run test:run      # Run all tests

License

MIT β€” free to use for educational and portfolio purposes.


About

FinSight is a production-deployed personal finance dashboard that helps users track transactions, manage budgets, visualize spending patterns, and get AI-powered insights about their financial behavior.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors