# sametcanturhan/distributedgis architecture

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

- Interactive diagram: https://gitdiagram.com/sametcanturhan/distributedgis
- Repository: https://github.com/sametcanturhan/distributedgis

## Overview

This is a Berlin-focused, weather-aware road-risk Web GIS. Users select or search for a location, snap it to a road, submit a hazard report, and view risk-affected road segments and map layers; reports and road data persist in PostGIS. The graph includes the documented weather, search, layer, and export capabilities. Backend call paths are supported by excerpts; several frontend interactions and deployment connections are documented in the README because their source was only partially sampled.

Main entry points: [`backend/main.py`](https://github.com/sametcanturhan/distributedgis/blob/main/backend/main.py) (FastAPI routes), [`backend/crud.py`](https://github.com/sametcanturhan/distributedgis/blob/main/backend/crud.py) (Report management), [`js/app.js`](https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js) (Report workflows), [`init.sql`](https://github.com/sametcanturhan/distributedgis/blob/main/init.sql) (PostGIS reports and roads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Map interface"]
  node_webmap["Leaflet map<br/>[index.html]"]
  node_map_workflows["Report workflows<br/>[app.js]"]
  node_map_layers["Map layers<br/>[app.js]"]
  node_map_search["Location search<br/>[app.js]"]
  node_map_export["Data export<br/>[app.js]"]
end

subgraph group_backend["API and domain"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_report_crud["Report management<br/>[crud.py]"]
  node_schemas["Request and GeoJSON schemas<br/>[models.py]"]
  node_geojson["Report GeoJSON<br/>[geojson.py]"]
  node_road_analysis["Road snap and risk<br/>[roads.py]"]
  node_weather_logic["Weather lookup<br/>[weather.py]"]
  node_location_proxy["Search proxy<br/>[locations.py]"]
end

subgraph group_data["Spatial data"]
  node_db_session["Database sessions<br/>[database.py]"]
  node_report_model["Road report model<br/>[db_models.py]"]
  node_spatial_db[("PostGIS reports and roads<br/>[init.sql]")]
  node_road_importer["OSM road importer<br/>[roads.lua]"]
end

subgraph group_services["External services"]
  node_open_meteo["Open-Meteo"]
  node_nominatim["Nominatim"]
  node_map_tiles["Basemap tiles"]
end

node_visitor(("Map user"))

node_visitor -->|"uses"| node_webmap
node_webmap -->|"hosts"| node_map_workflows
node_map_workflows -->|"requests"| node_api
node_api -->|"dispatches"| node_report_crud
node_api -->|"dispatches"| node_road_analysis
node_api -->|"dispatches"| node_weather_logic
node_api -->|"dispatches"| node_location_proxy
node_api -->|"formats reports"| node_geojson
node_api -->|"validates responses"| node_schemas
node_api -->|"opens sessions"| node_db_session
node_report_crud -->|"creates and reads"| node_report_model
node_report_crud -->|"snaps locations"| node_road_analysis
node_report_crud -->|"fetches weather"| node_weather_logic
node_report_crud -->|"persists reports"| node_spatial_db
node_report_model -->|"uses base"| node_db_session
node_geojson -->|"converts reports"| node_report_model
node_road_analysis -->|"queries spatial data"| node_spatial_db
node_db_session -->|"connects to"| node_spatial_db
node_road_importer -->|"imports roads"| node_spatial_db
node_weather_logic -->|"requests forecasts"| node_open_meteo
node_location_proxy -->|"searches places"| node_nominatim
node_map_search -->|"searches through"| node_api
node_map_layers -->|"loads weather and risk"| node_api
node_map_workflows -->|"renders reports"| node_map_layers
node_map_export -->|"exports results"| node_map_workflows
node_webmap -->|"loads basemaps"| node_map_tiles

click node_webmap "https://github.com/sametcanturhan/distributedgis/blob/main/index.html"
click node_map_workflows "https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js"
click node_map_layers "https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js"
click node_map_search "https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js"
click node_map_export "https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js"
click node_api "https://github.com/sametcanturhan/distributedgis/blob/main/backend/main.py"
click node_report_crud "https://github.com/sametcanturhan/distributedgis/blob/main/backend/crud.py"
click node_schemas "https://github.com/sametcanturhan/distributedgis/blob/main/backend/models.py"
click node_geojson "https://github.com/sametcanturhan/distributedgis/blob/main/backend/geojson.py"
click node_road_analysis "https://github.com/sametcanturhan/distributedgis/blob/main/backend/roads.py"
click node_weather_logic "https://github.com/sametcanturhan/distributedgis/blob/main/backend/weather.py"
click node_location_proxy "https://github.com/sametcanturhan/distributedgis/blob/main/backend/locations.py"
click node_db_session "https://github.com/sametcanturhan/distributedgis/blob/main/backend/database.py"
click node_report_model "https://github.com/sametcanturhan/distributedgis/blob/main/backend/db_models.py"
click node_spatial_db "https://github.com/sametcanturhan/distributedgis/blob/main/init.sql"
click node_road_importer "https://github.com/sametcanturhan/distributedgis/blob/main/osm2pgsql/roads.lua"

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_webmap,node_map_workflows,node_map_layers,node_map_search,node_map_export,node_visitor toneBlue
class node_api,node_report_crud,node_schemas,node_geojson,node_road_analysis,node_weather_logic,node_location_proxy toneAmber
class node_db_session,node_report_model,node_spatial_db,node_road_importer toneMint
class node_open_meteo,node_nominatim,node_map_tiles toneRose
```

## Components

### Map interface

- [Leaflet map](https://github.com/sametcanturhan/distributedgis/blob/main/index.html): `index.html`
- [Report workflows](https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js): `js/app.js`
- [Map layers](https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js): `js/app.js`
- [Location search](https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js): `js/app.js`
- [Data export](https://github.com/sametcanturhan/distributedgis/blob/main/js/app.js): `js/app.js`

### API and domain

- [FastAPI routes](https://github.com/sametcanturhan/distributedgis/blob/main/backend/main.py): `backend/main.py`
- [Report management](https://github.com/sametcanturhan/distributedgis/blob/main/backend/crud.py): `backend/crud.py`
- [Request and GeoJSON schemas](https://github.com/sametcanturhan/distributedgis/blob/main/backend/models.py): `backend/models.py`
- [Report GeoJSON](https://github.com/sametcanturhan/distributedgis/blob/main/backend/geojson.py): `backend/geojson.py`
- [Road snap and risk](https://github.com/sametcanturhan/distributedgis/blob/main/backend/roads.py): `backend/roads.py`
- [Weather lookup](https://github.com/sametcanturhan/distributedgis/blob/main/backend/weather.py): `backend/weather.py`
- [Search proxy](https://github.com/sametcanturhan/distributedgis/blob/main/backend/locations.py): `backend/locations.py`

### Spatial data

- [Database sessions](https://github.com/sametcanturhan/distributedgis/blob/main/backend/database.py): `backend/database.py`
- [Road report model](https://github.com/sametcanturhan/distributedgis/blob/main/backend/db_models.py): `backend/db_models.py`
- [PostGIS reports and roads](https://github.com/sametcanturhan/distributedgis/blob/main/init.sql): `init.sql`
- [OSM road importer](https://github.com/sametcanturhan/distributedgis/blob/main/osm2pgsql/roads.lua): `osm2pgsql/roads.lua`

### External services

- **Open-Meteo**
- **Nominatim**
- **Basemap tiles**

### Other components

- **Map user**

## Connections

- Map user → Leaflet map: uses (evidence: `README.md`)
- Leaflet map → Report workflows: hosts (evidence: `js/app.js`)
- Report workflows → FastAPI routes: requests (evidence: `js/app.js`)
- FastAPI routes → Report management: dispatches (evidence: `backend/main.py`)
- FastAPI routes → Road snap and risk: dispatches (evidence: `backend/main.py`)
- FastAPI routes → Weather lookup: dispatches (evidence: `backend/main.py`)
- FastAPI routes → Search proxy: dispatches (evidence: `backend/main.py`)
- FastAPI routes → Report GeoJSON: formats reports (evidence: `backend/main.py`)
- FastAPI routes → Request and GeoJSON schemas: validates responses (evidence: `backend/main.py`)
- FastAPI routes → Database sessions: opens sessions (evidence: `backend/main.py`)
- Report management → Road report model: creates and reads (evidence: `backend/crud.py`)
- Report management → Road snap and risk: snaps locations (evidence: `backend/crud.py`)
- Report management → Weather lookup: fetches weather (evidence: `backend/crud.py`)
- Report management → PostGIS reports and roads: persists reports (evidence: `backend/crud.py`)
- Road report model → Database sessions: uses base (evidence: `backend/db_models.py`)
- Report GeoJSON → Road report model: converts reports (evidence: `backend/geojson.py`)
- Road snap and risk → PostGIS reports and roads: queries spatial data (evidence: `backend/roads.py`)
- Database sessions → PostGIS reports and roads: connects to (evidence: `README.md`)
- OSM road importer → PostGIS reports and roads: imports roads (evidence: `README.md`)
- Weather lookup → Open-Meteo: requests forecasts (evidence: `backend/weather.py`)
- Search proxy → Nominatim: searches places (evidence: `backend/locations.py`)
- Location search → FastAPI routes: searches through (evidence: `README.md`)
- Map layers → FastAPI routes: loads weather and risk (evidence: `js/app.js`)
- Report workflows → Map layers: renders reports (evidence: `js/app.js`)
- Data export → Report workflows: exports results (evidence: `js/app.js`)
- Leaflet map → Basemap tiles: loads basemaps (evidence: `README.md`)
