A modern, full-stack personal finance management application built with Next.js 15, TypeScript, and Supabase. Track your income, expenses, and financial goals with beautiful analytics and insights tailored for Sri Lankan users.
- User Registration & Login - Secure authentication with form validation using Zod schemas
- Protected Routes - Automatic redirection for unauthorized access with ProtectedRoute component
- Session Management - Persistent login state with localStorage and React Context
- Professional UI - Clean, modern authentication forms with error handling
- Demo Mode - Quick demo access for testing (email: any@email.com, password: 6+ chars)
- Transaction Tracking - Add, edit, delete income and expense transactions with full CRUD operations
- Category Management - 40+ pre-defined Sri Lankan categories with emojis and color coding
- Real-time Dashboard - Live financial overview with key metrics and recent transactions
- Advanced Filtering - Filter transactions by type, category, date range, and description
- Sri Lankan Context - LKR currency, local categories (Rice & Curry, CEB Bills, Dialog/Mobitel, etc.)
- Data Validation - Form validation with Zod for data integrity and user experience
- Interactive Charts - Beautiful pie charts and bar graphs using Recharts
- Expense Breakdown - Visual representation of spending by category
- Income Analysis - Track income sources and patterns
- Monthly Trends - Historical data visualization for the last 6 months
- Financial Summaries - Total income, expenses, and net balance
- Responsive Design - Optimized for desktop, tablet, and mobile devices
- Modern UI Components - Custom-built components with TailwindCSS
- Loading States - Smooth loading indicators and error handling
- Sri Lankan Context - LKR currency and localized categories
- Next.js 15.3.3 - React framework with App Router and Turbopack
- React 19.0.0 - Latest React with concurrent features
- TypeScript 5.8.3 - Type-safe JavaScript with strict mode
- TailwindCSS 4.1.10 - Utility-first CSS framework with custom theme
- Recharts 2.15.3 - Composable charting library for data visualization
- Lucide React 0.514.0 - Beautiful SVG icon library
- Date-fns 4.1.0 - Modern JavaScript date utility library
- Zod 3.25.63 - TypeScript-first schema validation
- Supabase - PostgreSQL database with real-time features and REST API
- Supabase Auth - Authentication and user management with JWT
- Supabase Auth Helpers - Next.js integration for seamless auth
- Row Level Security (RLS) - Database-level security policies for data isolation
- PostgreSQL - Robust relational database with ACID compliance
- ESLint 9 - Code linting with Next.js and TypeScript rules
- PostCSS 8.5.5 - CSS processing with Tailwind integration
- Autoprefixer 10.4.21 - CSS vendor prefixing for browser compatibility
- Node.js 18+ and npm/yarn/pnpm
- Supabase account and project
git clone https://github.com/yourusername/personal-finance-tracker.git
cd personal-finance-trackernpm install
# or
yarn install
# or
pnpm installCreate a .env.local file in the root directory:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_keyRun the SQL scripts in your Supabase Dashboard β SQL Editor in this order:
-
Initial Setup: Execute
database-setup.sql- Creates
categoriesandtransactionstables - Sets up Row Level Security (RLS) policies
- Creates indexes for optimal performance
- Inserts 40+ Sri Lankan categories
- Creates
-
RLS Policy Fixes (if needed): Execute
fix-rls-policies.sql- Fixes any RLS policy issues for development
- Allows demo data access
- Configures proper user permissions
npm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 to view the application.
personal-finance-tracker/
βββ src/
β βββ app/ # Next.js 15 App Router pages
β β βββ analytics/ # Analytics dashboard with charts
β β β βββ page.tsx # Analytics page component
β β βββ dashboard/ # Main financial dashboard
β β β βββ page.tsx # Dashboard overview
β β βββ login/ # Authentication pages
β β β βββ page.tsx # Login form
β β βββ register/ # User registration
β β β βββ page.tsx # Registration form
β β βββ transactions/ # Transaction management
β β β βββ add/ # Add new transaction
β β β β βββ page.tsx # Transaction form
β β β βββ [id]/ # Dynamic transaction routes
β β β β βββ edit/ # Edit transaction
β β β β βββ page.tsx
β β β βββ page.tsx # Transaction list
β β βββ globals.css # Global styles with Tailwind
β β βββ layout.tsx # Root layout with providers
β β βββ page.tsx # Landing page
β βββ components/ # Reusable UI components
β β βββ ui/ # Base UI components
β β β βββ Button.tsx # Custom button variants
β β β βββ Card.tsx # Container component
β β β βββ Input.tsx # Form input with validation
β β βββ Header.tsx # Navigation header
β β βββ ProtectedRoute.tsx # Route protection HOC
β βββ contexts/ # React Context providers
β β βββ AuthContext.tsx # Authentication state management
β βββ lib/ # Utility libraries
β β βββ supabase.ts # Supabase client & database types
β β βββ utils.ts # Helper functions
β β βββ validations.ts # Zod validation schemas
β β βββ sri-lankan-data.ts # Local data and constants
β βββ types/ # TypeScript type definitions
β βββ transaction.ts # Transaction-related interfaces
βββ public/ # Static assets
β βββ favicon.ico # App favicon
β βββ *.svg # Icon assets
βββ database-setup.sql # Initial database schema
βββ fix-rls-policies.sql # RLS policy configurations
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ next.config.ts # Next.js configuration
βββ postcss.config.mjs # PostCSS configuration
βββ eslint.config.mjs # ESLint configuration
βββ README.md # Project documentation
CREATE TABLE categories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name VARCHAR(100) NOT NULL,
icon VARCHAR(10) NOT NULL,
color VARCHAR(7) NOT NULL,
type VARCHAR(10) CHECK (type IN ('income', 'expense')),
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);CREATE TABLE transactions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
amount DECIMAL(12,2) NOT NULL CHECK (amount > 0),
type VARCHAR(10) NOT NULL CHECK (type IN ('income', 'expense')),
category_id UUID REFERENCES categories(id),
description TEXT NOT NULL,
date DATE NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);Manages user authentication state across the application:
- Login/logout functionality
- User session persistence
- Protected route access control
Abstracted database operations with TypeScript:
- CRUD operations for transactions
- Category management
- Analytics data aggregation
- Type-safe database queries
Reusable, accessible components:
- Button: Multiple variants and sizes
- Card: Consistent container styling
- Input: Form inputs with validation
- Header: Navigation with user context
- Total income and expenses
- Current balance calculation
- Transaction count
- Recent transactions list
- Pie Charts: Expense and income breakdown by category
- Bar Charts: Monthly trends over time
- Category Lists: Detailed breakdown with percentages
- Time Filtering: View data for different time periods
- Form Validation - Client-side validation with Zod schemas and server-side verification
- Password Security - Minimum 6 characters requirement with secure hashing
- Session Management - JWT-based authentication with automatic token refresh
- Protected Routes - Route-level protection with automatic redirects
- User Context - Secure user state management with React Context API
- Row Level Security (RLS) - PostgreSQL RLS policies ensuring users only access their own data
- User Isolation - UUID-based user identification with foreign key constraints
- SQL Injection Prevention - Parameterized queries and Supabase client protection
- Secure API Endpoints - Server-side validation and authentication checks
- Data Encryption - Encrypted data transmission with HTTPS and secure storage
- Data Minimization - Only collect necessary financial data
- User Control - Users can delete their own transactions and data
- Secure Storage - Encrypted database storage with Supabase infrastructure
- No Third-party Tracking - Privacy-focused design without external analytics
- Primary: Blue (#3B82F6)
- Success: Green (#10B981)
- Danger: Red (#EF4444)
- Warning: Yellow (#F59E0B)
- Neutral: Gray scale
- Font: Geist Sans (Vercel's font family)
- Headings: Bold, hierarchical sizing
- Body: Regular weight, readable line height
- Consistent spacing using Tailwind's scale
- Rounded corners and subtle shadows
- Hover and focus states for interactivity
- Mobile-first responsive design
- Connect Repository: Link your GitHub repository to Vercel
- Environment Variables: Add the following in Vercel dashboard:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key - Auto Deploy: Automatic deployment on push to main branch
- Custom Domain: Configure custom domain in Vercel settings
# Build the application
npm run build
# Start production server
npm run start
# Or using PM2 for production
npm install -g pm2
pm2 start npm --name "finance-tracker" -- startFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage- Unit Tests - Component and utility function testing
- Integration Tests - API endpoint and database operation testing
- E2E Tests - Full user workflow testing with Playwright
- Next.js 15 - Latest performance optimizations and Turbopack
- Image Optimization - Automatic image optimization with Next.js Image component
- Code Splitting - Automatic code splitting for optimal loading
- Static Generation - Pre-rendered pages for better performance
- Database Indexing - Optimized database queries with proper indexing
- Core Web Vitals - Optimized for Google's Core Web Vitals
- Bundle Analysis - Regular bundle size monitoring
- Database Performance - Query optimization and connection pooling
We welcome contributions! Please follow these steps:
- Fork the repository and clone your fork
- Install dependencies:
npm install - Set up environment: Copy
.env.exampleto.env.local - Database setup: Run the SQL scripts in Supabase
- Start development:
npm run dev
- Create a feature branch:
git checkout -b feature/amazing-feature - Follow code style: Use ESLint and Prettier configurations
- Write tests: Add tests for new features
- Update documentation: Update README if needed
- Commit changes: Use conventional commit messages
- Push to branch:
git push origin feature/amazing-feature - Open Pull Request: Provide clear description of changes
- Use TypeScript for all new code
- Follow ESLint and Prettier configurations
- Use meaningful variable and function names
- Add JSDoc comments for complex functions
- Maintain consistent file structure
# Check environment variables
echo $NEXT_PUBLIC_SUPABASE_URL
echo $NEXT_PUBLIC_SUPABASE_ANON_KEY
# Verify Supabase connection
npm run test:db# Clear Next.js cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Check TypeScript errors
npm run type-check- Verify Supabase Auth is enabled
- Check RLS policies are correctly configured
- Ensure environment variables are set correctly
- v0.1.0 - Initial release with basic transaction tracking
- v0.2.0 - Added analytics and charts
- v0.3.0 - Enhanced security and authentication
- v1.0.0 - Production-ready release (planned)
- Next.js - For the amazing React framework with App Router
- Supabase - For the powerful backend infrastructure and PostgreSQL
- TailwindCSS - For the utility-first CSS framework
- Recharts - For the beautiful and responsive charting library
- Lucide - For the comprehensive icon library
- Vercel - For the seamless deployment platform
- TypeScript - For type safety and developer experience
- Sri Lankan Developer Community - For inspiration and local context
β Star this repository if you found it helpful!










