# typesparky/prediction-market-intelligence architecture

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

- Interactive diagram: https://gitdiagram.com/typesparky/prediction-market-intelligence
- Repository: https://github.com/typesparky/prediction-market-intelligence

## Overview

This repository is a Polymarket signal-intelligence product whose documented workflow runs from trend detection and market discovery through filtering, polarity/volume analysis, analyst briefing, and sector analysis. Persistent signal, episode, and entity memories support cross-run queries and reflection; an API and dashboard expose pipeline status. The graph preserves these major branches. Several implementation files are unsampled, so their connections are shown only where documented in the README or supported by indexed source references.

Main entry points: [`packages/trend_detector/trend_detector.py`](https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/trend_detector/trend_detector.py) (Trend Detection), [`src/core/query_router.py`](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/query_router.py) (Memory Query Router), [`src/pipeline/orchestrator.py`](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/orchestrator.py) (Signal Orchestration), [`src/analytics/market_processor_production.py`](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/analytics/market_processor_production.py) (Market Filtering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data and Trends"]
  node_trend["Trend Detection<br/>[trend_detector.py]"]
  node_trend_ledger[("Momentum Ledger<br/>[ledger.py]")]
  node_market_fetch["Market Discovery<br/>[unified_fetcher.py]"]
end

subgraph group_signal["Signal Pipeline"]
  node_signal_orchestrator["Signal Orchestration<br/>[orchestrator.py]"]
  node_market_processor["Market Filtering"]
  node_market_cleaner["Market Cleaning<br/>[market_cleaner.py]"]
  node_polarity["Polarity Labeling"]
  node_signal_object["Signal Output<br/>[signal.py]"]
end

subgraph group_insight["Analysis and Briefing"]
  node_analyst["Analyst Deliberation<br/>[analyst_report.py]"]
  node_search_enrichment["Web Search Enrichment<br/>[analyst_report.py]"]
  node_cio_briefing["CIO Briefing<br/>[analyst_report.py]"]
  node_sector_analysis["Sector Analysis"]
end

subgraph group_memory["Memory and Reflection"]
  node_signal_memory[("Signal Memory<br/>[signal_memory.py]")]
  node_episodic_memory[("Episodic Memory<br/>[episodic_memory.py]")]
  node_entity_graph[("Entity Hypergraph")]
  node_query_router["Memory Query Router<br/>[query_router.py]"]
  node_reflection["Weekly Reflection"]
end

subgraph group_serving["Status and Dashboard"]
  node_status_api["Status API<br/>[api_server.py]"]
  node_dashboard["Dashboard"]
end

node_cio(("CIO / User"))
node_polymarket{{"Polymarket APIs"}}
node_rss{{"RSS Feeds"}}
node_hyperliquid{{"Hyperliquid"}}
node_brave{{"Brave Search"}}

node_polymarket -->|"provides market data"| node_trend
node_rss -->|"provides feed data"| node_trend
node_hyperliquid -->|"provides market data"| node_trend
node_trend -->|"scores and records"| node_trend_ledger
node_trend -->|"precedes discovery"| node_market_fetch
node_market_fetch -.->|"fetches markets"| node_polymarket
node_signal_orchestrator -->|"filters markets"| node_market_processor
node_market_processor -->|"cleans markets"| node_market_cleaner
node_market_processor -->|"labels markets"| node_polarity
node_signal_orchestrator -->|"produces signal"| node_signal_object
node_signal_orchestrator -->|"discovers markets"| node_market_fetch
node_trend -->|"starts signal stages"| node_signal_orchestrator
node_signal_object -->|"informs briefing"| node_analyst
node_brave -->|"returns search results"| node_search_enrichment
node_analyst -->|"requests research"| node_search_enrichment
node_search_enrichment -->|"enriches synthesis"| node_cio_briefing
node_analyst -->|"contributes assessments"| node_cio_briefing
node_signal_object -->|"cross-correlates signals"| node_sector_analysis
node_rss -->|"supplies news"| node_sector_analysis
node_cio -->|"submits queries"| node_query_router
node_query_router -->|"routes quantitative queries"| node_signal_memory
node_query_router -->|"routes history queries"| node_episodic_memory
node_query_router -->|"routes discovery queries"| node_entity_graph
node_signal_memory -->|"loads scored markets"| node_trend_ledger
node_reflection -.->|"reviews pipeline runs"| node_episodic_memory
node_status_api -->|"serves pipeline status"| node_dashboard
node_cio -->|"checks run status"| node_status_api

click node_trend "https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/trend_detector/trend_detector.py"
click node_trend_ledger "https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/trend_detector/ledger.py"
click node_market_fetch "https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/polymarket_fetcher/unified_fetcher.py"
click node_signal_orchestrator "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/orchestrator.py"
click node_market_processor "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/analytics/market_processor_production.py"
click node_market_cleaner "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/analytics/market_cleaner.py"
click node_polarity "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/llm/openrouter_labeler.py"
click node_signal_object "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/signal.py"
click node_analyst "https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py"
click node_search_enrichment "https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py"
click node_cio_briefing "https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py"
click node_sector_analysis "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/sector_trends_engine.py"
click node_signal_memory "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/signal_memory.py"
click node_episodic_memory "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/episodic_memory.py"
click node_entity_graph "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/entity_hypergraph.py"
click node_query_router "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/query_router.py"
click node_reflection "https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/weekly_reflection.py"
click node_status_api "https://github.com/typesparky/prediction-market-intelligence/blob/dev/scripts/api_server.py"
click node_dashboard "https://github.com/typesparky/prediction-market-intelligence/blob/dev/scripts/dashboard/generate_dashboard.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_trend,node_trend_ledger,node_market_fetch,node_cio toneBlue
class node_signal_orchestrator,node_market_processor,node_market_cleaner,node_polarity,node_signal_object toneAmber
class node_analyst,node_search_enrichment,node_cio_briefing,node_sector_analysis,node_polymarket toneMint
class node_signal_memory,node_episodic_memory,node_entity_graph,node_query_router,node_reflection toneRose
class node_status_api,node_dashboard,node_rss,node_hyperliquid,node_brave toneIndigo
```

## Components

### Data and Trends

- [Trend Detection](https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/trend_detector/trend_detector.py): `packages/trend_detector/trend_detector.py`
- [Momentum Ledger](https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/trend_detector/ledger.py): `packages/trend_detector/ledger.py`
- [Market Discovery](https://github.com/typesparky/prediction-market-intelligence/blob/dev/packages/polymarket_fetcher/unified_fetcher.py): `packages/polymarket_fetcher/unified_fetcher.py`

### Signal Pipeline

- [Signal Orchestration](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/orchestrator.py): `src/pipeline/orchestrator.py`
- [Market Filtering](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/analytics/market_processor_production.py): `src/analytics/market_processor_production.py`
- [Market Cleaning](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/analytics/market_cleaner.py): `src/analytics/market_cleaner.py`
- [Polarity Labeling](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/llm/openrouter_labeler.py): `src/llm/openrouter_labeler.py`
- [Signal Output](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/signal.py): `src/pipeline/signal.py`

### Analysis and Briefing

- [Analyst Deliberation](https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py): `analyst_report.py`
- [Web Search Enrichment](https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py): `analyst_report.py`
- [CIO Briefing](https://github.com/typesparky/prediction-market-intelligence/blob/dev/analyst_report.py): `analyst_report.py`
- [Sector Analysis](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/pipeline/sector_trends_engine.py): `src/pipeline/sector_trends_engine.py`

### Memory and Reflection

- [Signal Memory](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/signal_memory.py): `src/core/signal_memory.py`
- [Episodic Memory](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/episodic_memory.py): `src/core/episodic_memory.py`
- [Entity Hypergraph](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/entity_hypergraph.py): `src/core/entity_hypergraph.py`
- [Memory Query Router](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/query_router.py): `src/core/query_router.py`
- [Weekly Reflection](https://github.com/typesparky/prediction-market-intelligence/blob/dev/src/core/weekly_reflection.py): `src/core/weekly_reflection.py`

### Status and Dashboard

- [Status API](https://github.com/typesparky/prediction-market-intelligence/blob/dev/scripts/api_server.py): `scripts/api_server.py`
- [Dashboard](https://github.com/typesparky/prediction-market-intelligence/blob/dev/scripts/dashboard/generate_dashboard.py): `scripts/dashboard/generate_dashboard.py`

### Other components

- **CIO / User**
- **Polymarket APIs**
- **RSS Feeds**
- **Hyperliquid**
- **Brave Search**

## Connections

- Polymarket APIs → Trend Detection: provides market data (evidence: `README.md`)
- RSS Feeds → Trend Detection: provides feed data (evidence: `README.md`)
- Hyperliquid → Trend Detection: provides market data (evidence: `README.md`)
- Trend Detection → Momentum Ledger: scores and records (evidence: `README.md`)
- Trend Detection → Market Discovery: precedes discovery (evidence: `README.md`)
- Market Discovery → Polymarket APIs: fetches markets
- Signal Orchestration → Market Filtering: filters markets (evidence: `src/pipeline/orchestrator.py`)
- Market Filtering → Market Cleaning: cleans markets (evidence: `src/analytics/market_processor_production.py`)
- Market Filtering → Polarity Labeling: labels markets (evidence: `src/analytics/market_processor_production.py`)
- Signal Orchestration → Signal Output: produces signal (evidence: `README.md`)
- Signal Orchestration → Market Discovery: discovers markets (evidence: `README.md`)
- Trend Detection → Signal Orchestration: starts signal stages (evidence: `README.md`)
- Signal Output → Analyst Deliberation: informs briefing (evidence: `README.md`)
- Brave Search → Web Search Enrichment: returns search results (evidence: `README.md`)
- Analyst Deliberation → Web Search Enrichment: requests research (evidence: `README.md`)
- Web Search Enrichment → CIO Briefing: enriches synthesis (evidence: `README.md`)
- Analyst Deliberation → CIO Briefing: contributes assessments (evidence: `README.md`)
- Signal Output → Sector Analysis: cross-correlates signals
- RSS Feeds → Sector Analysis: supplies news (evidence: `src/pipeline/sector_trends_engine.py`)
- CIO / User → Memory Query Router: submits queries (evidence: `README.md`)
- Memory Query Router → Signal Memory: routes quantitative queries (evidence: `src/core/query_router.py`)
- Memory Query Router → Episodic Memory: routes history queries (evidence: `src/core/query_router.py`)
- Memory Query Router → Entity Hypergraph: routes discovery queries (evidence: `src/core/query_router.py`)
- Signal Memory → Momentum Ledger: loads scored markets (evidence: `README.md`)
- Weekly Reflection → Episodic Memory: reviews pipeline runs
- Status API → Dashboard: serves pipeline status (evidence: `README.md`)
- CIO / User → Status API: checks run status (evidence: `README.md`)
