# akhiil-626/investiq architecture

> Architecture diagram of the GitHub repository akhiil-626/investiq, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akhiil-626/investiq
- Repository: https://github.com/akhiil-626/investiq

## Overview

InvestIQ is an educational Flask app that compares Reddit sentiment with recent stock-price movement. A user submits a ticker; the route fetches price data, selects real Reddit sentiment or deterministic mock scores, normalizes both measures, classifies their divergence, and renders a results page with an educational explanation. Price retrieval, sentiment collection, scoring, and summarization are distinct runtime stages. The README also describes optional Reddit credentials and Grok summaries. The graph follows the sampled route and module calls; unsampled template behavior is not inferred.

Main entry points: [`app.py`](https://github.com/akhiil-626/investiq/blob/main/app.py) (Flask routes), [`data/price_fetcher.py`](https://github.com/akhiil-626/investiq/blob/main/data/price_fetcher.py) (Price retrieval), [`data/reddit_sentiment.py`](https://github.com/akhiil-626/investiq/blob/main/data/reddit_sentiment.py) (Reddit sentiment), [`data/ai_summary.py`](https://github.com/akhiil-626/investiq/blob/main/data/ai_summary.py) (Educational summary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_web_app["Flask routes<br/>[app.py]"]
  node_ticker_form["Ticker form<br/>[index.html]"]
  node_results_view["Results view<br/>[results.html]"]
end

subgraph group_analysis["Divergence analysis"]
  node_scoring["Scoring engine<br/>[scoring_engine.py]"]
end

subgraph group_data["Data and explanation"]
  node_price_fetcher["Price retrieval<br/>[price_fetcher.py]"]
  node_reddit_sentiment["Reddit sentiment"]
  node_mock_sentiment["Mock sentiment"]
  node_summary["Educational summary<br/>[ai_summary.py]"]
end

node_user(("User"))
node_yahoo["Yahoo Finance"]
node_reddit["Reddit"]
node_grok["Grok API"]

node_user -->|"submits ticker"| node_web_app
node_web_app -->|"renders"| node_ticker_form
node_web_app -->|"fetches prices"| node_price_fetcher
node_price_fetcher -->|"requests history"| node_yahoo
node_web_app -->|"tries collection"| node_reddit_sentiment
node_reddit_sentiment -->|"searches posts"| node_reddit
node_web_app -->|"uses on fallback"| node_mock_sentiment
node_web_app -->|"normalizes and compares"| node_scoring
node_web_app -->|"requests explanation"| node_summary
node_summary -.->|"requests summary"| node_grok
node_web_app -->|"renders results"| node_results_view

click node_web_app "https://github.com/akhiil-626/investiq/blob/main/app.py"
click node_ticker_form "https://github.com/akhiil-626/investiq/blob/main/templates/index.html"
click node_results_view "https://github.com/akhiil-626/investiq/blob/main/templates/results.html"
click node_price_fetcher "https://github.com/akhiil-626/investiq/blob/main/data/price_fetcher.py"
click node_reddit_sentiment "https://github.com/akhiil-626/investiq/blob/main/data/reddit_sentiment.py"
click node_mock_sentiment "https://github.com/akhiil-626/investiq/blob/main/data/reddit_sentiment.py"
click node_scoring "https://github.com/akhiil-626/investiq/blob/main/scoring_engine.py"
click node_summary "https://github.com/akhiil-626/investiq/blob/main/data/ai_summary.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_app,node_ticker_form,node_results_view,node_user toneBlue
class node_scoring toneAmber
class node_price_fetcher,node_reddit_sentiment,node_mock_sentiment,node_summary,node_grok toneMint
class node_yahoo,node_reddit toneIndigo
```

## Components

### Web experience

- [Flask routes](https://github.com/akhiil-626/investiq/blob/main/app.py): `app.py`
- [Ticker form](https://github.com/akhiil-626/investiq/blob/main/templates/index.html): `templates/index.html`
- [Results view](https://github.com/akhiil-626/investiq/blob/main/templates/results.html): `templates/results.html`

### Divergence analysis

- [Scoring engine](https://github.com/akhiil-626/investiq/blob/main/scoring_engine.py): `scoring_engine.py`

### Data and explanation

- [Price retrieval](https://github.com/akhiil-626/investiq/blob/main/data/price_fetcher.py): `data/price_fetcher.py`
- [Reddit sentiment](https://github.com/akhiil-626/investiq/blob/main/data/reddit_sentiment.py): `data/reddit_sentiment.py`
- [Mock sentiment](https://github.com/akhiil-626/investiq/blob/main/data/reddit_sentiment.py): `data/reddit_sentiment.py`
- [Educational summary](https://github.com/akhiil-626/investiq/blob/main/data/ai_summary.py): `data/ai_summary.py`

### Other components

- **User**
- **Yahoo Finance**
- **Reddit**
- **Grok API**

## Connections

- User → Flask routes: submits ticker (evidence: `app.py`)
- Flask routes → Ticker form: renders (evidence: `app.py`)
- Flask routes → Price retrieval: fetches prices (evidence: `app.py`)
- Price retrieval → Yahoo Finance: requests history (evidence: `data/price_fetcher.py`)
- Flask routes → Reddit sentiment: tries collection (evidence: `app.py`)
- Reddit sentiment → Reddit: searches posts (evidence: `data/reddit_sentiment.py`)
- Flask routes → Mock sentiment: uses on fallback (evidence: `app.py`)
- Flask routes → Scoring engine: normalizes and compares (evidence: `app.py`)
- Flask routes → Educational summary: requests explanation (evidence: `app.py`)
- Educational summary → Grok API: requests summary (evidence: `data/ai_summary.py`)
- Flask routes → Results view: renders results (evidence: `app.py`)
