# rohith-s378/driftwatch architecture

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

- Interactive diagram: https://gitdiagram.com/rohith-s378/driftwatch
- Repository: https://github.com/rohith-s378/driftwatch

## Overview

DriftWatch is a competitive-intelligence platform. A user submits a company URL through Discovery; the backend profiles it, searches for and verifies competitor candidates, ranks them for review, and can promote a candidate into scheduled monitoring. Monitoring crawls tracked sites, stores snapshots, detects changes, and exposes results through overview, changes, insights, and grounded Ask AI views. A separate webhook ingestion route accepts externally supplied snapshots. The graph follows README-documented workflows and sampled call relationships; some unsampled page and service internals are represented only at subsystem level.

Main entry points: [`app/main.py`](https://github.com/rohith-s378/driftwatch/blob/main/app/main.py) (FastAPI endpoints), [`app/services/snapshot_service.py`](https://github.com/rohith-s378/driftwatch/blob/main/app/services/snapshot_service.py) (Snapshot processing), [`app/services/crawler.py`](https://github.com/rohith-s378/driftwatch/blob/main/app/services/crawler.py) (Website crawler), [`app/models/models.py`](https://github.com/rohith-s378/driftwatch/blob/main/app/models/models.py) (Domain records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_discovery_ui["Discovery page<br/>[Discovery.jsx]"]
  node_overview_ui["Overview page<br/>[Overview.jsx]"]
  node_changes_ui["Changes page<br/>[Changes.jsx]"]
  node_insights_ui["Insights page<br/>[Insights.jsx]"]
  node_ask_ui["Ask AI page<br/>[askAI.jsx]"]
  node_frontend_api["Backend API client<br/>[api.js]"]
end

subgraph group_discovery["Competitor discovery"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_profiler["Company profiler<br/>[profiler.py]"]
  node_discovery_engine["Competitor discovery<br/>[discovery.py]"]
  node_search["Search providers"]
end

subgraph group_monitoring["Monitoring and alerts"]
  node_crawler["Website crawler<br/>[crawler.py]"]
  node_url_guard["SSRF URL guard<br/>[url_validator.py]"]
  node_scheduler["Monitoring scheduler<br/>[scheduler.py]"]
  node_webhook["Webhook ingestion<br/>[webhook.py]"]
end

subgraph group_intelligence["Data and intelligence"]
  node_snapshots["Snapshot processing"]
  node_detector["Change detection<br/>[change_detector.py]"]
  node_extractors["Content extractors<br/>[extractors.py]"]
  node_ask_service["Grounded Q&amp;A<br/>[ask_ai.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

node_user(("Market analyst"))
node_external_search{{"Search APIs"}}

node_user -->|"submits URL"| node_discovery_ui
node_discovery_ui -->|"requests discovery"| node_frontend_api
node_frontend_api -->|"calls endpoints"| node_api
node_api -->|"profiles company"| node_profiler
node_api -->|"starts discovery"| node_discovery_engine
node_profiler -->|"crawls site"| node_crawler
node_discovery_engine -->|"searches candidates"| node_search
node_search -->|"queries provider"| node_external_search
node_discovery_engine -->|"verifies sites"| node_crawler
node_api -->|"persists candidates"| node_models
node_user -->|"reviews monitoring"| node_overview_ui
node_user -->|"reviews changes"| node_changes_ui
node_user -->|"reviews insights"| node_insights_ui
node_user -->|"asks questions"| node_ask_ui
node_api -->|"tracks competitors"| node_scheduler
node_scheduler -->|"schedules crawls"| node_crawler
node_crawler -->|"validates URLs"| node_url_guard
node_crawler -.->|"submits snapshots"| node_snapshots
node_webhook -->|"processes payload"| node_snapshots
node_snapshots -->|"runs detectors"| node_detector
node_snapshots -->|"extracts prices"| node_extractors
node_snapshots -->|"stores events"| node_models
node_api -->|"queries intelligence"| node_ask_service
node_ask_service -->|"reads evidence"| node_models
node_models -->|"maps records"| node_database

click node_discovery_ui "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Discovery.jsx"
click node_overview_ui "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Overview.jsx"
click node_changes_ui "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Changes.jsx"
click node_insights_ui "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Insights.jsx"
click node_ask_ui "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/askAI.jsx"
click node_frontend_api "https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/api.js"
click node_api "https://github.com/rohith-s378/driftwatch/blob/main/app/main.py"
click node_profiler "https://github.com/rohith-s378/driftwatch/blob/main/app/services/profiler.py"
click node_discovery_engine "https://github.com/rohith-s378/driftwatch/blob/main/app/services/discovery.py"
click node_search "https://github.com/rohith-s378/driftwatch/blob/main/app/services/search_providers.py"
click node_crawler "https://github.com/rohith-s378/driftwatch/blob/main/app/services/crawler.py"
click node_url_guard "https://github.com/rohith-s378/driftwatch/blob/main/app/services/url_validator.py"
click node_scheduler "https://github.com/rohith-s378/driftwatch/blob/main/app/services/scheduler.py"
click node_webhook "https://github.com/rohith-s378/driftwatch/blob/main/app/routers/webhook.py"
click node_snapshots "https://github.com/rohith-s378/driftwatch/blob/main/app/services/snapshot_service.py"
click node_detector "https://github.com/rohith-s378/driftwatch/blob/main/app/services/change_detector.py"
click node_extractors "https://github.com/rohith-s378/driftwatch/blob/main/app/services/extractors.py"
click node_ask_service "https://github.com/rohith-s378/driftwatch/blob/main/app/services/ask_ai.py"
click node_models "https://github.com/rohith-s378/driftwatch/blob/main/app/models/models.py"
click node_database "https://github.com/rohith-s378/driftwatch/blob/main/app/db/database.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_discovery_ui,node_overview_ui,node_changes_ui,node_insights_ui,node_ask_ui,node_frontend_api toneBlue
class node_api,node_profiler,node_discovery_engine,node_search toneAmber
class node_crawler,node_url_guard,node_scheduler,node_webhook,node_external_search toneMint
class node_snapshots,node_detector,node_extractors,node_ask_service,node_models,node_database toneRose
class node_user toneIndigo
```

## Components

### Web application

- [Discovery page](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Discovery.jsx): `frontend/src/pages/Discovery.jsx`
- [Overview page](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Overview.jsx): `frontend/src/pages/Overview.jsx`
- [Changes page](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Changes.jsx): `frontend/src/pages/Changes.jsx`
- [Insights page](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/Insights.jsx): `frontend/src/pages/Insights.jsx`
- [Ask AI page](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/pages/askAI.jsx): `frontend/src/pages/askAI.jsx`
- [Backend API client](https://github.com/rohith-s378/driftwatch/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Competitor discovery

- [FastAPI endpoints](https://github.com/rohith-s378/driftwatch/blob/main/app/main.py): `app/main.py`
- [Company profiler](https://github.com/rohith-s378/driftwatch/blob/main/app/services/profiler.py): `app/services/profiler.py`
- [Competitor discovery](https://github.com/rohith-s378/driftwatch/blob/main/app/services/discovery.py): `app/services/discovery.py`
- [Search providers](https://github.com/rohith-s378/driftwatch/blob/main/app/services/search_providers.py): `app/services/search_providers.py`

### Monitoring and alerts

- [Website crawler](https://github.com/rohith-s378/driftwatch/blob/main/app/services/crawler.py): `app/services/crawler.py`
- [SSRF URL guard](https://github.com/rohith-s378/driftwatch/blob/main/app/services/url_validator.py): `app/services/url_validator.py`
- [Monitoring scheduler](https://github.com/rohith-s378/driftwatch/blob/main/app/services/scheduler.py): `app/services/scheduler.py`
- [Webhook ingestion](https://github.com/rohith-s378/driftwatch/blob/main/app/routers/webhook.py): `app/routers/webhook.py`

### Data and intelligence

- [Snapshot processing](https://github.com/rohith-s378/driftwatch/blob/main/app/services/snapshot_service.py): `app/services/snapshot_service.py`
- [Change detection](https://github.com/rohith-s378/driftwatch/blob/main/app/services/change_detector.py): `app/services/change_detector.py`
- [Content extractors](https://github.com/rohith-s378/driftwatch/blob/main/app/services/extractors.py): `app/services/extractors.py`
- [Grounded Q&A](https://github.com/rohith-s378/driftwatch/blob/main/app/services/ask_ai.py): `app/services/ask_ai.py`
- [Domain records](https://github.com/rohith-s378/driftwatch/blob/main/app/models/models.py): `app/models/models.py`
- [SQL database](https://github.com/rohith-s378/driftwatch/blob/main/app/db/database.py): `app/db/database.py`

### Other components

- **Market analyst**
- **Search APIs**

## Connections

- Market analyst → Discovery page: submits URL
- Discovery page → Backend API client: requests discovery (evidence: `frontend/src/pages/Discovery.jsx`)
- Backend API client → FastAPI endpoints: calls endpoints
- FastAPI endpoints → Company profiler: profiles company (evidence: `app/main.py`)
- FastAPI endpoints → Competitor discovery: starts discovery (evidence: `app/main.py`)
- Company profiler → Website crawler: crawls site (evidence: `app/services/profiler.py`)
- Competitor discovery → Search providers: searches candidates (evidence: `app/services/discovery.py`)
- Search providers → Search APIs: queries provider (evidence: `app/services/search_providers.py`)
- Competitor discovery → Website crawler: verifies sites (evidence: `app/services/discovery.py`)
- FastAPI endpoints → Domain records: persists candidates (evidence: `app/main.py`)
- Market analyst → Overview page: reviews monitoring
- Market analyst → Changes page: reviews changes
- Market analyst → Insights page: reviews insights
- Market analyst → Ask AI page: asks questions
- FastAPI endpoints → Monitoring scheduler: tracks competitors (evidence: `app/main.py`)
- Monitoring scheduler → Website crawler: schedules crawls (evidence: `app/services/scheduler.py`)
- Website crawler → SSRF URL guard: validates URLs (evidence: `app/services/crawler.py`)
- Website crawler → Snapshot processing: submits snapshots
- Webhook ingestion → Snapshot processing: processes payload (evidence: `app/routers/webhook.py`)
- Snapshot processing → Change detection: runs detectors (evidence: `app/services/snapshot_service.py`)
- Snapshot processing → Content extractors: extracts prices (evidence: `app/services/snapshot_service.py`)
- Snapshot processing → Domain records: stores events (evidence: `app/services/snapshot_service.py`)
- FastAPI endpoints → Grounded Q&A: queries intelligence (evidence: `app/main.py`)
- Grounded Q&A → Domain records: reads evidence (evidence: `app/services/ask_ai.py`)
- Domain records → SQL database: maps records (evidence: `app/models/models.py`)
