Skip to content

shreyas463/Stock-Analysis-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

104 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Stock Analysis Platform

A modern, full-stack trading simulation platform with real-time market data

Next.js Flask Firebase Finnhub License

🌟 Overview

The Stock Analysis Platform is a comprehensive web application that replicates the core features of popular trading platforms like Robinhood. It combines real-time market data with intelligent analysis tools to provide users with an immersive trading simulation experience.

πŸ” Live Demo

πŸ—οΈ Deployment Architecture

  • Frontend: Deployed on Vercel for seamless Next.js integration and global CDN distribution
  • Backend: Hosted on Render with automatic scaling and continuous deployment
  • Database: Firebase Firestore for real-time data synchronization across clients
  • Authentication: Firebase Authentication for secure user management
  • Environment Variables: Securely managed through Vercel and Render dashboards

✨ Key Features

  • πŸ“Š Real-time Market Data - Live stock prices and market data via Finnhub API
  • πŸ“‰ Interactive Charts - Visualize stock performance with customizable time ranges
  • 🧠 Smart Trading Insights - Data-driven recommendations powered by statistical analysis
  • πŸ’Ό Portfolio Management - Track your investments and performance metrics
  • πŸ’° Trading Simulation - Buy and sell stocks with virtual currency
  • πŸ”’ Secure Authentication - User accounts powered by Firebase
  • πŸ“± Responsive Design - Optimized for both desktop and mobile devices
  • πŸ“° News Integration - Latest stock-related news for informed decisions
  • πŸ’¬ Discussion Forum - Community discussions about stocks and market trends
  • πŸš€ Top Gainers - Track the best-performing stocks in real-time

πŸ› οΈ Technology Stack

Frontend

  • βš›οΈ Next.js - React framework for production
  • 🎨 Material UI - Comprehensive component library
  • πŸ“Š Chart.js - Interactive data visualization
  • πŸ” Firebase Auth - Secure user authentication
  • πŸ“ TypeScript - Static type checking
  • πŸ”„ SWR - Data fetching and caching

Backend

  • 🐍 Flask - Python web framework
  • πŸ”₯ Firebase Firestore - NoSQL database
  • πŸ“‘ Finnhub API - Real-time stock market data
  • πŸ“Š Statistical Analysis - Time series forecasting
  • πŸ”‘ JWT - Token-based authentication
  • ☁️ Render - Cloud deployment platform

πŸ“‹ Prerequisites

  • Node.js (v14 or higher)
  • Python (v3.8 or higher)
  • Firebase account
  • Finnhub API key (free tier available)
  • Git for version control

πŸ”§ Installation & Setup

1️⃣ Clone the Repository

git clone https://github.com/shreyas463/Stock-Analysis-platform.git
cd Stock-Analysis-platform

2️⃣ Firebase Setup

  1. Create a new Firebase project at Firebase Console
  2. Enable Authentication (with Email/Password) and Firestore in your project
  3. Generate a new web app in your Firebase project and copy the configuration
  4. Generate a new service account key for the admin SDK:
    • Go to Project Settings > Service Accounts
    • Click "Generate New Private Key"
    • Save the JSON file as serviceAccountKey.json in the backend directory

3️⃣ Backend Setup

# Navigate to the backend directory
cd backend

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create and configure environment variables
cp .env.example .env

Update the .env file with your API keys and Firebase configuration:

FLASK_APP=app.py
FLASK_ENV=development
GOOGLE_APPLICATION_CREDENTIALS=serviceAccountKey.json
SECRET_KEY=your-secret-key-here
FINNHUB_API_KEY=your-finnhub-api-key

4️⃣ Frontend Setup

# Navigate to the frontend directory
cd ../frontend

# Install dependencies
npm install

# Create and configure environment variables
cp .env.example .env.local

Update the .env.local file with your Firebase configuration:

NEXT_PUBLIC_API_URL=http://localhost:5001
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
NEXT_PUBLIC_FIREBASE_APP_ID=your-app-id

πŸš€ Running the Application

Local Development

1. Start the backend server:

# From the project root
cd backend
source venv/bin/activate  # On Windows: venv\Scripts\activate
python app.py

The backend server will start on http://localhost:5001

2. Start the frontend development server:

# From the project root (in a new terminal)
cd frontend
npm run dev

3. Access the application:

Open http://localhost:3000 in your browser

Production Deployment

This application is deployed using a modern cloud architecture:

  • Frontend: Deployed on Vercel

    • Automatic deployments from the main branch
    • Environment variables configured in Vercel dashboard
    • Custom domain configuration with SSL
  • Backend: Hosted on Render

    • Web service with automatic scaling
    • Environment variables securely stored
    • Continuous deployment from GitHub

For detailed deployment instructions, see DEPLOYMENT.md

πŸ“„ License

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

πŸ”„ Latest Updates

πŸ”§ March 2025: Finnhub API Integration Fix
  • πŸ› Bug Fix: Resolved issues with Finnhub stock price display in production environment
  • πŸ”’ Environment Variables: Improved handling of API keys and environment configuration
  • 🌐 CORS Configuration: Enhanced cross-origin resource sharing for better API communication
  • πŸ“ Logging: Added comprehensive logging for better debugging and monitoring
  • ⚠️ Error Handling: Improved error messages and fallback mechanisms
πŸ“Š Stock Analysis Feature Improvements
  • πŸ”„ Backend-Frontend Integration: Fixed mismatch between backend response structure and frontend interface
  • πŸ—ΊοΈ Data Mapping: Implemented proper mapping of backend response data to match frontend expectations
  • ⚠️ Error Handling: Enhanced error handling with proper type checking
  • πŸ‘€ User Experience: Improved reliability for better trading decisions
⚑ Performance & Reliability Enhancements
  • πŸ’° Portfolio Calculations: Enhanced accuracy of value calculations
  • ⏱️ Price Loading Optimization:
    • Removed unnecessary re-renders
    • Extended update intervals from 10s to 15s
    • Eliminated redundant console logs
    • Simplified portfolio value calculations
  • 🧠 ML Analysis: Separated analysis from buy logic for better maintainability
  • πŸ”’ Type Safety: Added comprehensive type checking throughout the application
🎨 UI/UX Refinements
  • πŸ“ˆ Market Overview: Streamlined market data display with unified section
  • πŸ’Ό Portfolio Display: Improved value accuracy and presentation
  • πŸ’° Trading Interface: Enhanced buy/sell flow with clearer feedback
  • πŸ” Layout Optimization: Removed duplicate sections for cleaner interface
  • πŸ”Ž Enhanced Search: Improved search dropdown with better positioning
  • πŸš€ Top Gainers Section: Redesigned with fallback data for consistent display
🧩 Interactive Features
  • πŸ‘οΈ Interactive Login Character: Animated character that watches users type and politely closes its eyes during password entry
  • πŸ“± Responsive Layout: Trading panel moved next to chart for better usability
  • ⚑ Real-time Updates: Live stock price updates when selecting stocks
  • πŸ’¬ Discussion Forum: Enhanced community interaction features

🧠 Smart Trading Features

Smart Trading Features

The platform includes intelligent trading capabilities powered by statistical analysis:

Feature Description
πŸ“ˆ Price Forecasting Advanced statistical analysis for stock price prediction
πŸ” Buy/Sell Recommendations Data-driven suggestions based on historical performance
πŸ“Š Trend Analysis Identification of potential market trends and patterns
πŸ”„ Fallback Mechanisms Ensures predictions are available even with limited API data
βš–οΈ Risk Assessment Evaluation of potential investment risks

πŸ’Ό Portfolio Management

Comprehensive tools to track and manage your investments:

  • πŸ“Š Real-time Portfolio Valuation: Up-to-date value of your holdings
  • πŸ’° Transaction History: Complete record of all your trades
  • πŸ“ˆ Performance Metrics: Track your investment performance over time
  • πŸ”„ Automatic Updates: Portfolio values refresh automatically

🎭 User Experience Features

πŸ‘οΈ Interactive Login Character

The login page features an engaging animated character that creates a more personalized experience:

  • Reactive Eye Movements: Eyes follow along as users type in username fields
  • Privacy-Conscious Design: Eyes automatically close during password entry
  • Subtle Animations: Natural-looking movements that respond to user input

πŸ’° Crypto Widget Integration

  • Real-time cryptocurrency prices displayed alongside the login form
  • Track market movements even before logging in
  • Seamlessly integrated with the authentication flow

🀝 Contributing

  1. Fork the repository
  2. Create a new branch for your feature
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

πŸ“œ License

This project is licensed under the MIT License

Releases

No releases published

Packages

 
 
 

Contributors