# ugarth-p/hackathon_hackiwha architecture

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

- Interactive diagram: https://gitdiagram.com/ugarth-p/hackathon_hackiwha
- Repository: https://github.com/ugarth-p/hackathon_hackiwha

## Overview

Brand Market Tracker is a competitive-intelligence product: users manage brand projects, launch research, inspect agent findings as the pipeline runs, and review monitoring changes. The principal flow crosses the React client, NestJS research API, Python agent runner, and PostgreSQL; a separate monitoring flow compares completed runs. README documentation supports the client/API and worker handoffs, while source excerpts and the SOURCE INDEX support internal calls. Some frontend wiring and scheduler behavior are documented but not sampled, so those connections are cited to the README or left unasserted where evidence is insufficient.

Main entry points: [`workers/main.py`](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/main.py) (Worker dispatcher), [`frontend/src/services/api.ts`](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/services/api.ts) (HTTP and SSE client), [`workers/db.py`](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/db.py) (Worker data access), [`workers/scraping/agent.py`](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/scraping/agent.py) (Market intelligence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Brand workspace"]
  node_app["Client routes<br/>[App.tsx]"]
  node_projects["Projects workspace<br/>[ProjectsPage.tsx]"]
  node_projectdetail["Project details"]
  node_agentspage["Agent pipeline view<br/>[AgentsPage.tsx]"]
  node_pipelineview["Pipeline visualization<br/>[AgentPipeline.tsx]"]
  node_agentnode["Finding panels<br/>[AgentNode.tsx]"]
  node_clientapi["HTTP and SSE client<br/>[api.ts]"]
  node_pipelinehook["Pipeline state hook<br/>[usePipeline.ts]"]
  node_monitorhook["Monitoring hook<br/>[useMonitoring.ts]"]
end

subgraph group_api["Application API"]
  node_researchapi["Research endpoints"]
  node_researchsvc["Pipeline orchestration"]
  node_monitorapi["Monitoring endpoints"]
  node_monitorsvc["Monitoring orchestration"]
  node_scheduler["Scheduled runs"]
end

subgraph group_agents["Research workers"]
  node_runner["Worker dispatcher<br/>[main.py]"]
  node_scraping["Market intelligence<br/>[agent.py]"]
  node_analysis["Competitor reconnaissance<br/>[agent.py]"]
  node_strategy["Strategy generation<br/>[agent.py]"]
end

subgraph group_monitor["Change monitoring"]
  node_monitoragent["Run comparison<br/>[agent.py]"]
end

subgraph group_persistence["Data and integrations"]
  node_dbworker["Worker data access<br/>[db.py]"]
  node_embeddings["Embedding generation<br/>[embeddings.py]"]
  node_tools["Web search tools<br/>[tools.py]"]
  node_config["Worker configuration<br/>[config.py]"]
  node_prisma["Prisma service<br/>[prisma.service.ts]"]
  node_postgres[("PostgreSQL and pgvector")]
end

node_user(("Brand user"))
node_gemini{{"Gemini API"}}
node_tavily{{"Tavily search"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_projects
node_app -->|"routes to"| node_projectdetail
node_app -->|"routes to"| node_agentspage
node_agentspage -.->|"renders"| node_pipelineview
node_pipelineview -.->|"renders"| node_agentnode
node_projects -.->|"requests data"| node_clientapi
node_projectdetail -.->|"requests data"| node_clientapi
node_pipelinehook -.->|"requests and streams"| node_clientapi
node_monitorhook -.->|"requests monitoring"| node_clientapi
node_clientapi -->|"HTTP and SSE"| node_researchapi
node_researchapi -->|"delegates"| node_researchsvc
node_researchsvc -->|"reads and writes"| node_prisma
node_researchsvc -->|"spawns with JSON"| node_runner
node_runner -->|"dispatches"| node_scraping
node_runner -->|"dispatches"| node_analysis
node_runner -->|"dispatches"| node_strategy
node_scraping -->|"searches and fetches"| node_tools
node_analysis -->|"searches and fetches"| node_tools
node_scraping -.->|"synthesizes"| node_gemini
node_analysis -.->|"analyzes"| node_gemini
node_strategy -.->|"generates strategy"| node_gemini
node_tools -.->|"searches"| node_tavily
node_scraping -.->|"stores findings"| node_dbworker
node_analysis -->|"stores findings"| node_dbworker
node_strategy -.->|"stores findings"| node_dbworker
node_analysis -->|"embeds output"| node_embeddings
node_scraping -.->|"embeds findings"| node_embeddings
node_strategy -.->|"embeds output"| node_embeddings
node_dbworker -->|"queries"| node_postgres
node_prisma -.->|"persists records"| node_postgres
node_runner -->|"returns JSON"| node_researchsvc
node_researchsvc -->|"emits SSE"| node_clientapi
node_clientapi -->|"updates visualization"| node_pipelineview
node_monitorapi -->|"delegates"| node_monitorsvc
node_monitorsvc -->|"loads and saves runs"| node_prisma
node_monitorsvc -->|"spawns comparison"| node_runner
node_runner -->|"dispatches monitoring"| node_monitoragent
node_monitoragent -->|"loads and saves data"| node_dbworker
node_scheduler -->|"triggers monitoring"| node_monitorsvc
node_runner -->|"loads settings"| node_config
node_dbworker -->|"reads database settings"| node_config
node_embeddings -->|"reads API settings"| node_config
node_tools -->|"reads API settings"| node_config
node_gemini -.->|"provides embeddings"| node_embeddings

click node_app "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/App.tsx"
click node_projects "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/ProjectsPage.tsx"
click node_projectdetail "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/ProjectDetailPage.tsx"
click node_agentspage "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/AgentsPage.tsx"
click node_pipelineview "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/components/AgentPipeline.tsx"
click node_agentnode "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/components/AgentNode.tsx"
click node_clientapi "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/services/api.ts"
click node_pipelinehook "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/hooks/usePipeline.ts"
click node_monitorhook "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/hooks/useMonitoring.ts"
click node_researchapi "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/research/research.controller.ts"
click node_researchsvc "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/research/research.service.ts"
click node_monitorapi "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/monitoring/monitoring.controller.ts"
click node_monitorsvc "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/monitoring/monitoring.service.ts"
click node_scheduler "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/scheduler/scheduler.service.ts"
click node_runner "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/main.py"
click node_scraping "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/scraping/agent.py"
click node_analysis "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/analysis/agent.py"
click node_strategy "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/strategy/agent.py"
click node_monitoragent "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/monitoring/agent.py"
click node_dbworker "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/db.py"
click node_embeddings "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/embeddings.py"
click node_tools "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/tools.py"
click node_config "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/config.py"
click node_prisma "https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/modules/prisma/prisma.service.ts"

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_app,node_projects,node_projectdetail,node_agentspage,node_pipelineview,node_agentnode,node_clientapi,node_pipelinehook,node_monitorhook,node_user toneBlue
class node_researchapi,node_researchsvc,node_monitorapi,node_monitorsvc,node_scheduler toneAmber
class node_runner,node_scraping,node_analysis,node_strategy,node_gemini toneMint
class node_monitoragent toneRose
class node_dbworker,node_embeddings,node_tools,node_config,node_prisma,node_postgres,node_tavily toneIndigo
```

## Components

### Brand workspace

- [Client routes](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Projects workspace](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/ProjectsPage.tsx): `frontend/src/pages/ProjectsPage.tsx`
- [Project details](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/ProjectDetailPage.tsx): `frontend/src/pages/ProjectDetailPage.tsx`
- [Agent pipeline view](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/pages/AgentsPage.tsx): `frontend/src/pages/AgentsPage.tsx`
- [Pipeline visualization](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/components/AgentPipeline.tsx): `frontend/src/components/AgentPipeline.tsx`
- [Finding panels](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/components/AgentNode.tsx): `frontend/src/components/AgentNode.tsx`
- [HTTP and SSE client](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Pipeline state hook](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/hooks/usePipeline.ts): `frontend/src/hooks/usePipeline.ts`
- [Monitoring hook](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/frontend/src/hooks/useMonitoring.ts): `frontend/src/hooks/useMonitoring.ts`

### Application API

- [Research endpoints](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/research/research.controller.ts): `backend/src/research/research.controller.ts`
- [Pipeline orchestration](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/research/research.service.ts): `backend/src/research/research.service.ts`
- [Monitoring endpoints](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/monitoring/monitoring.controller.ts): `backend/src/monitoring/monitoring.controller.ts`
- [Monitoring orchestration](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/monitoring/monitoring.service.ts): `backend/src/monitoring/monitoring.service.ts`
- [Scheduled runs](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/scheduler/scheduler.service.ts): `backend/src/scheduler/scheduler.service.ts`

### Research workers

- [Worker dispatcher](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/main.py): `workers/main.py`
- [Market intelligence](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/scraping/agent.py): `workers/scraping/agent.py`
- [Competitor reconnaissance](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/analysis/agent.py): `workers/analysis/agent.py`
- [Strategy generation](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/strategy/agent.py): `workers/strategy/agent.py`

### Change monitoring

- [Run comparison](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/monitoring/agent.py): `workers/monitoring/agent.py`

### Data and integrations

- [Worker data access](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/db.py): `workers/db.py`
- [Embedding generation](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/embeddings.py): `workers/embeddings.py`
- [Web search tools](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/tools.py): `workers/tools.py`
- [Worker configuration](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/workers/config.py): `workers/config.py`
- [Prisma service](https://github.com/ugarth-p/hackathon_hackiwha/blob/main/backend/src/modules/prisma/prisma.service.ts): `backend/src/modules/prisma/prisma.service.ts`
- **PostgreSQL and pgvector**

### Other components

- **Brand user**
- **Gemini API**
- **Tavily search**

## Connections

- Brand user → Client routes: uses
- Client routes → Projects workspace: routes to (evidence: `frontend/src/App.tsx`)
- Client routes → Project details: routes to (evidence: `frontend/src/App.tsx`)
- Client routes → Agent pipeline view: routes to (evidence: `frontend/src/App.tsx`)
- Agent pipeline view → Pipeline visualization: renders
- Pipeline visualization → Finding panels: renders
- Projects workspace → HTTP and SSE client: requests data
- Project details → HTTP and SSE client: requests data
- Pipeline state hook → HTTP and SSE client: requests and streams
- Monitoring hook → HTTP and SSE client: requests monitoring
- HTTP and SSE client → Research endpoints: HTTP and SSE
- Research endpoints → Pipeline orchestration: delegates (evidence: `backend/src/research/research.controller.ts`)
- Pipeline orchestration → Prisma service: reads and writes (evidence: `backend/src/research/research.service.ts`)
- Pipeline orchestration → Worker dispatcher: spawns with JSON (evidence: `backend/src/research/research.service.ts`)
- Worker dispatcher → Market intelligence: dispatches (evidence: `workers/main.py`)
- Worker dispatcher → Competitor reconnaissance: dispatches (evidence: `workers/main.py`)
- Worker dispatcher → Strategy generation: dispatches (evidence: `workers/main.py`)
- Market intelligence → Web search tools: searches and fetches (evidence: `workers/scraping/agent.py`)
- Competitor reconnaissance → Web search tools: searches and fetches (evidence: `workers/analysis/agent.py`)
- Market intelligence → Gemini API: synthesizes
- Competitor reconnaissance → Gemini API: analyzes
- Strategy generation → Gemini API: generates strategy
- Web search tools → Tavily search: searches
- Market intelligence → Worker data access: stores findings (evidence: `workers/scraping/agent.py`)
- Competitor reconnaissance → Worker data access: stores findings (evidence: `workers/analysis/agent.py`)
- Strategy generation → Worker data access: stores findings (evidence: `workers/strategy/agent.py`)
- Competitor reconnaissance → Embedding generation: embeds output (evidence: `workers/analysis/agent.py`)
- Market intelligence → Embedding generation: embeds findings (evidence: `workers/scraping/agent.py`)
- Strategy generation → Embedding generation: embeds output (evidence: `workers/strategy/agent.py`)
- Worker data access → PostgreSQL and pgvector: queries (evidence: `workers/db.py`)
- Prisma service → PostgreSQL and pgvector: persists records
- Worker dispatcher → Pipeline orchestration: returns JSON
- Pipeline orchestration → HTTP and SSE client: emits SSE
- HTTP and SSE client → Pipeline visualization: updates visualization
- Monitoring endpoints → Monitoring orchestration: delegates (evidence: `backend/src/monitoring/monitoring.controller.ts`)
- Monitoring orchestration → Prisma service: loads and saves runs (evidence: `backend/src/monitoring/monitoring.service.ts`)
- Monitoring orchestration → Worker dispatcher: spawns comparison (evidence: `backend/src/monitoring/monitoring.service.ts`)
- Worker dispatcher → Run comparison: dispatches monitoring (evidence: `workers/main.py`)
- Run comparison → Worker data access: loads and saves data (evidence: `workers/monitoring/agent.py`)
- Scheduled runs → Monitoring orchestration: triggers monitoring (evidence: `backend/src/scheduler/scheduler.service.ts`)
- Worker dispatcher → Worker configuration: loads settings (evidence: `workers/main.py`)
- Worker data access → Worker configuration: reads database settings (evidence: `workers/db.py`)
- Embedding generation → Worker configuration: reads API settings (evidence: `workers/embeddings.py`)
- Web search tools → Worker configuration: reads API settings (evidence: `workers/tools.py`)
- Gemini API → Embedding generation: provides embeddings
