A comprehensive ChatGPT-like stock analysis platform with AI-powered insights, real-time data, and professional portfolio management tools.
- AI-Powered Analysis: Google Gemini AI integration for intelligent stock recommendations
- Real-time Stock Data: Yahoo Finance API integration for live market data
- Portfolio Management: Comprehensive tracking with performance metrics
- Role-Based Access: Separate interfaces for analysts and investors
- Technical Indicators: RSI, MACD, SMA, EMA calculations
- Risk Assessment: Portfolio diversification and concentration analysis
- 3D Portfolio Visualization: Interactive 3D donut charts showing portfolio allocation by sector/stock with hover effects and smooth animations
- 3D Stock Performance Cubes: Dynamic 3D bar charts displaying stock performance over time with depth and perspective
- Interactive 3D Market Globe: Rotating 3D globe showing global market performance with clickable regions
- 3D Risk Assessment Pyramid: Multi-layered 3D pyramid visualization showing risk levels across different portfolio segments
- Real-time Candlestick Charts: Interactive candlestick charts with zoom, pan, and technical indicator overlays (RSI, MACD, Bollinger Bands)
- Multi-dimensional Scatter Plots: 3D scatter plots showing risk vs. return vs. market cap relationships
- Animated Line Charts: Smooth animated line charts for portfolio performance over time with gradient fills
- Heatmap Visualizations: Interactive sector performance heatmaps with color-coded performance indicators
- Correlation Matrix Charts: Visual correlation matrices showing relationships between different stocks/sectors
- Glassmorphism Effects: Modern glass-like effects on chart containers with backdrop blur
- Dark/Light Theme Toggle: Seamless theme switching for all visualizations with system preference detection
- Loading Skeletons: Smooth loading animations for chart components
- Chart Customization: Extensive options for colors, time ranges, and technical indicators
- Export Functionality: Export charts as PNG, PDF, or SVG with customizable options
- Accessibility Features: Keyboard navigation and screen reader support
- Google OAuth Authentication: Secure login with NextAuth.js
- Role-Based Permissions: Analyst and investor user types
- User-Analyst Relationships: Many-to-many mapping system
- Session Management: Secure token validation
- Investor Dashboard: Portfolio overview, performance metrics, AI recommendations
- Analyst Dashboard: Multi-investor management, report generation tools
- Interactive Charts: Real-time data visualization
- Report History: Historical analysis tracking
- Framework: Next.js 15 with App Router
- Database: MongoDB Atlas with Mongoose ODM
- Authentication: NextAuth.js with Google OAuth
- AI Integration: Google Gemini API
- Stock Data: Yahoo Finance API
- Framework: React 18 with TypeScript
- Styling: Tailwind CSS with Dark Mode Support
- 3D Graphics: Three.js with React Three Fiber
- Animations: Framer Motion for smooth transitions
- Charts: D3.js, Chart.js, React-Chartjs-2
- UI Components: Headless UI, Heroicons
- State Management: React Hooks and Context API
- Language: TypeScript
- Linting: ESLint
- Package Manager: npm
- Environment: Node.js
Before running this application, make sure you have:
- Node.js 18+ installed
- MongoDB Atlas account
- Google Cloud Console project with OAuth credentials
- Google Gemini API key
- Alpha Vantage API key (optional)
-
Clone the repository
git clone <repository-url> cd stock-analysis-platform
-
Install dependencies
npm install
-
Environment Setup
Copy the environment example file:
cp .env.example .env.local
Update
.env.local
with your credentials:# Database Configuration MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/stock-analysis # NextAuth Configuration NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your-nextauth-secret-key # Google OAuth Configuration GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret # Google Gemini AI Configuration GEMINI_API_KEY=your-gemini-api-key # Alpha Vantage API (optional) ALPHA_VANTAGE_API_KEY=your-alpha-vantage-api-key
-
Database Setup
The application will automatically create the necessary collections and indexes when you first run it.
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/google
- Visit Google AI Studio
- Create a new API key
- Copy the key to your environment variables
- Create account at MongoDB Atlas
- Create a new cluster
- Create database user
- Get connection string
- Add your IP to whitelist
src/
βββ app/ # Next.js App Router
β βββ api/ # API routes
β βββ auth/ # Authentication pages
β βββ dashboard/ # Dashboard pages
β βββ globals.css # Global styles
βββ components/ # React components
β βββ dashboard/ # Dashboard components
β βββ layout/ # Layout components
β βββ providers/ # Context providers
βββ lib/ # Utility libraries
β βββ auth.ts # NextAuth configuration
β βββ geminiAI.ts # AI integration
β βββ mongodb.ts # Database connection
β βββ stockData.ts # Stock data service
βββ models/ # Mongoose models
β βββ User.ts # User model
β βββ Portfolio.ts # Portfolio model
β βββ AnalysisReport.ts # Analysis report model
β βββ UserAnalyst.ts # User-analyst relationship
βββ types/ # TypeScript type definitions
βββ tests/ # Test suites
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ e2e/ # End-to-end tests
βββ docs/ # Comprehensive documentation
βββ getting-started/ # Installation and setup guides
βββ api/ # API documentation
βββ architecture/ # System architecture docs
βββ features/ # Feature-specific guides
βββ deployment/ # Deployment guides
βββ testing/ # Testing documentation
βββ reports/ # Technical reports
βββ maintenance/ # Maintenance and monitoring
Comprehensive documentation is available in the /docs
folder:
- Installation Guide - Complete setup instructions
- Configuration Guide - Environment configuration
- Quick Start Guide - Get up and running quickly
- Complete API Reference - Full API documentation
- Authentication - Auth endpoints and security
- Portfolio Management - Portfolio APIs
- Stock Data - Stock market data APIs
- System Overview - High-level architecture
- Technical Decisions - Architecture rationale
- Security Implementation - Security measures
- AI-Powered Analysis - AI capabilities and implementation
- Indian Market Integration - NSE/BSE integration
- 3D Visualizations - Advanced 3D features
- Deployment Guide - Production deployment
- Environment Setup - Environment configuration
- Production Checklist - Pre-deployment checklist
- Testing Guide - Testing strategies and setup
- Test Coverage - Coverage reports and metrics
- Technical Report - Comprehensive technical analysis
- Assignment Deliverables - Project deliverables
- Performance Optimization - Performance tuning
- Monitoring & Logging - System monitoring
- Troubleshooting - Common issues and solutions
-
Push to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Deploy to Vercel
- Connect your GitHub repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically
Make sure to set all environment variables in your production environment:
- Update
NEXTAUTH_URL
to your production domain - Use strong secrets for
NEXTAUTH_SECRET
andJWT_SECRET
- Configure production MongoDB connection string
- Sign in with Google account
- Create portfolios and add stock holdings
- Generate AI analysis for investment recommendations
- View performance metrics and risk assessment
- Track historical analysis reports
- Sign in with Google account (role assigned by admin)
- Manage multiple investor portfolios
- Generate comprehensive analysis reports
- Monitor client portfolio performance
- Provide investment recommendations
Run the test suite:
npm test
Run tests in watch mode:
npm run test:watch
- Caching: Stock data cached for 5 minutes
- Rate Limiting: API calls limited to prevent abuse
- Database Indexing: Optimized queries with proper indexes
- Image Optimization: Next.js automatic image optimization
- Code Splitting: Automatic code splitting with Next.js
- Authentication: Secure OAuth with NextAuth.js
- Authorization: Role-based access control
- Data Validation: Input sanitization and validation
- Environment Variables: Secure credential management
- HTTPS: SSL/TLS encryption in production
- CORS: Cross-origin request protection
- 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.
For support, email support@stockanalysis.com or create an issue in the GitHub repository.
- Next.js for the amazing framework
- Google Gemini for AI capabilities
- Yahoo Finance for stock data
- Tailwind CSS for styling
- MongoDB for database solutions