# dheerajrai-dev/spectramap architecture

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

- Interactive diagram: https://gitdiagram.com/dheerajrai-dev/spectramap
- Repository: https://github.com/dheerajrai-dev/spectramap

## Overview

SpectraMap turns cellular-tower records into a spatial interference graph, colors that graph with heuristic and exact solvers, and presents allocations and diagnostics in an interactive map workspace. The main flow is tower retrieval, graph construction, optimization and validation, then visualization and inspection. The README documents additional analytics, comparison, bounds checks, and offline-demo capabilities. Some frontend-to-API wiring and unsampled feature details are not visible in the excerpts, so those relationships are omitted or marked unverified.

Main entry points: [`app.py`](https://github.com/dheerajrai-dev/spectramap/blob/main/app.py) (REST API), [`static/app.js`](https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js) (Interactive Workspace), [`data_service.py`](https://github.com/dheerajrai-dev/spectramap/blob/main/data_service.py) (Tower Ingestion), [`graph_engine.py`](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py) (DSatur Solver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["User Workspace"]
  node_web["Interactive Workspace<br/>[app.js]"]
  node_map["Map and Graph Views<br/>[app.js]"]
  node_inspector["Tower Inspector<br/>[app.js]"]
end

subgraph group_service["API and Data"]
  node_api["REST API<br/>[app.py]"]
  node_ingest["Tower Ingestion<br/>[data_service.py]"]
  node_cache[("Local Query Cache")]
end

subgraph group_allocation["Graph Allocation"]
  node_graph["Interference Graph Builder<br/>[graph_engine.py]"]
  node_metrics["Graph Diagnostics<br/>[graph_engine.py]"]
  node_dsatur["DSatur Solver<br/>[graph_engine.py]"]
  node_welsh["Welsh-Powell Solver<br/>[graph_engine.py]"]
  node_exact["Exact Solver<br/>[graph_engine.py]"]
  node_audit["Coloring Validator<br/>[graph_engine.py]"]
  node_results["Allocation Results<br/>[app.py]"]
end

subgraph group_contracts["Data Contracts"]
  node_contracts["Request and Response Models<br/>[schemas.py]"]
end

node_engineer(("Workspace User"))
node_opencellid["OpenCellID"]
node_osm["OpenStreetMap Tiles"]

node_engineer -->|"uses"| node_web
node_web -.->|"requests data"| node_api
node_api -->|"validates requests"| node_contracts
node_api -->|"fetches records"| node_ingest
node_ingest -->|"queries"| node_opencellid
node_ingest -.->|"reads and writes"| node_cache
node_api -->|"builds graph"| node_graph
node_api -->|"runs solver"| node_dsatur
node_api -->|"runs solver"| node_welsh
node_api -.->|"supports exact solve"| node_exact
node_api -->|"returns diagnostics"| node_metrics
node_api -->|"returns validation"| node_audit
node_graph -->|"measures"| node_metrics
node_dsatur -->|"validates coloring"| node_audit
node_welsh -->|"validates coloring"| node_audit
node_exact -->|"falls back to"| node_dsatur
node_api -->|"returns allocations"| node_results
node_results -->|"renders results"| node_map
node_web -->|"opens details"| node_inspector
node_web -->|"switches views"| node_map
node_map -.->|"displays tiles"| node_osm

click node_web "https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js"
click node_map "https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js"
click node_inspector "https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js"
click node_api "https://github.com/dheerajrai-dev/spectramap/blob/main/app.py"
click node_ingest "https://github.com/dheerajrai-dev/spectramap/blob/main/data_service.py"
click node_contracts "https://github.com/dheerajrai-dev/spectramap/blob/main/schemas.py"
click node_graph "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_metrics "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_dsatur "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_welsh "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_exact "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_audit "https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py"
click node_results "https://github.com/dheerajrai-dev/spectramap/blob/main/app.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_web,node_map,node_inspector,node_engineer toneBlue
class node_api,node_ingest,node_cache toneAmber
class node_graph,node_metrics,node_dsatur,node_welsh,node_exact,node_audit,node_results toneMint
class node_contracts toneRose
class node_opencellid,node_osm toneIndigo
```

## Components

### User Workspace

- [Interactive Workspace](https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js): `static/app.js`
- [Map and Graph Views](https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js): `static/app.js`
- [Tower Inspector](https://github.com/dheerajrai-dev/spectramap/blob/main/static/app.js): `static/app.js`

### API and Data

- [REST API](https://github.com/dheerajrai-dev/spectramap/blob/main/app.py): `app.py`
- [Tower Ingestion](https://github.com/dheerajrai-dev/spectramap/blob/main/data_service.py): `data_service.py`
- **Local Query Cache**

### Graph Allocation

- [Interference Graph Builder](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [Graph Diagnostics](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [DSatur Solver](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [Welsh-Powell Solver](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [Exact Solver](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [Coloring Validator](https://github.com/dheerajrai-dev/spectramap/blob/main/graph_engine.py): `graph_engine.py`
- [Allocation Results](https://github.com/dheerajrai-dev/spectramap/blob/main/app.py): `app.py`

### Data Contracts

- [Request and Response Models](https://github.com/dheerajrai-dev/spectramap/blob/main/schemas.py): `schemas.py`

### Other components

- **Workspace User**
- **OpenCellID**
- **OpenStreetMap Tiles**

## Connections

- Workspace User → Interactive Workspace: uses (evidence: `README.md`)
- Interactive Workspace → REST API: requests data
- REST API → Request and Response Models: validates requests (evidence: `app.py`)
- REST API → Tower Ingestion: fetches records (evidence: `app.py`)
- Tower Ingestion → OpenCellID: queries (evidence: `data_service.py`)
- Tower Ingestion → Local Query Cache: reads and writes (evidence: `README.md`)
- REST API → Interference Graph Builder: builds graph (evidence: `app.py`)
- REST API → DSatur Solver: runs solver (evidence: `app.py`)
- REST API → Welsh-Powell Solver: runs solver (evidence: `app.py`)
- REST API → Exact Solver: supports exact solve (evidence: `README.md`)
- REST API → Graph Diagnostics: returns diagnostics (evidence: `app.py`)
- REST API → Coloring Validator: returns validation (evidence: `app.py`)
- Interference Graph Builder → Graph Diagnostics: measures (evidence: `graph_engine.py`)
- DSatur Solver → Coloring Validator: validates coloring (evidence: `graph_engine.py`)
- Welsh-Powell Solver → Coloring Validator: validates coloring (evidence: `graph_engine.py`)
- Exact Solver → DSatur Solver: falls back to (evidence: `graph_engine.py`)
- REST API → Allocation Results: returns allocations (evidence: `app.py`)
- Allocation Results → Map and Graph Views: renders results (evidence: `README.md`)
- Interactive Workspace → Tower Inspector: opens details (evidence: `static/app.js`)
- Interactive Workspace → Map and Graph Views: switches views (evidence: `static/app.js`)
- Map and Graph Views → OpenStreetMap Tiles: displays tiles (evidence: `README.md`)
