# jatinkumar321/spatial-db-engine architecture

> Architecture diagram of the GitHub repository jatinkumar321/spatial-db-engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jatinkumar321/spatial-db-engine
- Repository: https://github.com/jatinkumar321/spatial-db-engine

## Overview

This is an in-memory spatial-index service with a browser dashboard, rather than a complete ride-dispatch system: the sampled API inserts points and performs bounding-box searches, but does not assign nearest drivers to requests. The main workflow is dashboard-to-HTTP API, then R*-Tree operation, with results or tree data returned for display. The README also documents city-load simulation and event logging in the dashboard. The frontend source was not sampled, so its internal behavior and exact endpoint wiring are based on README descriptions; uncertain links are omitted.

Main entry points: [`src/main.cpp`](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/main.cpp) (REST endpoints), [`web/index.html`](https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html) (Map dashboard), [`src/rtree.cpp`](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp) (R*-Tree index), [`include/rtree.h`](https://github.com/jatinkumar321/spatial-db-engine/blob/main/include/rtree.h) (Tree statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Map dashboard<br/>[index.html]"]
  node_load_sim["City load simulator<br/>[index.html]"]
  node_event_log["Event log console<br/>[index.html]"]
end

subgraph group_api["HTTP service"]
  node_http_server["HTTP server<br/>[main.cpp]"]
  node_rest_api["REST endpoints<br/>[main.cpp]"]
end

subgraph group_spatial["Spatial index"]
  node_rtree[("R*-Tree index<br/>[rtree.cpp]")]
  node_range_search["Range search<br/>[rtree.cpp]"]
  node_tree_json["Tree serializer<br/>[rtree.cpp]"]
  node_tree_stats["Tree statistics<br/>[rtree.h]"]
end

subgraph group_model["Spatial model"]
  node_point_box["Points and MBRs<br/>[node.h]"]
end

node_browser_user(("Dashboard user"))

node_browser_user -->|"uses"| node_dashboard
node_dashboard -->|"HTTP requests"| node_http_server
node_http_server -->|"serves page"| node_dashboard
node_http_server -->|"dispatches routes"| node_rest_api
node_rest_api -->|"inserts points"| node_rtree
node_rest_api -->|"searches bounds"| node_range_search
node_rest_api -->|"clears index"| node_rtree
node_rest_api -->|"requests serialization"| node_tree_json
node_rest_api -->|"reads statistics"| node_tree_stats
node_range_search -->|"queries index"| node_rtree
node_tree_json -->|"serializes structure"| node_rtree
node_rtree -->|"indexes coordinates"| node_point_box
node_dashboard -.->|"starts simulation"| node_load_sim
node_dashboard -.->|"shows events"| node_event_log

click node_dashboard "https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html"
click node_load_sim "https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html"
click node_event_log "https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html"
click node_http_server "https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/main.cpp"
click node_rest_api "https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/main.cpp"
click node_rtree "https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp"
click node_range_search "https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp"
click node_tree_json "https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp"
click node_tree_stats "https://github.com/jatinkumar321/spatial-db-engine/blob/main/include/rtree.h"
click node_point_box "https://github.com/jatinkumar321/spatial-db-engine/blob/main/include/node.h"

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_dashboard,node_load_sim,node_event_log,node_browser_user toneBlue
class node_http_server,node_rest_api toneAmber
class node_rtree,node_range_search,node_tree_json,node_tree_stats toneMint
class node_point_box toneRose
```

## Components

### Dashboard

- [Map dashboard](https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html): `web/index.html`
- [City load simulator](https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html): `web/index.html`
- [Event log console](https://github.com/jatinkumar321/spatial-db-engine/blob/main/web/index.html): `web/index.html`

### HTTP service

- [HTTP server](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/main.cpp): `src/main.cpp`
- [REST endpoints](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/main.cpp): `src/main.cpp`

### Spatial index

- [R*-Tree index](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp): `src/rtree.cpp`
- [Range search](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp): `src/rtree.cpp`
- [Tree serializer](https://github.com/jatinkumar321/spatial-db-engine/blob/main/src/rtree.cpp): `src/rtree.cpp`
- [Tree statistics](https://github.com/jatinkumar321/spatial-db-engine/blob/main/include/rtree.h): `include/rtree.h`

### Spatial model

- [Points and MBRs](https://github.com/jatinkumar321/spatial-db-engine/blob/main/include/node.h): `include/node.h`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Map dashboard: uses
- Map dashboard → HTTP server: HTTP requests
- HTTP server → Map dashboard: serves page
- HTTP server → REST endpoints: dispatches routes
- REST endpoints → R*-Tree index: inserts points
- REST endpoints → Range search: searches bounds
- REST endpoints → R*-Tree index: clears index
- REST endpoints → Tree serializer: requests serialization
- REST endpoints → Tree statistics: reads statistics
- Range search → R*-Tree index: queries index
- Tree serializer → R*-Tree index: serializes structure
- R*-Tree index → Points and MBRs: indexes coordinates
- Map dashboard → City load simulator: starts simulation
- Map dashboard → Event log console: shows events
