Skip to content

Krish-afk-bot/market-intel-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Market Narrative Intelligence (MNI)

AI-powered market research that runs in minutes, not days

Multi-agent system that collects live data, analyzes markets in parallel, and self-refines reports before delivery


Status Python LLM UI License

Quick Start β€’ Features β€’ Architecture β€’ Roadmap


Mission

Make professional-grade market intelligence accessible to everyone β€” founders, analysts, students, and researchers β€” without expensive subscriptions or manual data collection. MNI uses coordinated AI agents and real-time public data to generate structured reports grounded in actual sources, not hallucinations.


The Challenge

Traditional market research is:

  • Slow: Analysts spend 4-8 hours manually collecting data from news sites, job boards, Wikipedia, and forums
  • Fragmented: Information scattered across dozens of sources with no unified view
  • Expensive: Professional reports cost $500-$5,000 per market
  • Stale: By the time a report is finished, parts are already outdated

Existing AI tools either:

  • Summarize a single source (limited scope)
  • Generate confident-sounding text with no real data backing (hallucinations)
  • Require manual prompt engineering for each section (not automated)

Our Solution

MNI runs an 8-stage autonomous pipeline with specialized AI agents:

  1. Research Agent β€” Fetches live data from DuckDuckGo, Wikipedia, and HackerNews (no LLM calls)
  2. Market + Capability Agents β€” Run in parallel via ThreadPoolExecutor to analyze market dynamics and required skills
  3. Strategy Agent β€” Synthesizes entry paths, opportunities, and risks
  4. Critic Agent β€” Reviews all sections for weak claims and contradictions, provides structured feedback
  5. Refinement Loop β€” Automatically reruns flagged sections with critic's improvement instructions
  6. Visualization Agent β€” Extracts chart-ready JSON for 7 interactive Plotly visualizations
  7. TL;DR Agent β€” Generates executive summary card with key metrics and verdict

Every section is grounded in data collected at runtime. No hardcoded content. No simulated results.


Key Features

Feature Description
7 Specialized Agents Each agent has one job: research, market analysis, capability mapping, strategy, critique, refinement, visualization, or executive summary
Parallel Execution Market and Capability agents run concurrently, cutting pipeline time by ~40%
Self-Refinement Loop Critic agent scores each section (1-10); sections scoring <7 are automatically rewritten with specific improvement instructions
TL;DR Summary Card Executive brief with market size, growth rate, entry difficulty, time-to-revenue, best opportunity, biggest risk, and verdict
Market Disambiguation Vague inputs like "trading" or "AI" are automatically clarified before search to avoid irrelevant results
SHA-256 LLM Cache Identical prompts served from memory β€” no duplicate API calls within a session
7 Interactive Charts Market metrics, trend momentum, skills radar, risk matrix, quality gauges, learning timeline, key players
Intelligence War Room UI Dark obsidian theme with amber accents, real-time pipeline progress, inline charts in tabs
CLI Runner Headless mode for scripting, automation, or CI pipelines
Export Options Download full report as Markdown or research data separately
Timestamp Tracking Every report shows generation time, data freshness, sources fetched, and refinement count
Inline Visualizations Charts embedded directly in relevant tabs (trends in Market, skills in Capabilities, risks in Strategy)

How It Works

Input: "Cybersecurity"
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 1 β€” Research Agent                               β”‚
β”‚  Fetches live data from DuckDuckGo, Wikipedia,          β”‚
β”‚  and HackerNews. No LLM calls β€” pure data collection.   β”‚
β”‚  Stores everything in shared AgentMemory.               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β–Ό                               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 2a       β”‚             β”‚  Stage 2b            β”‚
β”‚  Market Agent   β”‚  PARALLEL   β”‚  Capability Agent    β”‚
β”‚  Market size,   │◄──────────►│  Skills, tools,      β”‚
β”‚  players,       β”‚             β”‚  salaries, hiring    β”‚
β”‚  funding,       β”‚             β”‚  trends, learning    β”‚
β”‚  disruption     β”‚             β”‚  roadmap             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 3 β€” Strategy Agent                               β”‚
β”‚  Synthesizes market-entry plan from both analyses.      β”‚
β”‚  Identifies entry paths, risks, and unfair advantages.  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 4 β€” Critic Agent (Backend Only)                  β”‚
β”‚  Reviews all sections for contradictions and weak       β”‚
β”‚  claims. Returns structured JSON feedback with scores.  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 5 β€” Refinement Loop                              β”‚
β”‚  Automatically reruns agents for sections scoring <7.   β”‚
β”‚  Injects critic's improvement instructions into prompt. β”‚
β”‚  User never sees critic feedback β€” only improved output.β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 6 β€” Visualization Agent                          β”‚
β”‚  Makes one LLM call to extract chart-ready JSON         β”‚
β”‚  from the full report for all 7 Plotly charts.          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Stage 7 β€” TL;DR Agent                                  β”‚
β”‚  Generates executive summary card with key metrics,     β”‚
β”‚  verdict, sentiment, and top 3 companies.               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β–Ό
              Output: Structured Report
              + TL;DR Summary Card
              + 7 Interactive Charts
              + Markdown Export

System Architecture

market-narrative-intelligence/
β”‚
β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ base_agent.py          # Abstract base: cache-aware LLM call + memory helpers
β”‚   β”œβ”€β”€ research_agent.py      # Stage 1: live data collection (no LLM)
β”‚   β”œβ”€β”€ market_agent.py        # Stage 2a: market size, players, funding, disruption
β”‚   β”œβ”€β”€ capability_agent.py    # Stage 2b: skills, tools, salaries, hiring trends
β”‚   β”œβ”€β”€ strategy_agent.py      # Stage 3: market-entry strategy synthesis
β”‚   β”œβ”€β”€ critic_agent.py        # Stage 4: quality review with structured JSON feedback
β”‚   β”œβ”€β”€ visualization_agent.py # Stage 6: chart-ready JSON extraction
β”‚   └── tldr_agent.py          # Stage 7: executive summary card generation
β”‚
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ streamlit_app.py       # Intelligence War Room UI (dark theme, inline charts)
β”‚   └── charts.py              # 7 Plotly chart functions + render_all_charts()
β”‚
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ orchestrator.py        # 8-stage pipeline coordinator (ThreadPoolExecutor)
β”‚   β”œβ”€β”€ cache.py               # SHA-256 in-memory LLM response cache
β”‚   └── memory.py              # Shared key-value store for inter-agent communication
β”‚
β”œβ”€β”€ llm/
β”‚   └── groq_client.py         # Groq API wrapper (call tracking + token counting)
β”‚
β”œβ”€β”€ mcp/
β”‚   └── tools.py               # Tool dispatcher: DuckDuckGo, Wikipedia, HackerNews
β”‚
β”œβ”€β”€ .env.example               # Environment variable template
β”œβ”€β”€ requirements.txt           # Python dependencies
└── run_analysis.py            # CLI runner (argparse, markdown/json output)

Key Design Decisions:

  • Agent Isolation: Agents communicate exclusively through AgentMemory β€” no direct agent-to-agent calls
  • Cache Strategy: LLM responses cached via SHA-256 hash of prompt+system; tool calls never cached (always fresh data)
  • Parallel Stage 2: Market and Capability agents run concurrently via ThreadPoolExecutor to reduce total pipeline time
  • Backend-Only Critic: Critic feedback and refinement details never shown to user β€” only the improved final report
  • Single Orchestrator: Only Orchestrator knows the pipeline order; agents are stateless and reusable

User Journey

Step Action What Happens
1 Open dashboard Intelligence War Room UI loads at localhost:8501
2 Enter market name Type "Cybersecurity" or click suggested market button
3 Click INITIATE ANALYSIS 8-stage pipeline starts; real-time progress updates
4 View TL;DR card Executive summary with market size, growth, difficulty, verdict
5 Read sections Research, Market, Capabilities, Strategy tabs
6 Explore inline charts Trends in Market tab, skills radar in Capabilities, risk matrix in Strategy
7 View all charts Charts Overview tab shows all 7 visualizations together
8 Check full report Full Report tab shows complete Markdown document
9 Export Download as .md with one click

Technology Stack

AI & LLM

Component Technology Notes
LLM Provider Groq Free tier: 14,400 requests/day
Model llama-3.1-8b-instant Fast inference, high rate limits
Temperature 0.3 Low for factual, consistent output
Max Tokens 2048 per call Per agent call

Data Sources (all free, no API keys required)

Source Used For API
DuckDuckGo Search Market size, news, skills, tools, salaries, hiring data duckduckgo-search library
Wikipedia Background context and industry overviews wikipedia library
HackerNews Developer sentiment and trending discussions Algolia public API

Application Stack

Layer Technology Purpose
Web UI Streamlit 1.35+ Intelligence War Room dashboard
Charts Plotly 5.18+ 7 interactive visualizations
Concurrency Python ThreadPoolExecutor Parallel Stage 2 execution
Caching SHA-256 in-memory Custom SimpleCache for LLM responses
HTTP requests library API calls to HackerNews
Environment python-dotenv .env file management

Quick Start

Requirements: Python 3.10+, a free Groq API key

1. Clone the repository

git clone https://github.com/your-username/market-narrative-intelligence.git
cd market-narrative-intelligence

2. Install dependencies

pip install -r requirements.txt

3. Configure your API key

cp .env.example .env

Open .env and set your key:

GROQ_API_KEY=your_groq_api_key_here

4. Run the web dashboard

python -m streamlit run app/streamlit_app.py

Open http://localhost:8501 in your browser.

5. Or use the CLI

# Output to terminal (Markdown)
python run_analysis.py "Cybersecurity"

# Save as Markdown file
python run_analysis.py "FinTech" --output report.md

# Save as JSON
python run_analysis.py "AI SaaS" --format json --output report.json

🎨 UI Features

Intelligence War Room Theme

  • Obsidian black background (#0c0c0c) with dot-grid texture
  • Amber/gold accents (#f59e0b) for highlights and borders
  • Typography: Courier Prime (headings), IBM Plex Sans (body), IBM Plex Mono (metrics)
  • Custom metric cards with amber top borders (no default Streamlit metrics)
  • Animated pipeline progress with stage numbers [00] through [07]

TL;DR Summary Card

Appears immediately after metrics row, before tabs:

  • Market size and growth rate
  • Entry difficulty with explanation
  • Time to revenue estimate
  • Best opportunity and biggest risk
  • Opinionated verdict
  • Sentiment badge (BULLISH/NEUTRAL/BEARISH)
  • Top 3 key players

Inline Charts

Charts embedded directly in relevant tabs:

  • Market Analysis tab: Trend momentum chart
  • Capabilities tab: Skills radar + learning timeline (2 columns)
  • Strategy tab: Risk matrix + company relevance (2 columns)
  • Charts Overview tab: All 7 charts in one view

Error Handling

8 error types with clear explanations and actionable guidance:

  • API key required/invalid
  • Rate limit reached
  • Network error
  • Empty/too short market name
  • Analysis failed

Contributing

Contributions are welcome! A few guidelines to keep the codebase clean:

Core Principles

  • One agent, one job: Each agent reads from and writes to AgentMemory. Agents must not call other agents directly.
  • No hardcoded data: All data must come from live tool calls in mcp/tools.py.
  • Keep the pipeline order: The 8-stage sequence in core/orchestrator.py is intentional β€” don't reorder stages without understanding memory dependencies.
  • Test with real markets: Before opening a PR, run the full pipeline against at least one market and verify output quality.

Development Workflow

# Fork β†’ branch β†’ commit β†’ PR
git checkout -b feature/your-feature-name
git commit -m "feat: describe your change"
# Open a pull request against main

Testing

# Run a full analysis to test changes
python run_analysis.py "test market" --output test_report.md

# Or use the dashboard
python -m streamlit run app/streamlit_app.py

Example Output

Input: "Cybersecurity"

TL;DR Card:

  • Market Size: $190B
  • Growth Rate: 12% CAGR
  • Entry Difficulty: HIGH (Requires deep technical expertise and security certifications)
  • Time to Revenue: 12-18 months
  • Best Opportunity: Cloud security for SMB segment
  • Biggest Risk: Regulatory compliance complexity
  • Verdict: Attractive for well-funded teams with domain expertise β€” avoid if bootstrapping
  • Sentiment: BULLISH
  • Key Players: CrowdStrike Β· Palo Alto Networks Β· Fortinet

Report Sections:

  1. Research Summary (data sources and counts)
  2. Market Analysis (size, players, funding, disruption)
  3. Capability Analysis (skills, tools, salaries, learning roadmap)
  4. Strategic Entry Plan (entry paths, opportunities, risks)

Charts:

  1. Market Metrics Overview (bar chart)
  2. Trend Momentum (horizontal bar)
  3. Skills Demand Radar (spider chart)
  4. Risk Assessment Matrix (scatter plot)
  5. Section Quality Scores (gauge charts)
  6. Learning Timeline (Gantt-style)
  7. Key Market Players (horizontal bar)

License

MIT License β€” free to use, modify, and distribute. See LICENSE for details.


Acknowledgments

Built with:


Built with πŸ€– AI agents Β· πŸ“Š Live data Β· πŸ”„ Self-refinement

No hallucinations. No hardcoded data. Just real intelligence.

About

Real-time multi-agent market intelligence platform. 6 specialized AI agents + self-refinement loop + live data from DuckDuckGo, Wikipedia & HackerNews. Built with Groq LLM and Streamlit.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages