# savageking001/geopolitical-signal-engine architecture

> Architecture diagram of the GitHub repository savageking001/geopolitical-signal-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/savageking001/geopolitical-signal-engine
- Repository: https://github.com/savageking001/geopolitical-signal-engine

## Overview

Geopolitical Signal Engine turns event keywords into filtered and tagged news, company-level directional signals, a gold verdict, and a psychology summary. Its Flask form delegates analysis to the main entry point; the terminal entry point runs the same analysis. The repository also includes a separate company-news/chatbot and watchlist capability. Edges reflect shown calls or README-described stages; the chatbot’s web wiring and the separate Vaibhav dashboard are not established by the excerpts.

Main entry points: [`main.py`](https://github.com/savageking001/geopolitical-signal-engine/blob/main/main.py) (Analysis orchestrator), [`dashboard/chatbot.py`](https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/chatbot.py) (Company chatbot), [`sentiment_layer/reddit_scraper.py`](https://github.com/savageking001/geopolitical-signal-engine/blob/main/sentiment_layer/reddit_scraper.py) (Reddit collection), [`news_pipeline/fetcher.py`](https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/fetcher.py) (News fetcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_news["News analysis"]
  node_news_fetch["News fetcher<br/>[fetcher.py]"]
  node_news_filter["News filter<br/>[verifier.py]"]
  node_event_tagger["Event tagger<br/>[tagger.py]"]
end

subgraph group_mapping["Exposure mapping"]
  node_company_mapper["Company mapper<br/>[sector_mapper.py]"]
  node_company_data[("Company database<br/>[companies.json]")]
end

subgraph group_sentiment["Psychology signals"]
  node_reddit_fetch["Reddit collection<br/>[reddit_scraper.py]"]
  node_psychology["Psychology scoring"]
end

subgraph group_outputs["Signal outputs"]
  node_company_scorer["Company signals<br/>[scorer.py]"]
  node_gold_signal["Gold signal<br/>[gold_signal.py]"]
  node_analysis["Analysis orchestrator<br/>[main.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_flask_ui["Flask dashboard<br/>[app.py]"]
  node_chatbot["Company chatbot<br/>[chatbot.py]"]
  node_watchlist_data[("Watchlist file")]
  node_vaibhav_ui["Vaibhav dashboard<br/>[vaibhav.py]"]
end

node_user(("Researcher"))
node_news_api{{"NewsAPI"}}
node_reddit{{"Reddit"}}
node_google_news{{"Google News"}}

node_user -->|"submits query"| node_flask_ui
node_flask_ui -->|"requests analysis"| node_analysis
node_analysis -->|"fetches news"| node_news_fetch
node_news_fetch -->|"requests articles"| node_news_api
node_news_fetch -->|"filters articles"| node_news_filter
node_news_fetch -->|"tags articles"| node_event_tagger
node_analysis -->|"tags articles"| node_event_tagger
node_analysis -->|"generates signals"| node_company_scorer
node_analysis -->|"generates verdict"| node_gold_signal
node_analysis -->|"summarizes mood"| node_reddit_fetch
node_company_scorer -->|"gets affected firms"| node_company_mapper
node_company_mapper -->|"loads companies"| node_company_data
node_company_scorer -->|"gets psychology summary"| node_reddit_fetch
node_reddit_fetch -->|"fetches posts"| node_reddit
node_reddit_fetch -->|"scores text"| node_psychology
node_gold_signal -->|"gets psychology summary"| node_reddit_fetch
node_chatbot -->|"checks exposure"| node_company_mapper
node_chatbot -->|"analyzes news text"| node_psychology
node_chatbot -->|"fetches company news"| node_google_news
node_chatbot -->|"fetches company news"| node_news_api
node_chatbot -->|"reads and writes"| node_watchlist_data

click node_news_fetch "https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/fetcher.py"
click node_news_filter "https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/verifier.py"
click node_event_tagger "https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/tagger.py"
click node_company_mapper "https://github.com/savageking001/geopolitical-signal-engine/blob/main/company_database/sector_mapper.py"
click node_company_data "https://github.com/savageking001/geopolitical-signal-engine/blob/main/company_database/companies.json"
click node_reddit_fetch "https://github.com/savageking001/geopolitical-signal-engine/blob/main/sentiment_layer/reddit_scraper.py"
click node_psychology "https://github.com/savageking001/geopolitical-signal-engine/blob/main/sentiment_layer/psychology_signals.py"
click node_company_scorer "https://github.com/savageking001/geopolitical-signal-engine/blob/main/signal_engine/scorer.py"
click node_gold_signal "https://github.com/savageking001/geopolitical-signal-engine/blob/main/gold_module/gold_signal.py"
click node_analysis "https://github.com/savageking001/geopolitical-signal-engine/blob/main/main.py"
click node_flask_ui "https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/app.py"
click node_chatbot "https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/chatbot.py"
click node_watchlist_data "https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/vaibhav_watchlist.json"
click node_vaibhav_ui "https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/vaibhav.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_news_fetch,node_news_filter,node_event_tagger toneBlue
class node_company_mapper,node_company_data toneAmber
class node_reddit_fetch,node_psychology,node_news_api toneMint
class node_company_scorer,node_gold_signal,node_analysis toneRose
class node_flask_ui,node_chatbot,node_watchlist_data,node_vaibhav_ui,node_user,node_reddit,node_google_news toneIndigo
```

## Components

### News analysis

- [News fetcher](https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/fetcher.py): `news_pipeline/fetcher.py`
- [News filter](https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/verifier.py): `news_pipeline/verifier.py`
- [Event tagger](https://github.com/savageking001/geopolitical-signal-engine/blob/main/news_pipeline/tagger.py): `news_pipeline/tagger.py`

### Exposure mapping

- [Company mapper](https://github.com/savageking001/geopolitical-signal-engine/blob/main/company_database/sector_mapper.py): `company_database/sector_mapper.py`
- [Company database](https://github.com/savageking001/geopolitical-signal-engine/blob/main/company_database/companies.json): `company_database/companies.json`

### Psychology signals

- [Reddit collection](https://github.com/savageking001/geopolitical-signal-engine/blob/main/sentiment_layer/reddit_scraper.py): `sentiment_layer/reddit_scraper.py`
- [Psychology scoring](https://github.com/savageking001/geopolitical-signal-engine/blob/main/sentiment_layer/psychology_signals.py): `sentiment_layer/psychology_signals.py`

### Signal outputs

- [Company signals](https://github.com/savageking001/geopolitical-signal-engine/blob/main/signal_engine/scorer.py): `signal_engine/scorer.py`
- [Gold signal](https://github.com/savageking001/geopolitical-signal-engine/blob/main/gold_module/gold_signal.py): `gold_module/gold_signal.py`
- [Analysis orchestrator](https://github.com/savageking001/geopolitical-signal-engine/blob/main/main.py): `main.py`

### User interfaces

- [Flask dashboard](https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/app.py): `dashboard/app.py`
- [Company chatbot](https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/chatbot.py): `dashboard/chatbot.py`
- [Watchlist file](https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/vaibhav_watchlist.json): `dashboard/vaibhav_watchlist.json`
- [Vaibhav dashboard](https://github.com/savageking001/geopolitical-signal-engine/blob/main/dashboard/vaibhav.py): `dashboard/vaibhav.py`

### Other components

- **Researcher**
- **NewsAPI**
- **Reddit**
- **Google News**

## Connections

- Researcher → Flask dashboard: submits query (evidence: `dashboard/app.py`)
- Flask dashboard → Analysis orchestrator: requests analysis (evidence: `dashboard/app.py`)
- Analysis orchestrator → News fetcher: fetches news (evidence: `main.py`)
- News fetcher → NewsAPI: requests articles (evidence: `news_pipeline/fetcher.py`)
- News fetcher → News filter: filters articles (evidence: `news_pipeline/fetcher.py`)
- News fetcher → Event tagger: tags articles (evidence: `news_pipeline/fetcher.py`)
- Analysis orchestrator → Event tagger: tags articles (evidence: `main.py`)
- Analysis orchestrator → Company signals: generates signals (evidence: `main.py`)
- Analysis orchestrator → Gold signal: generates verdict (evidence: `main.py`)
- Analysis orchestrator → Reddit collection: summarizes mood (evidence: `main.py`)
- Company signals → Company mapper: gets affected firms (evidence: `signal_engine/scorer.py`)
- Company mapper → Company database: loads companies (evidence: `company_database/sector_mapper.py`)
- Company signals → Reddit collection: gets psychology summary (evidence: `signal_engine/scorer.py`)
- Reddit collection → Reddit: fetches posts (evidence: `sentiment_layer/reddit_scraper.py`)
- Reddit collection → Psychology scoring: scores text (evidence: `sentiment_layer/reddit_scraper.py`)
- Gold signal → Reddit collection: gets psychology summary (evidence: `gold_module/gold_signal.py`)
- Company chatbot → Company mapper: checks exposure (evidence: `dashboard/chatbot.py`)
- Company chatbot → Psychology scoring: analyzes news text (evidence: `dashboard/chatbot.py`)
- Company chatbot → Google News: fetches company news (evidence: `dashboard/chatbot.py`)
- Company chatbot → NewsAPI: fetches company news (evidence: `dashboard/chatbot.py`)
- Company chatbot → Watchlist file: reads and writes (evidence: `dashboard/chatbot.py`)
