How sreeragsreekanth/stockprice-predictor works
Project type and purpose
• This is a full-stack, local web application built with Flask (Python) that allows users to enter a stock symbol or company name, fetches historical price data in real-time from Yahoo Finance, runs an LSTM neural-network model to predict future prices, and then visualizes both historical and predicted data in the browser.
File structure
• Top level:
• app.py – Flask entry point defining routes, request handling, and template rendering.
• Procfile – deployment descriptor (e.g., for Heroku).
• requirements.txt – Python dependencies.
• ml/ directory: core ML logic split into:
• pipeline.py – orchestration of data loading, preprocessing, model inference.
• search_ticker.py – resolves company name → ticker symbol via yahooquery.
• utils.py – helper functions (data transforms, scaling, etc.).
• templates/: Jinja2 HTML templates (index.html, result.html).
• static/: static assets (CSS, JS, images if any).
README for additional insights
• Tech stack: Flask / Python backend, Pandas/NumPy/TensorFlow/Keras for ML, yfinance & yahooquery for data, Matplotlib for plotting.
• No persistent database—data fetch is real-time.
• User flow: submit query → backend fetch & preprocess → LSTM predict → plot graphs → render results.
a. Main components:
1. Client (Web Browser)
2. Flask Web Server (app.py)
3. ML Pipeline Module (ml/pipeline.py)
4. Ticker Resolution Service (ml/search_ticker.py)
5. External Data Source (Yahoo Finance API)
6. Visualization Engine (Matplotlib)
7. Templates & Static Assets
b. Relationships & interactions:
• Client → Flask Server: HTTP GET/POST requests.
• Flask app routes → calls search_ticker to map company name.
• Flask app → calls pipeline to fetch historical data (via yfinance), preprocess, load or run LSTM model, produce predictions.
• Pipeline → Visualization Engine to generate charts (PNG/SVG).
• Flask app → passes chart URLs/objects into Jinja2 templates → sends HTML response back to client.
• Pipeline may call utils for scaling and data transforms.
c. Architectural patterns & principles:
• MVC (Controller = app.py routes, Model = ML pipeline + data, View = HTML templates + plots).
• Separation of concerns: routing vs. ML logic vs. visualization vs. utilities.
• Modular design: distinct Python modules for search, pipeline, utils.
d. Key technologies & frameworks:
• Flask for HTTP serving and templating.
• yfinance & yahooquery for data ingestion.
• Pandas/NumPy for data manipulation.
• TensorFlow/Keras for LSTM model inference.
• Matplotlib for chart generation.
• Jinja2 templates for rendering.