How nicolewiktor/competitive_intelligence_database works
1. This is a Python-based agentic research system for competitive intelligence in the pressure transmitter market. The core runtime is a LangGraph loop that lets an LLM decide which research and persistence tools to call until it decides the investigation is complete.
2. The orchestration entry points are split between main.py for running the research pipeline from the CLI and streamlit_app.py for the human-facing dashboard. The same underlying stores are surfaced in both modes.
3. The agent layer lives in src/agents/agentic_agent.py. It defines the LangGraph state machine with an agent node and a tools node, plus the continuation logic that routes between them based on whether the LLM produced tool calls.
4. Tool execution is the main control boundary. The LLM can trigger web search, page extraction, entity writes, segment/need research, QFD generation, progress checks, and an explicit finish signal. This means the model is not just generating text; it is actively driving a research workflow.
5. There are two distinct persistence layers in src/pipeline: chroma_store.py handles raw evidence chunks for retrieval and verification, while graph_builder.py writes structured knowledge into Neo4j. This separation is central to the architecture: one store is for source grounding, the other for normalized facts and relationships.
6. The domain model is defined in src/ontology/specifications.py. It appears to normalize product specifications and related concepts so the graph can compare competitors consistently, rather than storing arbitrary scraped text as-is.
7. Configuration is centralized in src/config/settings.py, with environment variables for OpenAI, Tavily, and Neo4j in .env. That places the external dependencies clearly in the architecture: LLM reasoning, web search/extraction, and graph database persistence.
8. The data flow follows a research pipeline with four phases: competitor/product discovery, customer segment research, industry-needs research, and house-of-quality generation. Each phase produces structured graph updates and/or evidence chunks, so later phases can build on earlier graph state.
9. The graph model is explicitly competitive and product-centric: Honeywell competes with competitor companies, competitors offer products, products have specifications, and products can map to customer needs and customer segments. The QFD output connects needs to specs with relationship weights.
10. Verification is a first-class concern. verify_evidence.py and the Streamlit “Verify Data” flow let a human inspect Neo4j relationships alongside the original ChromaDB evidence text and source URL, providing an audit trail from structured fact back to source content.
11. The dashboard is not just visualization; it is an operator console over the research output. It exposes the graph, ontology/spec definitions, product comparisons, customer segments, customer needs, QFD matrix, and evaluation metrics in a way that matches the stored graph schema.
12. The lib/ assets, including vis-network and tom-select, support the dashboard’s graph visualization and selection UI. They are presentation dependencies, not core research logic, but they materially shape the Streamlit experience.
13. The small JSON files in the repo root look like saved artifacts or sample outputs from the research process. They likely reflect generated industry reports or segment/quality data that can be reused for inspection or demo purposes.
14. In architectural terms, the system is a closed research loop: LLM-driven tool calls collect evidence from the web, evidence is chunked into ChromaDB, normalized facts are written to Neo4j, and the UI reads both stores to support exploration and human verification.
Main entry points: agentic_agent.py Tool Calls · graph_builder.py Graph Store · streamlit_app.py Dashboard · verify_evidence.py Evidence Review
Components 20
Orchestration
CLI and dashboard entry points that start the research loop.
- CLI Runner · Runs the research pipeline from the command line.
main.py - Dashboard · Human-facing Streamlit console for exploring and managing results.
streamlit_app.py
Agent Runtime
LangGraph loop and tool-driven research execution.
- Agent Loop · State machine that alternates between LLM reasoning and tool execution.
src/agents/agentic_agent.py - Tool Calls · Executes web search, extraction, writes, research steps, progress checks, and finish signals.
src/agents/agentic_agent.py - LLM Reasoner · Chooses the next action and decides when the investigation is complete.
src/agents/agentic_agent.py - Web Search · Finds external sources for competitive intelligence gathering.
src/agents/agentic_agent.py - Page Extract · Pulls usable evidence text from source pages.
src/agents/agentic_agent.py - Entity Write · Writes researched entities and relations into the structured store.
src/agents/agentic_agent.py
Persistence
Evidence retrieval store and structured graph database.
- Evidence Store · Stores raw evidence chunks for retrieval and verification.
src/pipeline/chroma_store.py - Graph Store · Persists normalized facts and relationships in Neo4j.
src/pipeline/graph_builder.py - Graph Builder · Builds the structured knowledge graph from research outputs.
src/pipeline/graph_builder.py
Domain Model
Normalization layer for products, specs, needs, and QFD.
- Specs Model · Defines normalized product specifications and related concepts.
src/ontology/specifications.py - Discovery Phase · Finds competitors and products to seed the investigation.
- Segment Research · Researches customer segments and maps products to segment needs.
- Needs Research · Collects customer needs and other demand signals.
- QFD Matrix · Generates house-of-quality relationships between needs and specifications.
house_of_quality.json
Operator UI
Streamlit dashboard and verification workflow over stored research.
- Evidence Review · Lets a human inspect graph facts alongside source evidence.
verify_evidence.py - Metrics View · Shows evaluation and progress signals for the research output.
streamlit_app.py
Connections 22
- CLI Runner → Agent Loop: starts · CLI launches the research agent loop.
- Dashboard → Evidence Review: opens · Dashboard provides the verification workflow.
- Dashboard → Metrics View: shows · Dashboard surfaces graphs, comparisons, segments, needs, and metrics.
- Agent Loop → LLM Reasoner: routes to · State machine asks the LLM for the next step.
- Agent Loop → Tool Calls: routes to · Continuation logic sends tool calls to execution.
- LLM Reasoner → Tool Calls: issues calls · The model decides which research or persistence action to invoke.
- Tool Calls → Web Search: includes · Tooling performs external web search.
- Tool Calls → Page Extract: includes · Tooling extracts content from source pages.
- Tool Calls → Entity Write: includes · Tooling writes entities and relationships.
- Tool Calls → Evidence Store: stores evidence · Raw evidence chunks are saved for retrieval and verification.
- Tool Calls → Graph Store: stores facts · Structured knowledge is persisted to the graph database.
- Entity Write → Graph Builder: feeds · Entity writes are normalized into graph updates.
- Graph Builder → Specs Model: normalizes with · Graph building uses the domain specification model.
- Graph Builder → Graph Store: writes · Structured facts and relationships land in Neo4j.
- Discovery Phase → Evidence Store: grounds in · Discovery collects and stores evidence.
- Segment Research → Graph Store: updates · Segment research enriches the structured graph.
- Needs Research → Graph Store: updates · Needs research enriches the structured graph.
- QFD Matrix → Specs Model: maps · QFD connects customer needs to product specifications.
- Evidence Review → Evidence Store: reads evidence · Verification shows source text from the evidence store.
- Evidence Review → Graph Store: reads graph · Verification inspects structured relationships in Neo4j.
- Dashboard → Graph UI: uses · Dashboard relies on network visualization assets.
- Dashboard → Select UI: uses · Dashboard relies on selection/filter UI assets.