Skip to content

AI-powered Indian stock analysis platform integrating Google Gemini for intelligent investment recommendations with real-time NSE/BSE data. Features portfolio management with INR support, technical indicators, interactive visualizations, and role-based access for analysts and investors. Built with Next.js, React, MongoDB, and NextAuth.js.

Notifications You must be signed in to change notification settings

GreenHacker420/stock-analysis-platform

Repository files navigation

Stock Analysis Platform

A comprehensive ChatGPT-like stock analysis platform with AI-powered insights, real-time data, and professional portfolio management tools.

πŸš€ Features

Core Functionality

  • 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

🎨 Advanced 3D Visualizations

  • 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

πŸ“Š Advanced Charts & Analytics

  • 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

🎯 UI/UX Enhancements

  • 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

User Management

  • 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

Dashboard Features

  • 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

πŸ›  Tech Stack

Backend

  • 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

Frontend

  • 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

Development

  • Language: TypeScript
  • Linting: ESLint
  • Package Manager: npm
  • Environment: Node.js

πŸ“‹ Prerequisites

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)

πŸ”§ Installation

  1. Clone the repository

    git clone <repository-url>
    cd stock-analysis-platform
  2. Install dependencies

    npm install
  3. 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
  4. Database Setup

    The application will automatically create the necessary collections and indexes when you first run it.

  5. Run the development server

    npm run dev
  6. Open your browser

    Navigate to http://localhost:3000

πŸ”‘ API Keys Setup

Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable Google+ API
  4. Create OAuth 2.0 credentials
  5. Add authorized redirect URIs: http://localhost:3000/api/auth/callback/google

Google Gemini API Setup

  1. Visit Google AI Studio
  2. Create a new API key
  3. Copy the key to your environment variables

MongoDB Atlas Setup

  1. Create account at MongoDB Atlas
  2. Create a new cluster
  3. Create database user
  4. Get connection string
  5. Add your IP to whitelist

πŸ“ Project Structure

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

πŸ“š Documentation

Comprehensive documentation is available in the /docs folder:

πŸš€ Getting Started

πŸ”Œ API Documentation

πŸ—οΈ Architecture

✨ Features

πŸš€ Deployment

πŸ§ͺ Testing

πŸ“Š Reports

πŸ”§ Maintenance

πŸš€ Deployment

Vercel Deployment (Recommended)

  1. Push to GitHub

    git add .
    git commit -m "Initial commit"
    git push origin main
  2. Deploy to Vercel

    • Connect your GitHub repository to Vercel
    • Add environment variables in Vercel dashboard
    • Deploy automatically

Environment Variables for Production

Make sure to set all environment variables in your production environment:

  • Update NEXTAUTH_URL to your production domain
  • Use strong secrets for NEXTAUTH_SECRET and JWT_SECRET
  • Configure production MongoDB connection string

πŸ“Š Usage

For Investors

  1. Sign in with Google account
  2. Create portfolios and add stock holdings
  3. Generate AI analysis for investment recommendations
  4. View performance metrics and risk assessment
  5. Track historical analysis reports

For Analysts

  1. Sign in with Google account (role assigned by admin)
  2. Manage multiple investor portfolios
  3. Generate comprehensive analysis reports
  4. Monitor client portfolio performance
  5. Provide investment recommendations

πŸ§ͺ Testing

Run the test suite:

npm test

Run tests in watch mode:

npm run test:watch

πŸ“ˆ Performance Optimization

  • 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

πŸ”’ Security Features

  • 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

🀝 Contributing

  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

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

For support, email support@stockanalysis.com or create an issue in the GitHub repository.

πŸ™ Acknowledgments

About

AI-powered Indian stock analysis platform integrating Google Gemini for intelligent investment recommendations with real-time NSE/BSE data. Features portfolio management with INR support, technical indicators, interactive visualizations, and role-based access for analysts and investors. Built with Next.js, React, MongoDB, and NextAuth.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published