How tiffintech/stock works
Project Type and Purpose
• This is a hybrid data-analysis tool with:
• A small web frontend (Flask + Jinja template)
• A core pipeline for fetching data, analyzing sentiment, and correlating with stock prices
• An optional CLI entry point (stock_sentiment.py) for running the pipeline directly
File Structure
Top-level:
• README.md, requirements.txt, .env (runtime config)
• stock_sentiment.py (CLI launcher)
• src/
– app.py (Flask server / controller)
– models/sentiment_analyzer.py (NLP model code)
– reddit_sentiment.py (Reddit fetcher module)
– stock_data.py (Stock price fetcher module)
– visualization/plotter.py (Graph-generation module)
– templates/index.html (UI view)
Pull Insights from the README
• External dependencies: Reddit API, stock-price API
• Core features: data fetch → NLP sentiment analysis → correlation & trend prediction → output (plots/JSON)
Main Components & Their Relationships
A. Frontend (only if running as a web app)
• index.html
• Served by Flask via app.py
B. Backend / Controller
• src/app.py – defines HTTP routes, triggers pipeline
• stock_sentiment.py – alternative CLI “main”
C. Data-Fetch Modules
• src/reddit_sentiment.py → connects to Reddit API
• src/stock_data.py → fetches stock prices from external API
D. Processing / Business Logic
• src/models/sentiment_analyzer.py → sentiment scoring
• Correlator (inside stock_sentiment.py or app.py) → aligns sentiment vs. price
E. Visualization
• src/visualization/plotter.py → generates charts (matplotlib, plotly, etc.)
F. External Services
• Reddit API
• Stock-price API
Architectural Patterns & Design Principles
• MVC-style layering for the web path:
• View → templates/index.html
• Controller → src/app.py
• Model → src/models/… + data-fetch modules
• Modular pipeline: each step is a separate module
• Single responsibility: fetchers, analyzer, plotter all encapsulated
– Reddit Fetcher
– Stock-Data Fetcher
– Browser (renders image/data)
– CLI (prints summary / saves image)
Detail
• Your environment loader (.env) in a small note near the fetchers