Skip to main content

Architecture

System context


Container diagram


Key modules

Backend (app/)

ModulePathResponsibility
App factoryapp/factory.pyApp assembly — routers, static files, startup lifespan
Aggregate routerapp/api/routes/grass.pyMounts all sub-routers under /grass
Environment registryapp/services/env_registry.pyGRASS environment lifecycle, Redis sync, disk persistence
GRASS runtimeapp/services/grass_runtime.pyAsync subprocess execution, mapset locking
Routing clientapp/services/routing/client.pyValhalla HTTP proxy
Curvature serviceapp/services/curvature/road_db.py query, pop_density.py grid lookup, kmz_ingest.py pipeline
Terrain builderapp/services/terrain_builder.pyQuantized-mesh tile generation via mago-3d-terrainer
WFS serviceapp/wfs_service.pyMapServer WFS integration + vector info cache
POI databaseapp/db/osm_poi.pyPostGIS POI query helpers
Route storageapp/db/routes.pyPostGIS route CRUD, GPX/GeoJSON export
Schema migrationapp/db/migrate.pyensure_schema() at startup — routes + osm_poi tables
Authapp/auth/API key issuance, X-API-Key validation, web session middleware

Route modules (all mounted at /grass/…)

FilePrefixPurpose
environments.py/grass/envCreate / list / delete GRASS environments
layers.py/grass/env/{id}/layersLayer metadata and WMS/WFS layer management
profile.py/grass/env/{id}/profiler.profile transect execution
histogram.py/grass/env/{id}/histogramr.stats histogram execution
analysis_artifacts.py/grass/artifactsSave / load / delete profile+histogram results
terrain.py/grass/env/{id}/terrainTerrain build + list + delete
vector_edit.py/grass/env/{id}/veditVector digitise, move, attribute write
db_manager.py/grass/env/{id}/dbSQLite + PostgreSQL table inspection
routing.py/grass/routingValhalla route, isochrone, matrix, loop, speed cameras, POI
routes_manager.py/grass/routing/routesSave / load / delete / export routes
location.py/grass/routing/locationLive group position sharing
curvature.py/grass/curvatureCurvy-road DB query and precomputed analysis
elevation.py/grass/elevation/sampleGRASS-free elevation sampling along any polyline — best national DEM auto-selected, OpenTopoData fallback
field_sessions.py/grass/env/{id}/field-sessionsMobile field session registry (Redis-backed)
data_packs.py/grass/data-packsRegion management + background rebuild jobs
tiles.py/grass/tiles1°×1° SQLite tile catalog + download

Frontend (app/static/grass_runner/js/)

ModuleResponsibility
main.jsEntry point — wires toolbar, panels, tool modules
state.jsShared reactive state (connection, env, active module)
cesium-layers.jsLayer registry, WMS/WFS add/remove, drag-and-drop order
session-state.jsCollect / restore full app state
session-ui.jsNamed workspace save/load UI
profile-tool.jsProfile line drawing and r.profile execution
histogram-tool.jsBounding-box drawing and r.stats execution
vector-edit.jsVector digitise, move, vertex edit, attribute write
db-manager.jsDB Manager UI (SQLite + PostgreSQL inspection)
picker.jsr.what / v.what identify tool, cluster interaction
region.js / region-draw.jsComputational region management

Mobile app (mobile-app/)

PathResponsibility
app/(tabs)/navigate.tsxNavigation/map screen — routing, POI, curvy-road discovery, offline packs
app/(tabs)/capture.tsxField capture screen — GPS track, samples, sync
app/(tabs)/profile.tsxElevation profile tab — GRASS r.profile transect tool wired to stores
app/(tabs)/more.tsxSettings, connection, environment management, analyses viewer
src/stores/Zustand stores: connection, environment, location, profile, field-capture, tile-packs, settings
src/modules/navigation/Sheets: plan-route, loop-route, curvy-roads (inline elevation charts), offline-packs
src/modules/profile/ProfilePanels, ProfileChart (Skia), profileStore, useElevationProfile hook
src/modules/field-capture/Session management, sync handlers, pull service
src/modules/map/MapLibre layer model, FieldCaptureMap, FieldMapPanel
src/lib/fastgis-client.tsHTTP API client — all backend endpoints including elevation sampling
src/lib/tileGrid.ts1°×1° tile math: coordinate → tile ID, bbox, routeToTileIds
src/lib/curvatureDb.tsOffline curvature queries — tiled and monolithic SQLite
src/lib/poiDb.tsOffline POI queries — tiled SQLite
src/lib/resetAppData.tsWipe all cached offline data (tiles, curvature DB, cached routes) keeping credentials and user data

Data flow: running a GRASS module


Offline data pipeline


Session persistence