Imported from jdramirezl/finance-app (
AGENTS.md). Install upstream withnpx skills add jdramirezl/finance-app. Copyright stays with the author.
Finance App - AI Assistant Guide
For AI Assistants: This document provides comprehensive context about the Finance App personal finance management system. Use this as your primary reference when working with this codebase.
Quick Context
What: Personal finance management web application with multi-user support and cloud sync
Tech Stack: React 19 + TypeScript + Vite (frontend), Supabase PostgreSQL + Auth (backend), Vercel hosting
Architecture: Monorepo with 3 workspaces (frontend, backend, shared), clean architecture pattern
Cost: $0/month (free tier hosting)
Repository: https://github.com/jdramirezl/finance-app
Table of Contents
- Application Overview
- Core Concepts
- Architecture
- Code Organization
- Key Features
- Development Workflow
- Deployment
- Common Tasks
- Troubleshooting
- Additional Resources
Application Overview
What It Does
Finance App enables users to:
- Track Accounts: Manage multiple bank accounts, cash, and investments across currencies
- Organize with Pockets: Create sub-containers within accounts for specific purposes
- Record Transactions: Log income and expenses with detailed categorization
- Plan Budgets: Distribute income with percentage-based allocation
- Manage Fixed Expenses: Track recurring bills with automatic monthly contributions
- Set Reminders: Never miss payments with recurring reminders
- Track Net Worth: Visualize wealth over time with historical snapshots
- Monitor Investments: Track stocks with real-time pricing
- Handle Multiple Currencies: Support USD, MXN, COP, EUR, GBP with auto-conversion
- Plan Future Transactions: Register pending movements that don't affect current balance
Why It Exists
Problem: Personal finance data is fragmented across banks, apps, and spreadsheets. Existing solutions are expensive or lack customization.
Solution: Free, comprehensive finance tracking with flexible organization, multi-currency support, and cloud sync.
Value: $0/month cost, 2-3 hours/month time savings, complete financial visibility, bank-grade security.
Core Concepts
Domain Model
User
├── Account (bank, cash, investment)
│ └── Pocket (savings, travel, etc.)
│ └── SubPocket (only in fixed expense pocket)
├── Movement (transaction)
├── MovementTemplate (saved transaction pattern)
├── Reminder (bill payment reminder)
├── NetWorthSnapshot (historical wealth data)
└── Settings (preferences)
Business Rules
- Balance Calculation: Movements affect pockets only. Account balance = sum of pocket balances.
- Account Uniqueness: Cannot have duplicate (name + currency) combinations.
- Fixed Expenses: Only ONE fixed expenses pocket exists globally. Sub-pockets only exist here.
- Pending Movements: Don't affect current balances until converted to actual movements.
Key Entities
Account: Financial account with name, color, currency, calculated balance
Pocket: Sub-container within account (types: 'normal' | 'fixed')
SubPocket: Only in fixed pocket, tracks recurring expenses with automatic monthly contributions
Movement: Transaction with type, amount, account/pocket references, dates, optional pending flag
MovementTemplate: Saved transaction pattern for quick entry
Architecture
System Design
Frontend (React + Vite)
↓ HTTPS/REST
Backend (Supabase PostgreSQL + Auth)
↓
Database (PostgreSQL with RLS)
Frontend Layer:
- React 19 + TypeScript for UI
- TanStack Query for server state (data fetching, caching)
- Zustand for client state (theme, UI preferences)
- Tailwind CSS for styling
- Vite for build and dev server
Backend Layer:
- Supabase provides PostgreSQL database
- Auto-generated REST API
- Email/password authentication with JWT
- Row Level Security (RLS) for data isolation
Key Patterns:
- Clean architecture in backend modules
- Component-based UI with service layer
- Repository pattern for data access
- Domain-driven design
Data Flow
Read Operation:
- Component mounts → TanStack Query hook executes
- Service method called → HTTP request to Supabase
- RLS validates user → Data returned
- TanStack Query caches → Component renders
Write Operation:
- User submits form → Validation
- TanStack Query mutation → Service method
- HTTP request → Backend validates
- Database insert/update → Balance recalculation
- Success response → Query invalidation → UI updates
Code Organization
Monorepo Structure
finance-app/
├── frontend/ # React web application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── pages/ # Route pages
│ │ ├── services/ # Business logic & API
│ │ ├── hooks/ # React & TanStack Query hooks
│ │ ├── store/ # Zustand stores
│ │ ├── types/ # TypeScript types
│ │ └── utils/ # Utility functions
│ ├── api/ # Serverless functions
│ └── tests/ # Test files
├── backend/ # API server
│ ├── src/
│ │ ├── modules/ # Domain modules
│ │ │ ├── accounts/
│ │ │ ├── movements/
│ │ │ ├── pockets/
│ │ │ ├── reminders/
│ │ │ └── net-worth/
│ │ └── shared/ # Shared utilities
│ └── migrations/ # Database migrations
└── shared/ # Shared types & contracts
├── api-contracts/
└── types/
Key Directories
Frontend Components:
components/accounts/: Account management UIcomponents/movements/: Transaction tracking UIcomponents/budget/: Budget planning UIcomponents/fixed-expenses/: Fixed expense management UIcomponents/reminders/: Reminder system UIcomponents/net-worth/: Net worth visualization UI
Frontend Services:
accountService.ts: Account CRUD operationsmovementService.ts: Transaction operationspocketService.ts: Pocket managementinvestmentService.ts: Investment trackingcurrencyService.ts: Currency conversionreminderService.ts: Reminder management
Backend Modules (each follows clean architecture):
application/: Use cases and application servicesdomain/: Business entities and rulesinfrastructure/: Database repositories
Key Features
1. Account & Pocket Management
- Create accounts with name, color, currency
- Add pockets within accounts for organization
- Drag & drop reordering
- Calculated balances (never manually set)
2. Movement Tracking
- Record income and expenses
- Link to accounts and pockets
- Save as templates for quick entry
- Filter by date, type, account
- Pending movements for future transactions
3. Fixed Expenses
- Special pocket type for recurring bills
- Sub-pockets with target amounts and periodicity
- Automatic monthly contribution calculation
- Progress tracking with visual indicators
- Enable/disable individual expenses
4. Budget Planning
- Input total income
- Subtract fixed expenses automatically
- Distribute remaining with percentages
- Real-time calculation of amounts
5. Reminders
- Set bill payment reminders
- Recurrence: daily, weekly, monthly, yearly
- Enable/disable individual reminders
- Due date tracking
6. Net Worth Timeline
- Historical snapshots of total wealth
- Currency breakdown
- Visual charts with Recharts
- Automatic or manual snapshot creation
7. Investment Tracking
- Track stock holdings (e.g., VOO)
- Real-time price updates
- Gain/loss calculation
- Integrated into net worth
8. Multi-Currency Support
- USD, MXN, COP, EUR, GBP
- Real-time exchange rates
- Consolidated totals in primary currency
- Per-currency breakdowns
Development Workflow
Setup
# Clone and install
git clone https://github.com/jdramirezl/finance-app
cd finance-app
npm install
# Configure environment
# Create frontend/.env with Supabase credentials:
# VITE_SUPABASE_URL=https://[project-id].supabase.co
# VITE_SUPABASE_ANON_KEY=[anon-key]
# Start development
npm run dev:all # Both frontend and backend
# OR
npm run dev # Frontend only (http://localhost:5173)
Common Commands
# Development
npm run dev # Start frontend
npm run dev:backend # Start backend
npm run dev:all # Start both
# Testing
npm run test # Frontend tests
npm run test:backend # Backend tests
# Building
npm run build # Build frontend
npm run build:backend # Build backend
# Linting
npm run lint # Lint code
Making Changes
Adding a Feature:
- Define types in
shared/types/ - Create service methods in
frontend/src/services/ - Create components in
frontend/src/components/ - Add page route in
frontend/src/pages/ - Write tests
- Update documentation
Database Changes:
- Create migration:
supabase migration new [name] - Write SQL in
backend/migrations/###_name.sql - Test locally
- Run in production:
supabase db push - Update TypeScript types
Deployment
Automatic Deployment
Frontend (Vercel):
- Push to
mainbranch on GitHub - Vercel automatically builds and deploys
- Preview deployments for pull requests
Database (Supabase):
- Migrations run manually via CLI
- Schema changes applied to production
Manual Deployment
# Frontend
vercel --prod
# Database migrations
supabase link --project-ref [project-id]
supabase db push
Environment Variables
Vercel (Frontend):
VITE_SUPABASE_URL: Supabase project URLVITE_SUPABASE_ANON_KEY: Supabase anonymous key- Optional: API keys for exchange rates and stock prices
Supabase (Backend):
- Configured in Supabase dashboard
- Connection strings auto-generated
Common Tasks
Task: Add a New Page
- Create page component in
frontend/src/pages/NewPage.tsx - Add route in router configuration
- Create necessary components in
frontend/src/components/ - Add service methods if needed
- Update navigation
Task: Add a Database Table
- Create migration:
supabase migration new add_table_name - Write SQL with RLS policies
- Run migration:
supabase db push - Add TypeScript types in
shared/types/ - Create service methods
- Update components
Task: Fix a Bug
- Reproduce the issue locally
- Check browser console and network tab
- Review relevant service and component code
- Fix and test locally
- Write test to prevent regression
- Deploy fix
Task: Update Dependencies
npm outdated # Check for updates
npm update # Update all
npm run test # Test after updates
npm run build # Verify build works
Troubleshooting
Build Fails
Check:
- All dependencies in package.json
- TypeScript errors:
npm run build - Environment variables set correctly
Authentication Issues
Check:
- Supabase URL and anon key in environment
- RLS policies allow the operation
- JWT token in request headers
- User is authenticated
Database Errors
Check:
- Database not paused (free tier auto-pauses)
- RLS policies configured correctly
- Connection string valid
- User has permissions
Slow Performance
Check:
- Bundle size (use code splitting)
- Database query performance
- Image optimization
- API response caching
- Network tab in DevTools
Additional Resources
Detailed Documentation
For comprehensive information, see .agents/application-summary/:
identity.md: Ownership and project statusproduct.md: Business context and use casespackages.md: Code organization detailsarchitecture.md: System design deep diveinfrastructure.md: Deployment and hostingoperations.md: Maintenance and proceduresdocumentation.md: All documentation linksindex.md: Navigation guide
Project Documentation
README.md: Project overview and quick startdocs/PROJECT_SPEC.md: Complete technical specificationsdocs/FEATURE_ROADMAP.md: Planned featuresdocs/qol.md: Quality of life improvements
External Documentation
- React: https://react.dev
- TypeScript: https://www.typescriptlang.org/docs
- Vite: https://vitejs.dev
- TanStack Query: https://tanstack.com/query/latest
- Tailwind CSS: https://tailwindcss.com/docs
- Supabase: https://supabase.com/docs
- Vercel: https://vercel.com/docs
Getting Help
- GitHub Issues: https://github.com/jdramirezl/finance-app/issues
- Supabase Discord: https://discord.supabase.com
- Vercel Support: support@vercel.com
Working with This Codebase
Best Practices
- Type Safety: Use TypeScript strictly, define types in
shared/types/ - Component Structure: Keep components focused, extract reusable logic to hooks
- Service Layer: Business logic in services, not components
- Testing: Write tests for new features
- Documentation: Update docs when making significant changes
Code Patterns
Data Fetching:
// Use TanStack Query hooks
const { data, isLoading, error } = useQuery({
queryKey: ['accounts'],
queryFn: accountService.getAccounts
});
Mutations:
const mutation = useMutation({
mutationFn: accountService.createAccount,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['accounts'] });
}
});
State Management:
// Use Zustand for UI state
const theme = useThemeStore((state) => state.theme);
const setTheme = useThemeStore((state) => state.setTheme);
Security Considerations
- Never commit secrets to git
- Use environment variables for sensitive data
- RLS policies enforce data isolation
- All connections use HTTPS
- JWT tokens for authentication
Performance Tips
- Use React.memo for expensive components
- Implement code splitting for routes
- Optimize images and assets
- Cache API responses with TanStack Query
- Monitor Core Web Vitals
Summary
Finance App is a well-architected personal finance management system built with modern technologies. The codebase follows clean architecture principles, uses TypeScript throughout for type safety, and leverages free-tier cloud services for zero-cost hosting.
Key Strengths:
- Comprehensive feature set
- Clean, maintainable code structure
- Strong type safety
- Secure multi-user support
- Zero operational cost
When Working on This Project:
- Start with this AGENTS.md for context
- Review relevant detailed docs in
.agents/application-summary/ - Follow established patterns and conventions
- Write tests for new features
- Update documentation as needed
For detailed information on any topic, refer to the comprehensive documentation in .agents/application-summary/.
