A comprehensive AI-powered financial advisor application that helps users create detailed financial profiles, analyze their financial health, and receive personalized financial recommendations.
πΊ Watch the AI Finance Agent in Action
- Interactive Chat Interface: Step-by-step guided conversation to collect comprehensive financial information
- Structured Data Collection: Captures personal info, income sources, expenses, debts, savings, and financial goals
- Real-time Progress Tracking: Visual progress indicators and session management
- Persistent Sessions: Resume conversations with unique session IDs
- AI-Powered Analysis: Advanced financial metrics calculation using Mastra AI agents
- Comprehensive Reports:
- Debt-to-Income (DTI) ratio analysis
- Savings rate calculations
- Emergency fund adequacy assessment
- Net worth tracking
- Financial health scoring (A/B/C grades)
- Personalized recommendations
- Visual Data Presentation: Clean, responsive charts and metrics display
- CSV File Upload: Import expense and income records via drag-and-drop interface
- Smart Column Mapping: Automatic detection and manual mapping of CSV columns
- Data Validation: Real-time validation and error handling
- Batch Processing: Efficient handling of large financial datasets
- Supabase Authentication: Secure email/password and Google OAuth integration
- Row Level Security (RLS): Database-level security policies
- User Data Isolation: Complete data privacy and user separation
- Session Management: Secure chat session handling
- OpenAI GPT-4 Integration: Advanced conversational AI capabilities
- Structured Responses: AI responses with embedded JSON data for seamless processing
- Message Persistence: All conversations saved to database
- Real-time Interaction: Smooth chat experience with typing indicators
- Responsive Design: Works seamlessly across desktop, tablet, and mobile devices
- Dark/Light Theme: Modern interface with Tailwind CSS styling
- Component Library: Reusable UI components built with Radix UI
- Accessibility: WCAG compliant design patterns
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Lucide React - Beautiful icon library
- OpenAI GPT-4 - Advanced language model for financial analysis
- Mastra AI - AI agent framework for specialized financial tools
- AI SDK - Streamlined AI integration with React
- Supabase - PostgreSQL database with real-time features
- Supabase Auth - Authentication and authorization
- Row Level Security - Database-level security policies
- ESLint - Code linting and quality
- Turbopack - Fast development bundler
- PostCSS - CSS processing
- Node.js 18+
- npm, yarn, pnpm, or bun
- Supabase account
- OpenAI API key
git clone <repository-url>
cd ai-finance-agentnpm install
# or
yarn install
# or
pnpm installCreate a .env.local file in the root directory:
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key
# Google OAuth (Optional)
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_google_client_idRun the Supabase migrations to set up your database schema:
# Apply migrations (run in Supabase dashboard or via CLI)
# The migrations are located in supabase/migrations/npm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 to see the application.
ai-finance-agent/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β β βββ financial-health/ # Financial analysis endpoints
β β βββ financial-profile/ # Profile collection endpoints
β βββ auth/ # Authentication pages
β βββ chat/ # Chat session pages
β βββ page.tsx # Landing page
βββ components/ # React components
β βββ auth/ # Authentication components
β βββ ui/ # Reusable UI components
β βββ financial-analysis.tsx # Financial report display
β βββ financial-profile-collection.tsx # Main chat interface
β βββ financial-records-upload.tsx # File upload component
βββ lib/ # Utility libraries
β βββ supabase/ # Supabase client and services
β βββ utils.ts # Helper functions
βββ mastra/ # AI agents and workflows
β βββ agents/ # Mastra AI agents
β βββ tools/ # AI tools and functions
β βββ workflows/ # AI workflows
βββ supabase/ # Database migrations
β βββ migrations/ # SQL migration files
βββ hooks/ # Custom React hooks
npm run dev- Start development server with Turbopacknpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run dev:mastra- Start Mastra AI development servernpm run build:mastra- Build Mastra AI agents
The application uses the following main tables:
- user_profiles - User financial profile data
- chat_sessions - Chat session management
- chat_messages - Conversation history storage
- financial_records - Uploaded financial data
All tables include Row Level Security (RLS) policies for data protection.
- Guides users through financial data collection
- Validates and structures user responses
- Maintains conversation context and progress
- Calculates key financial metrics
- Generates personalized recommendations
- Provides actionable financial insights
- Row Level Security (RLS) - Database-level access control
- Supabase Auth - Secure authentication system
- Service Role Keys - Secure API operations
- Input Validation - Client and server-side validation
- CSRF Protection - Built-in Next.js security
The application is fully responsive and optimized for:
- Desktop (1024px+)
- Tablet (768px - 1023px)
- Mobile (320px - 767px)
- Connect your GitHub repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically on push to main branch
The application can be deployed to any platform that supports Next.js:
- Netlify
- Railway
- DigitalOcean App Platform
- AWS Amplify
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the Issues page for existing solutions
- Create a new issue with detailed information
- Include error messages and steps to reproduce
- Next.js - React framework
- Supabase - Backend as a service
- OpenAI - AI language models
- Mastra AI - AI agent framework
- Tailwind CSS - CSS framework
- Radix UI - UI primitives
Built with β€οΈ using modern web technologies