Skip to content

A comprehensive financial analysis platform built with Next.js that provides AI-powered insights for stocks, cryptocurrencies, and forex markets. The platform offers real-time market data, technical analysis, and personalized financial advice.

License

Notifications You must be signed in to change notification settings

RobinMillford/Ai-Finance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FinanceAI - AI-Powered Financial Analysis Platform

Next.js React TypeScript License Tests Performance

A production-ready financial analysis platform with AI-powered insights, real-time market data, portfolio management, and advanced search capabilities.

FinanceAI Dashboard

FinanceAI Dashboard

🎯 Overview

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.

✨ Key Features

πŸ“Š Multi-Market Analysis

  • Stocks: Real-time stock data with technical indicators
  • Forex: Currency pair analysis and trends
  • Crypto: Cryptocurrency market tracking

πŸ’Ό Portfolio Management

  • Create and manage multiple portfolios
  • Track holdings with real-time P&L calculations
  • Portfolio analytics dashboard with interactive charts
  • Export portfolio data (CSV/PDF)

πŸ‘οΈ Watchlist System

  • Track favorite assets across all markets
  • Quick access to watched assets
  • Statistics and performance tracking
  • Export watchlist data

πŸ” Advanced Search

  • Command palette (⌘K / Ctrl+K)
  • Real-time fuzzy search across all markets
  • Recent items tracking
  • Keyboard-first navigation

πŸ“ˆ Data Visualizations

  • 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

πŸ€– AI-Powered Insights

  • LLaMA 3 integration via Groq
  • Market intelligence analysis
  • Reddit sentiment analysis (15+ subreddits)
  • News aggregation and analysis

🎨 Modern UI/UX

  • Beautiful, responsive design
  • Dark/Light theme support
  • Smooth animations with Framer Motion
  • Accessible (WCAG AA compliant)
  • Progressive Web App (PWA)

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: shadcn/ui
  • Animations: Framer Motion
  • Charts: Recharts, D3.js
  • State Management: React Hooks, SWR

Backend

  • Runtime: Node.js
  • API: Next.js API Routes
  • Database: MongoDB Atlas
  • Authentication: NextAuth.js
  • AI: Groq (LLaMA 3), LangChain
  • Search: Tavily API

Data Sources

  • Market Data: Twelve Data API
  • News: NewsAPI
  • Community: Reddit API
  • Search: Tavily Search API

Development Tools

  • Testing: Jest, React Testing Library, Playwright
  • E2E Testing: Playwright (multi-browser + mobile)
  • Linting: ESLint, Prettier
  • Accessibility: axe-core, eslint-plugin-jsx-a11y
  • Bundle Analysis: @next/bundle-analyzer
  • CI/CD: GitHub Actions
  • Security: DOMPurify (XSS prevention)

πŸ§ͺ Testing & Quality Assurance

Comprehensive Test Coverage

  • Unit Tests: 28 tests with Jest & React Testing Library
    • Rate limiter tests
    • API client tests
    • Utility function tests
  • E2E Tests: 25+ tests with Playwright
    • Homepage & navigation
    • Search functionality (Command Palette)
    • Portfolio management
    • Watchlist operations
    • Market data pages
    • Multi-browser testing (Chrome, Firefox, Safari)
    • Mobile testing (Pixel 5, iPhone 12)
  • CI/CD: Automated testing on every push/PR
  • Code Coverage: Codecov integration

Security Features

  • Security Headers: 8 comprehensive headers
    • HSTS (Strict Transport Security)
    • CSP (Content Security Policy)
    • X-Frame-Options (Clickjacking prevention)
    • X-XSS-Protection
    • And more...
  • Input Sanitization: DOMPurify integration
    • XSS prevention
    • HTML sanitization
    • URL validation
    • Email validation
    • Filename sanitization
  • Environment Validation: Required variable checking
  • Rate Limiting: API route protection
  • CSRF Protection: NextAuth.js integration

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MongoDB Atlas account (free tier)
  • API keys (see Environment Variables)

Installation

# 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
npm run dev

Open http://localhost:3000 to see the application.

Build for Production

# Create optimized production build
npm run build

# Start production server
npm start

# Analyze bundle size
ANALYZE=true npm run build

πŸ” Environment Variables

Create a .env.local file in the root directory:

# Database
MONGODB_URI=your_mongodb_connection_string

# Authentication
NEXTAUTH_SECRET=your_nextauth_secret
NEXTAUTH_URL=http://localhost:3000

# Market Data
TWELVE_DATA_API_KEY=your_twelve_data_key

# News
NEWS_API_KEY=your_news_api_key

# AI
GROQ_API_KEY=your_groq_api_key

# Search
TAVILY_API_KEY=your_tavily_api_key

# Reddit (Optional)
REDDIT_CLIENT_ID=your_reddit_client_id
REDDIT_CLIENT_SECRET=your_reddit_client_secret

Getting API Keys

πŸ“ Project Structure

financeai/
β”œβ”€β”€ app/                      # Next.js app directory
β”‚   β”œβ”€β”€ api/                  # API routes
β”‚   β”‚   β”œβ”€β”€ portfolio/        # Portfolio endpoints
β”‚   β”‚   β”œβ”€β”€ watchlist/        # Watchlist endpoints
β”‚   β”‚   β”œβ”€β”€ stocks/           # Stock data
β”‚   β”‚   β”œβ”€β”€ forex/            # Forex data
β”‚   β”‚   └── cryptos/          # Crypto data
β”‚   β”œβ”€β”€ portfolio/            # Portfolio pages
β”‚   β”œβ”€β”€ watchlist/            # Watchlist pages
β”‚   β”œβ”€β”€ stocks/               # Stock analysis
β”‚   β”œβ”€β”€ forexs/               # Forex analysis
β”‚   β”œβ”€β”€ cryptos/              # Crypto analysis
β”‚   └── layout.tsx            # Root layout
β”œβ”€β”€ components/               # React components
β”‚   β”œβ”€β”€ ui/                   # UI components (shadcn)
β”‚   β”œβ”€β”€ charts/               # Chart components
β”‚   β”œβ”€β”€ CommandPalette.tsx    # Search command palette
β”‚   β”œβ”€β”€ ExportButton.tsx      # Export functionality
β”‚   └── ...
β”œβ”€β”€ lib/                      # Utility functions
β”‚   β”œβ”€β”€ export-utils.ts       # CSV/PDF export
β”‚   β”œβ”€β”€ mongodb.ts            # Database connection
β”‚   └── ...
β”œβ”€β”€ models/                   # MongoDB models
β”‚   β”œβ”€β”€ Portfolio.ts
β”‚   β”œβ”€β”€ Watchlist.ts
β”‚   └── User.ts
β”œβ”€β”€ contexts/                 # React contexts
β”‚   └── AuthContext.tsx
β”œβ”€β”€ public/                   # Static assets
└── next.config.js            # Next.js configuration

🎨 Features in Detail

Portfolio Management

Create and manage investment portfolios with:

  • Add/remove holdings
  • Real-time P&L tracking
  • Performance analytics
  • Asset allocation visualization
  • Export to CSV/PDF

Watchlist System

Track your favorite assets:

  • Multi-market support (stocks, forex, crypto)
  • Quick access from any page
  • Performance statistics
  • Export capabilities

Advanced Search

Powerful search with:

  • Keyboard shortcuts (⌘K / Ctrl+K)
  • Fuzzy matching
  • Recent searches
  • Cross-market search

Data Visualizations

Professional charts:

  • Portfolio analytics dashboard
  • Market heatmap
  • Correlation matrix
  • OHLC price charts
  • Interactive tooltips

πŸ§ͺ Testing

# Run unit tests
npm test

# Run tests in watch mode
npm test -- --watch

# Run tests with coverage
npm test -- --coverage

# Run E2E tests
npx playwright test

# Run E2E tests in UI mode
npx playwright test --ui

# Run E2E tests on specific browser
npx playwright test --project=chromium

# View E2E test report
npx playwright show-report

Test Coverage

  • Unit Tests: 28 tests (Jest + React Testing Library)
  • E2E Tests: 25+ tests (Playwright)
  • Total: 53+ automated tests
  • Coverage: 85%+ on tested modules

πŸ“Š Performance

  • Lighthouse Score: 90+ (Production)
  • First Contentful Paint: <0.5s
  • Largest Contentful Paint: <2.5s
  • Time to Interactive: <3s
  • Cumulative Layout Shift: <0.1

Optimizations Implemented

  • Code splitting and lazy loading
  • React.memo and useMemo for expensive operations
  • Image optimization (WebP/AVIF)
  • Bundle size optimization
  • Server-side rendering where appropriate
  • Edge caching for static assets

β™Ώ Accessibility

  • WCAG AA compliant
  • Keyboard navigation support
  • Screen reader compatible
  • ARIA labels and roles
  • Semantic HTML
  • Color contrast compliance

πŸ”’ Security

  • Secure authentication with NextAuth.js
  • Environment variable validation
  • Rate limiting on API routes
  • Input sanitization
  • CSRF protection
  • Security headers (HSTS, XFO, CSP)

πŸ“± Progressive Web App

  • Installable on desktop and mobile
  • Offline support (coming soon)
  • App-like experience
  • Fast loading times

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure:

  • Code follows TypeScript and ESLint standards
  • Tests pass (npm test)
  • Accessibility guidelines are followed
  • Documentation is updated

πŸ‘¨β€πŸ’» Author

Yamin Hossain

πŸ™ Acknowledgments

πŸ—ΊοΈ Roadmap

βœ… Completed

  • Portfolio management system
  • Watchlist functionality
  • Advanced search (Command Palette)
  • Data visualizations (5 chart types)
  • Export functionality (CSV/PDF)
  • E2E testing with Playwright
  • Security hardening
  • Performance optimization
  • CI/CD pipeline

🚧 In Progress

  • Real-time price updates via WebSocket
  • Advanced technical indicators
  • Price alerts and notifications

πŸ“‹ Planned

  • Social trading features
  • Mobile app (React Native)
  • Advanced portfolio analytics
  • Backtesting capabilities
  • Multi-language support

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

GPL-3.0 License Summary

  • βœ… Freedom to use - Use the software for any purpose
  • βœ… Freedom to study - Study how the program works and modify it
  • βœ… Freedom to share - Redistribute copies to help others
  • βœ… Freedom to improve - Distribute modified versions

Note: Any derivative work must also be licensed under GPL-3.0 and source code must be made available.


Built with ❀️ using Next.js and TypeScript

About

A comprehensive financial analysis platform built with Next.js that provides AI-powered insights for stocks, cryptocurrencies, and forex markets. The platform offers real-time market data, technical analysis, and personalized financial advice.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages