A production-ready financial analysis platform with AI-powered insights, real-time market data, portfolio management, and advanced search capabilities.
FinanceAI is a comprehensive financial analysis platform that combines real-time market data with AI-powered insights to help users make informed investment decisions. Built with modern web technologies and optimized for performance, accessibility, and user experience.
- LangGraph Architecture: Orchestrator-Workers pattern with intelligent routing
- 3 Specialized Advisors: Crypto, Forex, and Stock analysis
- 4-Agent Teams: Supervisor, Technical Analyst, Sentiment Analyst, Market Researcher
- Real-time Streaming: Live agent status updates via SSE
- Smart Routing: 1-2 agents for simple queries, 2-3 for comprehensive analysis
- Token Budget Trimming: Dynamic message history based on token budget instead of a fixed count
- Stocks: Real-time stock data with technical indicators
- Forex: Currency pair analysis and trends
- Crypto: Cryptocurrency market tracking
- Create and manage multiple portfolios
- Track holdings with real-time P&L calculations
- Portfolio analytics dashboard with interactive charts
- Export portfolio data (CSV/PDF)
- Track favorite assets across all markets
- Quick access to watched assets
- Statistics and performance tracking
- Export watchlist data
- Command palette (⌘K / Ctrl+K)
- Real-time fuzzy search across all markets
- Recent items tracking
- Keyboard-first navigation
- Portfolio value over time (area charts)
- Asset allocation (pie charts)
- P&L breakdown (bar charts)
- Market heatmap (sector performance)
- Correlation matrix (diversification analysis)
- OHLC price charts with time ranges
- Responsive design with dark/light theme support
- Smooth animations with Framer Motion
- Accessible (WCAG AA compliant)
- Framework: Next.js 16 (App Router)
- Language: TypeScript 5.9
- Styling: Tailwind CSS v4
- UI Components: shadcn/ui
- Animations: Framer Motion
- Charts: Recharts
- State Management: React Hooks, SWR
- Runtime: Node.js
- API: Next.js API Routes
- Database: MongoDB Atlas
- Authentication: NextAuth.js v4
- Multi-Agent AI:
- LangGraph (State Machine Orchestration)
- LangChain (Tool Integration)
- Groq (LLaMA 3.3 70B + LLaMA 3.1 8B)
- Search & Intelligence: Tavily API
- Email: Resend API (password reset)
- Market Data: Twelve Data API (stocks, forex, crypto)
- News: NewsAPI
- Community Sentiment: Reddit API (15+ financial subreddits)
- Market Intelligence: Tavily Search API
- Technical Indicators: RSI, MACD, EMA, Bollinger Bands, ATR, ADX
- Testing: Jest 30, React Testing Library, Playwright
- E2E Testing: Playwright (multi-browser + mobile)
- Linting: ESLint
- Accessibility: axe-core, eslint-plugin-jsx-a11y
- Bundle Analysis: @next/bundle-analyzer
- CI/CD: GitHub Actions
- Security: isomorphic-dompurify v3 (XSS prevention)
- Unit Tests: Jest + React Testing Library
- Rate limiter (18 tests)
- AI utilities —
trimToTokenBudget,collectToolResults(13 tests) - Graph factory — routing logic, supervisor cap, config contract (15 tests)
- E2E Tests: 6 test suites with Playwright
- Homepage & navigation
- Search functionality (Command Palette)
- Portfolio management
- Watchlist operations
- Market data pages
- Crypto routes
- Multi-browser (Chrome, Firefox, Safari) + mobile (Pixel 5, iPhone 12)
- CI/CD: Automated testing on every push and PR
- Coverage Threshold: 50% enforced on branches, functions, lines, and statements
- Code Coverage: Codecov integration
- Security Headers: HSTS, CSP (nonce-based), X-Frame-Options, X-XSS-Protection, and more
- Input Sanitization: isomorphic-dompurify v3 — XSS prevention, HTML sanitization
- Rate Limiting: Shared in-memory rate limiter across all API routes
- CSRF Protection: NextAuth.js integration
- Password Reset: Transactional email via Resend API
- Node.js 18+ and npm
- MongoDB Atlas account (free tier available)
- API keys (see Environment Variables below)
# Clone the repository
git clone https://github.com/RobinMillford/Ai-Finance.git
cd Ai-Finance
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your API keys
# Run development server (Turbopack enabled)
npm run devOpen http://localhost:3000 to see the application.
# Create optimized production build
npm run build
# Start production server
npm start
# Analyze bundle size
npm run analyzeCopy .env.example to .env.local and fill in your values. All variables are documented in .env.example.
# Database
MONGODB_URI=your_mongodb_connection_string
# Authentication
NEXTAUTH_SECRET=your_nextauth_secret
NEXTAUTH_URL=http://localhost:3000
# AI - Multi-Agent System (required)
NEXT_PUBLIC_GROQ_API_KEY=your_groq_api_key
# Market Data (required)
NEXT_PUBLIC_TWELVEDATA_API_KEY=your_twelve_data_key
NEXT_PUBLIC_TAVILY_API_KEY=your_tavily_api_key
NEXT_PUBLIC_NEWS_API_KEY=your_news_api_key
# Email — password reset (optional, logs to console if unset)
RESEND_API_KEY=your_resend_key
# Reddit — social sentiment (optional)
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret- MongoDB: MongoDB Atlas
- Groq: Groq Cloud
- Twelve Data: Twelve Data
- NewsAPI: NewsAPI
- Tavily: Tavily
- Resend: Resend
- Reddit: Reddit Apps
financeai/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── chat/ # Crypto Multi-Agent API
│ │ ├── forex-chat/ # Forex Multi-Agent API
│ │ ├── stock-chat/ # Stock Multi-Agent API
│ │ ├── portfolio/ # Portfolio endpoints
│ │ ├── watchlist/ # Watchlist endpoints
│ │ ├── stocks/ # Stock data
│ │ ├── forex/ # Forex data
│ │ ├── cryptos/ # Crypto data
│ │ ├── reddit/ # Reddit sentiment
│ │ ├── news/ # News aggregation
│ │ └── market-intelligence/ # Market intelligence
│ ├── cryptoadvisor/ # Crypto Multi-Agent UI
│ ├── forexadvisor/ # Forex Multi-Agent UI
│ ├── stockadvisor/ # Stock Multi-Agent UI
│ ├── portfolio/ # Portfolio pages
│ ├── watchlist/ # Watchlist pages
│ ├── stocks/ # Stock analysis
│ ├── forexs/ # Forex analysis
│ ├── cryptos/ # Crypto analysis
│ ├── dashboard/ # Dashboard
│ └── layout.tsx # Root layout
├── components/ # React components
│ ├── ui/ # UI components (shadcn)
│ └── charts/ # Chart components
│ ├── TechnicalChart.tsx # Shared recharts wrapper (memo)
│ ├── PortfolioAnalytics.tsx
│ ├── MarketHeatmap.tsx
│ ├── CorrelationMatrix.tsx
│ └── PriceChart.tsx
├── lib/ # Utility functions
│ ├── ai/ # Multi-Agent AI system
│ │ ├── config.ts # LLM configuration (env-driven)
│ │ ├── graph-factory.ts # Shared advisor graph factory
│ │ ├── utils.ts # trimToTokenBudget, collectToolResults
│ │ ├── graph.ts # Crypto advisor (thin wrapper)
│ │ ├── forex-graph.ts # Forex advisor (thin wrapper)
│ │ ├── stock-graph.ts # Stock advisor (thin wrapper)
│ │ ├── __tests__/ # Unit tests for AI utilities
│ │ └── tools/ # AI tools
│ │ ├── financial.ts # Crypto price & indicators
│ │ ├── forex.ts # Forex quotes & indicators
│ │ ├── stock.ts # Stock quotes & indicators
│ │ ├── social.ts # Reddit sentiment
│ │ └── search.ts # Tavily search
│ ├── __tests__/ # Unit tests
│ ├── rate-limiter.ts # Shared in-memory rate limiter
│ ├── email.ts # Resend transactional email
│ ├── market-intelligence.ts # Market analysis (Tavily)
│ ├── mongodb.ts # Database connection
│ ├── sanitize.ts # DOMPurify XSS sanitization
│ └── export-utils.ts # CSV/PDF export
├── models/ # MongoDB models
│ ├── Portfolio.ts
│ ├── Watchlist.ts
│ └── User.ts
├── e2e/ # Playwright E2E tests (6 suites)
├── middleware.ts # CSP nonces + auth middleware
├── .env.example # All env vars documented
└── next.config.js # Next.js configuration
Orchestrator-Workers pattern — one supervisor per domain coordinates three specialist workers:
User Query
│
▼
Supervisor (LLaMA 3.3 70B)
│ Analyzes query, picks agent(s), enforces 3-call cap
├──▶ TechnicalAnalyst (LLaMA 3.1 8B) — prices, indicators
├──▶ SentimentAnalyst (LLaMA 3.1 8B) — Reddit community mood
└──▶ MarketResearcher (LLaMA 3.1 8B) — news, events, macro
│
▼
finalResponse — synthesizes all collected data
Three domain-specific advisors share one graph-factory.ts — each provides only the prompts and tools that differ per domain:
- Crypto Advisor — cryptocurrency prices, social sentiment
- Forex Advisor — currency pair quotes, economic indicators
- Stock Advisor — US stock data, earnings, sector news
Example workflows:
- "What's AAPL price?" → TechnicalAnalyst → Response (1 agent)
- "Analyze TSLA" → TechnicalAnalyst + SentimentAnalyst → Response (2 agents)
- "BTC full outlook" → All 3 agents → Comprehensive Response
npm run dev # Start dev server with Turbopack
npm run build # Production build
npm start # Start production server
npm run analyze # Build with bundle size report
npm test # Run unit tests
npm run test:watch # Unit tests in watch mode
npm run test:coverage # Unit tests with coverage report
npx playwright test # Run E2E tests
npx playwright test --ui # E2E in interactive UI mode
npx playwright test --project=chromium # Single browser
npx playwright show-report # View last E2E report- Code splitting and lazy loading
React.memoanduseMemoon all heavy chart components- Turbopack for fast HMR in development
- Image optimization (WebP/AVIF)
- Server-side rendering where appropriate
- WCAG AA compliant
- Keyboard navigation support
- Screen reader compatible
- ARIA labels and roles
- Semantic HTML
- Color contrast compliance
- Secure authentication with NextAuth.js
- Per-request CSP nonces (no
unsafe-inline/unsafe-evalin production) - Rate limiting on all API routes
- Input sanitization with isomorphic-dompurify v3
- CSRF protection via NextAuth.js
- Environment variable validation at startup
Contributions are welcome! Please follow these steps:
- 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
Please ensure:
- Code follows TypeScript and ESLint standards
- Tests pass (
npm test) - Accessibility guidelines are followed
- Documentation is updated
Yamin Hossain
- LinkedIn: Yamin Hossain
- GitHub: @RobinMillford
- Next.js — React framework
- LangGraph — Multi-agent orchestration
- LangChain — AI tool integration
- Groq — Ultra-fast LLM inference
- shadcn/ui — UI components
- Recharts — Chart library
- Twelve Data — Market data
- Tavily — AI-powered search
- Resend — Transactional email
- Multi-Agent AI system (Crypto, Forex, Stock advisors)
- Shared graph factory — single source for all 3 advisors
- LangGraph orchestration with smart routing and 3-call cap
- Real-time streaming with SSE
- Token-budget message trimming (dynamic, env-configurable)
- Portfolio management system
- Watchlist functionality
- Advanced search (Command Palette)
- Data visualizations (5 chart types, all recharts)
- Export functionality (CSV/PDF)
- E2E testing with Playwright (6 suites, multi-browser + mobile)
- Unit tests with 50% coverage threshold enforced
- Security hardening (nonce-based CSP, DOMPurify v3, rate limiting)
- Turbopack dev server
- CI/CD pipeline with GitHub Actions (test → build → E2E → deploy)
- Real-time price updates via WebSocket
- Advanced technical indicators (Fibonacci, Ichimoku)
- Price alerts and notifications
- Advanced backtesting with historical data
- Advanced portfolio analytics (Sharpe ratio, beta, alpha)
- Multi-language support
- Options & derivatives trading analysis
This project is licensed under the GNU General Public License v3.0 — see the LICENSE file for details.
Built with Next.js and TypeScript

