Skip to content

Aayushman-Gupta/Multithreaded-Stock-Price-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Multithreaded Stock Price Simulator

C++ React WebSockets TailwindCSS

A high-performance, real-time stock price simulator using a multithreaded C++ backend and a modern React frontend.

The backend leverages a thread pool and a producer-consumer model to efficiently generate and broadcast live stock price updates. The frontend consumes this data over WebSockets and displays it in a beautiful, responsive dashboard with interactive charts.


πŸ“Š Demo Preview

This is the final user interface, featuring a "glassmorphism" design with live-updating charts.

Live Stock Dashboard Preview Live Stock Dashboard Preview


✨ Features

  • πŸš€ High-Performance C++ Backend
    • Thread Pool Architecture to efficiently manage hundreds of stock simulations.
    • Producer-Consumer Model for clean separation of data generation and broadcasting.
    • Thread-safe queue using mutexes & condition variables to guarantee data integrity.
  • 🎨 Modern Glassmorphism UI
    • Instant-loading dummy graphs that seamlessly transition to live data.
    • Beautifully styled charts from Recharts with live price-change indicators.
    • Fully responsive design built with React and Tailwind CSS.
  • ⚑ Real-Time Communication
    • Low-latency data streaming from backend to frontend using WebSockets.

πŸ› οΈ Tech Stack

Backend

  • C++17
  • Multithreading (std::thread, std::mutex, std::shared_mutex, std::condition_variable)
  • Thread Pool Design Pattern
  • WebSocket++ Library

Frontend

  • React + Vite
  • Tailwind CSS for styling
  • Recharts for interactive charts
  • WebSocket Client (useRef for stable connection)

πŸ—οΈ Architecture

        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚   Scheduling Thread    β”‚
        β”‚(Submits tasks per stock)β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚ Tasks
                    β–Ό
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚ Task Queueβ”‚<--β”‚   Thread Pool (Workers)β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚ (Run simulation tasks) β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚ StockEvents
                                  β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ Event Queue (Thread-Safe)β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    Consumer Threads    β”‚
                    β”‚ (Broadcasts via WebSocket)β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                      β”‚  React Frontend  β”‚
                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

About

πŸ“ˆ Multithreaded Stock Price Simulator built in C++ with Producer–Consumer concurrency, thread-safe queues, and a React frontend for real-time stock visualization.The frontend consumes this data over WebSockets and displays it with interactive charts.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors