# nicolewiktor/competitive_intelligence_database architecture

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

- Interactive diagram: https://gitdiagram.com/nicolewiktor/competitive_intelligence_database
- Repository: https://github.com/nicolewiktor/competitive_intelligence_database

## Overview

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: [`src/agents/agentic_agent.py`](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py) (Tool Calls), [`src/pipeline/graph_builder.py`](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/graph_builder.py) (Graph Store), [`streamlit_app.py`](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/streamlit_app.py) (Dashboard), [`verify_evidence.py`](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/verify_evidence.py) (Evidence Review)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_orchestration["Orchestration"]
  node_node_main["CLI Runner<br/>entrypoint<br/>[main.py]"]
  node_node_streamlit["Dashboard<br/>entrypoint<br/>[streamlit_app.py]"]
end

subgraph group_group_agent["Agent Runtime"]
  node_node_agentic{{"Agent Loop<br/>langgraph<br/>[agentic_agent.py]"}}
  node_node_tools["Tool Calls<br/>tool-router<br/>[agentic_agent.py]"]
  node_node_llm(("LLM Reasoner<br/>model<br/>[agentic_agent.py]"))
  node_node_web["Web Search<br/>research-tool<br/>[agentic_agent.py]"]
  node_node_extract["Page Extract<br/>research-tool<br/>[agentic_agent.py]"]
  node_node_persist["Entity Write<br/>write-tool<br/>[agentic_agent.py]"]
end

subgraph group_group_persistence["Persistence"]
  node_node_chroma[("Evidence Store<br/>vector-store<br/>[chroma_store.py]")]
  node_node_neo4j[("Graph Store<br/>graph-db<br/>[graph_builder.py]")]
  node_node_pipeline["Graph Builder<br/>ingest-pipeline<br/>[graph_builder.py]"]
end

subgraph group_group_domain["Domain Model"]
  node_node_specs["Specs Model<br/>ontology<br/>[specifications.py]"]
  node_node_discovery["Discovery Phase<br/>pipeline-stage"]
  node_node_segments["Segment Research<br/>pipeline-stage"]
  node_node_needs["Needs Research<br/>pipeline-stage"]
  node_node_qfd["QFD Matrix<br/>analysis-output"]
end

subgraph group_group_ui["Operator UI"]
  node_node_verify["Evidence Review<br/>verification<br/>[verify_evidence.py]"]
  node_node_metrics["Metrics View<br/>dashboard-panel<br/>[streamlit_app.py]"]
end

subgraph group_group_assets["UI Assets"]
  node_node_vis["Graph UI<br/>visualization<br/>[vis-network.css]"]
  node_node_select["Select UI<br/>ui-library<br/>[tom-select.css]"]
end

node_node_main -->|"starts"| node_node_agentic
node_node_streamlit -->|"opens"| node_node_verify
node_node_streamlit -->|"shows"| node_node_metrics
node_node_agentic -->|"routes to"| node_node_llm
node_node_agentic -->|"routes to"| node_node_tools
node_node_llm -->|"issues calls"| node_node_tools
node_node_tools -->|"includes"| node_node_web
node_node_tools -->|"includes"| node_node_extract
node_node_tools -->|"includes"| node_node_persist
node_node_tools -->|"stores evidence"| node_node_chroma
node_node_tools -->|"stores facts"| node_node_neo4j
node_node_persist -->|"feeds"| node_node_pipeline
node_node_pipeline -->|"normalizes with"| node_node_specs
node_node_pipeline -->|"writes"| node_node_neo4j
node_node_discovery -->|"grounds in"| node_node_chroma
node_node_segments -->|"updates"| node_node_neo4j
node_node_needs -->|"updates"| node_node_neo4j
node_node_qfd -->|"maps"| node_node_specs
node_node_verify -->|"reads evidence"| node_node_chroma
node_node_verify -->|"reads graph"| node_node_neo4j
node_node_streamlit -->|"uses"| node_node_vis
node_node_streamlit -->|"uses"| node_node_select

click node_node_main "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/main.py"
click node_node_streamlit "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/streamlit_app.py"
click node_node_agentic "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_tools "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_llm "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_web "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_extract "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_persist "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py"
click node_node_chroma "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/chroma_store.py"
click node_node_neo4j "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/graph_builder.py"
click node_node_pipeline "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/graph_builder.py"
click node_node_specs "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/ontology/specifications.py"
click node_node_qfd "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/house_of_quality.json"
click node_node_verify "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/verify_evidence.py"
click node_node_metrics "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/streamlit_app.py"
click node_node_vis "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/lib/vis-9.1.2/vis-network.css"
click node_node_select "https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/lib/tom-select/tom-select.css"

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_node_main,node_node_streamlit toneBlue
class node_node_agentic,node_node_tools,node_node_llm,node_node_web,node_node_extract,node_node_persist toneAmber
class node_node_chroma,node_node_neo4j,node_node_pipeline toneMint
class node_node_specs,node_node_discovery,node_node_segments,node_node_needs,node_node_qfd toneRose
class node_node_verify,node_node_metrics toneIndigo
class node_node_vis,node_node_select toneTeal
```

## Components

### Orchestration

CLI and dashboard entry points that start the research loop.

- [CLI Runner](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/main.py): entrypoint · Runs the research pipeline from the command line. · `main.py`
- [Dashboard](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/streamlit_app.py): entrypoint · Human-facing Streamlit console for exploring and managing results. · `streamlit_app.py`

### Agent Runtime

LangGraph loop and tool-driven research execution.

- [Agent Loop](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): langgraph · State machine that alternates between LLM reasoning and tool execution. · `src/agents/agentic_agent.py`
- [Tool Calls](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): tool-router · Executes web search, extraction, writes, research steps, progress checks, and finish signals. · `src/agents/agentic_agent.py`
- [LLM Reasoner](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): model · Chooses the next action and decides when the investigation is complete. · `src/agents/agentic_agent.py`
- [Web Search](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): research-tool · Finds external sources for competitive intelligence gathering. · `src/agents/agentic_agent.py`
- [Page Extract](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): research-tool · Pulls usable evidence text from source pages. · `src/agents/agentic_agent.py`
- [Entity Write](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/agents/agentic_agent.py): write-tool · Writes researched entities and relations into the structured store. · `src/agents/agentic_agent.py`

### Persistence

Evidence retrieval store and structured graph database.

- [Evidence Store](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/chroma_store.py): vector-store · Stores raw evidence chunks for retrieval and verification. · `src/pipeline/chroma_store.py`
- [Graph Store](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/graph_builder.py): graph-db · Persists normalized facts and relationships in Neo4j. · `src/pipeline/graph_builder.py`
- [Graph Builder](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/pipeline/graph_builder.py): ingest-pipeline · 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](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/src/ontology/specifications.py): ontology · Defines normalized product specifications and related concepts. · `src/ontology/specifications.py`
- **Discovery Phase**: pipeline-stage · Finds competitors and products to seed the investigation.
- **Segment Research**: pipeline-stage · Researches customer segments and maps products to segment needs.
- **Needs Research**: pipeline-stage · Collects customer needs and other demand signals.
- [QFD Matrix](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/house_of_quality.json): analysis-output · 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](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/verify_evidence.py): verification · Lets a human inspect graph facts alongside source evidence. · `verify_evidence.py`
- [Metrics View](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/streamlit_app.py): dashboard-panel · Shows evaluation and progress signals for the research output. · `streamlit_app.py`

### UI Assets

Frontend libraries used by the Streamlit interface.

- [Graph UI](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/lib/vis-9.1.2/vis-network.css): visualization · Interactive graph browsing and entity selection in the dashboard. · `lib/vis-9.1.2/vis-network.css`
- [Select UI](https://github.com/nicolewiktor/competitive_intelligence_database/blob/main/lib/tom-select/tom-select.css): ui-library · Dropdown and filtering controls used by the dashboard. · `lib/tom-select/tom-select.css`

## Connections

- 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.
