# abdussalam01/dealersight architecture

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

- Interactive diagram: https://gitdiagram.com/abdussalam01/dealersight
- Repository: https://github.com/abdussalam01/dealersight

## Overview

DealerSight is a local FastAPI product that turns Ring camera events into an anonymous dealership funnel, adds clearly labelled simulated sales and finance data, and presents evidence-backed comparisons and findings. The main workflow is polling, optional queue delivery, ingestion, rule-based correlation, then funnel and review views; an analyst receives a computed metric packet and returns validated prose or a labelled fallback. README-documented capabilities include dealer, network, finance, event-audit, demo-camera controls, and optional SQS. Some route and persistence details are documented rather than shown in the sampled excerpts.

Main entry points: [`backend/main.py`](https://github.com/abdussalam01/dealersight/blob/main/backend/main.py) (FastAPI application), [`backend/correlation.py`](https://github.com/abdussalam01/dealersight/blob/main/backend/correlation.py) (Event correlation), [`db/schema.sql`](https://github.com/abdussalam01/dealersight/blob/main/db/schema.sql) (PostgreSQL records), [`backend/ring_poller.py`](https://github.com/abdussalam01/dealersight/blob/main/backend/ring_poller.py) (Ring poller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Event collection"]
  node_poller["Ring poller<br/>[ring_poller.py]"]
  node_worker["Queue worker<br/>[pipeline.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_evidence["Funnel evidence"]
  node_ingest["Event ingestion<br/>[ingest.py]"]
  node_database[("PostgreSQL records<br/>[schema.sql]")]
  node_correlation["Event correlation<br/>[correlation.py]"]
  node_seed["Demo data seeding<br/>[seed.py]"]
  node_replay["Event replay<br/>[replay.py]"]
  node_rules["Correlation rules<br/>[rules.yaml]"]
end

subgraph group_analytics["Business analytics"]
  node_funnel["Funnel and patterns<br/>[funnel.py]"]
  node_checks["Finding checks<br/>[checks.py]"]
  node_metrics["Metric summaries<br/>[metrics.py]"]
  node_packets["Metric packets<br/>[packets.py]"]
end

subgraph group_presentation["API and analyst"]
  node_api["FastAPI application<br/>[main.py]"]
  node_analyst["AI analyst<br/>[analyst.py]"]
  node_frontend["Dashboard UI"]
end

node_ring(("Ring Playground"))
node_ring_api["Ring Partner API"]
node_queue["SQS event queue"]
node_bedrock["Amazon Bedrock"]

node_ring -->|"emits events"| node_ring_api
node_ring_api -->|"serves history"| node_poller
node_poller -->|"ingests locally"| node_ingest
node_poller -.->|"publishes events"| node_queue
node_queue -->|"delivers events"| node_worker
node_worker -->|"ingests messages"| node_ingest
node_ingest -->|"stores events"| node_database
node_database -->|"reads raw events"| node_correlation
node_correlation -->|"loads rules"| node_rules
node_correlation -->|"writes derived events"| node_database
node_seed -->|"seeds demo records"| node_database
node_seed -->|"rebuilds derived data"| node_correlation
node_replay -->|"replays events"| node_ingest
node_replay -->|"rebuilds metrics"| node_correlation
node_funnel -->|"queries records"| node_database
node_checks -->|"compares periods"| node_funnel
node_checks -->|"tests pairing rules"| node_correlation
node_metrics -->|"queries records"| node_database
node_packets -->|"builds metric facts"| node_funnel
node_packets -->|"adds finding evidence"| node_checks
node_api -->|"starts polling"| node_poller
node_api -.->|"starts worker"| node_worker
node_api -->|"seeds on startup"| node_seed
node_api -->|"serves views"| node_funnel
node_api -->|"serves findings"| node_checks
node_api -->|"serves summaries"| node_metrics
node_api -->|"handles questions"| node_analyst
node_api -->|"serves dashboard"| node_frontend
node_analyst -->|"requests facts"| node_packets
node_analyst -.->|"requests explanation"| node_bedrock
node_bedrock -.->|"returns answer"| node_analyst
node_config -->|"configures polling"| node_poller
node_config -->|"configures queue"| node_worker

click node_poller "https://github.com/abdussalam01/dealersight/blob/main/backend/ring_poller.py"
click node_worker "https://github.com/abdussalam01/dealersight/blob/main/backend/pipeline.py"
click node_ingest "https://github.com/abdussalam01/dealersight/blob/main/backend/ingest.py"
click node_database "https://github.com/abdussalam01/dealersight/blob/main/db/schema.sql"
click node_correlation "https://github.com/abdussalam01/dealersight/blob/main/backend/correlation.py"
click node_seed "https://github.com/abdussalam01/dealersight/blob/main/backend/seed.py"
click node_replay "https://github.com/abdussalam01/dealersight/blob/main/backend/replay.py"
click node_funnel "https://github.com/abdussalam01/dealersight/blob/main/backend/funnel.py"
click node_checks "https://github.com/abdussalam01/dealersight/blob/main/backend/checks.py"
click node_metrics "https://github.com/abdussalam01/dealersight/blob/main/backend/metrics.py"
click node_packets "https://github.com/abdussalam01/dealersight/blob/main/backend/packets.py"
click node_api "https://github.com/abdussalam01/dealersight/blob/main/backend/main.py"
click node_analyst "https://github.com/abdussalam01/dealersight/blob/main/backend/analyst.py"
click node_frontend "https://github.com/abdussalam01/dealersight/tree/main/frontend"
click node_rules "https://github.com/abdussalam01/dealersight/blob/main/config/rules.yaml"
click node_config "https://github.com/abdussalam01/dealersight/blob/main/backend/config.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_poller,node_worker,node_config toneBlue
class node_ingest,node_database,node_correlation,node_seed,node_replay,node_rules toneAmber
class node_funnel,node_checks,node_metrics,node_packets,node_ring_api toneMint
class node_api,node_analyst,node_frontend,node_queue toneRose
class node_ring,node_bedrock toneIndigo
```

## Components

### Event collection

- [Ring poller](https://github.com/abdussalam01/dealersight/blob/main/backend/ring_poller.py): `backend/ring_poller.py`
- [Queue worker](https://github.com/abdussalam01/dealersight/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Runtime configuration](https://github.com/abdussalam01/dealersight/blob/main/backend/config.py): `backend/config.py`

### Funnel evidence

- [Event ingestion](https://github.com/abdussalam01/dealersight/blob/main/backend/ingest.py): `backend/ingest.py`
- [PostgreSQL records](https://github.com/abdussalam01/dealersight/blob/main/db/schema.sql): `db/schema.sql`
- [Event correlation](https://github.com/abdussalam01/dealersight/blob/main/backend/correlation.py): `backend/correlation.py`
- [Demo data seeding](https://github.com/abdussalam01/dealersight/blob/main/backend/seed.py): `backend/seed.py`
- [Event replay](https://github.com/abdussalam01/dealersight/blob/main/backend/replay.py): `backend/replay.py`
- [Correlation rules](https://github.com/abdussalam01/dealersight/blob/main/config/rules.yaml): `config/rules.yaml`

### Business analytics

- [Funnel and patterns](https://github.com/abdussalam01/dealersight/blob/main/backend/funnel.py): `backend/funnel.py`
- [Finding checks](https://github.com/abdussalam01/dealersight/blob/main/backend/checks.py): `backend/checks.py`
- [Metric summaries](https://github.com/abdussalam01/dealersight/blob/main/backend/metrics.py): `backend/metrics.py`
- [Metric packets](https://github.com/abdussalam01/dealersight/blob/main/backend/packets.py): `backend/packets.py`

### API and analyst

- [FastAPI application](https://github.com/abdussalam01/dealersight/blob/main/backend/main.py): `backend/main.py`
- [AI analyst](https://github.com/abdussalam01/dealersight/blob/main/backend/analyst.py): `backend/analyst.py`
- [Dashboard UI](https://github.com/abdussalam01/dealersight/tree/main/frontend): `frontend`

### Other components

- **Ring Playground**
- **Ring Partner API**
- **SQS event queue**
- **Amazon Bedrock**

## Connections

- Ring Playground → Ring Partner API: emits events (evidence: `README.md`)
- Ring Partner API → Ring poller: serves history (evidence: `README.md`)
- Ring poller → Event ingestion: ingests locally (evidence: `README.md`)
- Ring poller → SQS event queue: publishes events (evidence: `README.md`)
- SQS event queue → Queue worker: delivers events (evidence: `README.md`)
- Queue worker → Event ingestion: ingests messages (evidence: `backend/pipeline.py`)
- Event ingestion → PostgreSQL records: stores events (evidence: `backend/ingest.py`)
- PostgreSQL records → Event correlation: reads raw events (evidence: `backend/correlation.py`)
- Event correlation → Correlation rules: loads rules (evidence: `backend/correlation.py`)
- Event correlation → PostgreSQL records: writes derived events (evidence: `backend/correlation.py`)
- Demo data seeding → PostgreSQL records: seeds demo records (evidence: `backend/seed.py`)
- Demo data seeding → Event correlation: rebuilds derived data (evidence: `backend/seed.py`)
- Event replay → Event ingestion: replays events (evidence: `backend/replay.py`)
- Event replay → Event correlation: rebuilds metrics (evidence: `backend/replay.py`)
- Funnel and patterns → PostgreSQL records: queries records (evidence: `backend/funnel.py`)
- Finding checks → Funnel and patterns: compares periods (evidence: `backend/checks.py`)
- Finding checks → Event correlation: tests pairing rules (evidence: `backend/checks.py`)
- Metric summaries → PostgreSQL records: queries records (evidence: `backend/metrics.py`)
- Metric packets → Funnel and patterns: builds metric facts (evidence: `backend/packets.py`)
- Metric packets → Finding checks: adds finding evidence (evidence: `backend/packets.py`)
- FastAPI application → Ring poller: starts polling (evidence: `README.md`)
- FastAPI application → Queue worker: starts worker (evidence: `README.md`)
- FastAPI application → Demo data seeding: seeds on startup (evidence: `README.md`)
- FastAPI application → Funnel and patterns: serves views (evidence: `backend/main.py`)
- FastAPI application → Finding checks: serves findings (evidence: `README.md`)
- FastAPI application → Metric summaries: serves summaries (evidence: `backend/main.py`)
- FastAPI application → AI analyst: handles questions (evidence: `README.md`)
- FastAPI application → Dashboard UI: serves dashboard (evidence: `backend/main.py`)
- AI analyst → Metric packets: requests facts (evidence: `backend/analyst.py`)
- AI analyst → Amazon Bedrock: requests explanation (evidence: `README.md`)
- Amazon Bedrock → AI analyst: returns answer (evidence: `README.md`)
- Runtime configuration → Ring poller: configures polling (evidence: `backend/ring_poller.py`)
- Runtime configuration → Queue worker: configures queue (evidence: `backend/pipeline.py`)
