plexus / map
CASE STUDY — OFFLINE-FIRST TOURING MAP, BACKEND INCLUDED

How Plexus Map works offline

Plexus Map is our offline-first hiking map — built for the Caucasus and Thuringia, where connectivity is a rumor. The whole map lives on the phone: vector tiles, terrain, routing graphs and tracks as verified packages. Behind it, a Spring Boot monolith runs a versioned geodata pipeline — OSM extracts in, Planetiler PMTiles and DEM derivatives out — and every byte is licensed, hashed and atomically published.

MapLibre Native PMTiles packages Planetiler pipeline Copernicus GLO-30 DEM GraphHopper profiles geodesic legs PostGIS catalog R2 object storage
geofabrik PBF→ pipeline jobs→ versioned release→ signed package→ a map that works offline
SCROLL ↓
01 — The idea

Why offline is the core requirement

Consumer map apps treat "offline" as a cache that might help. A touring map can't afford that: the route you plotted in a valley has to survive a ridge with zero bars. Offline is the product, not the fallback — the backend's real job is manufacturing self-contained regions: tiles, terrain, routing graph and license metadata bundled into one verifiable package. Download once, and every later request hits the phone's own storage.

Source data landsGeofabrik PBF · Copernicus GLO-30 COGs
Pipeline runs turn it into artifactsplanetiler → PMTiles · GDAL → hillshade/contours/slope
Releases assemble layers atomicallylicense gate: offlineAllowed=false layers never ship
The package reaches the phonemanifest + sha256 — verified, then activated
Everything works without a signaltiles, terrain profile, local routing, GPS tracks
// The honest constraint that shaped everything: OpenStreetMap's public tile servers forbid bulk download — so every layer the app ships offline is rendered from source data on our own pipeline. Licenses aren't a footer here, they're a gate in the release assembly itself.
02 — What the user sees

What the user gets

The product surface is a regional package and a map that never spins. Everything else — routes, tracks, drawn trails, elevation — syncs when it can and survives when it can't.

offline packages
Caucasus · vector + DEM + graph
Thuringia · vector + hillshade
Alps · vector + routing graph
sha256 verified · all-or-nothing activation

A region is one download

Each package bundles base vector tiles, terrain data and a routing graph with a manifest — checksums verified before activation, licenses attached to every layer.

schemaVersion'd manifest · sha256 per file · license gate
ridge trail14.2 km
+1 340 m ascentPCHIP profile
route: 2 graph-routed legs + 1 direct

Routes mix road and wilderness

A leg can follow the GraphHopper network — or go straight across open terrain on a geodesic line. Direct legs are first-class geometry, never snapped to roads that don't exist up there.

RouteLeg.mode · NETWORK_ROUTED / DIRECT_GEODESIC / FREEHAND · local GH
trail building
draw a path the map doesn't know
synced to your library · moderated

You can draw what's missing

Custom ways are user-drawn trails — sketched freehand on the map, stored server-side, synced to every device and reviewable against satellite imagery in the admin panel.

custom-ways sync · quadkey indexing · admin review
recording → gpx → library✓✓
GPS track · voice nav · floating map

Record, navigate, keep

Tracks record with the screen off and land in a GPX-exportable library. Navigation speaks turn-by-turn, and a floating minimized map keeps the route visible over other apps.

foreground service · Route ≠ Track · GPX export
03 — From idea to system

The constraints that shaped the stack

The stack wasn't designed on paper — each stage answered something that broke or was legally off-limits.

STEP 01

Tiles we may actually ship

Public OSM tile servers ban bulk and offline use — so the base map is built from Geofabrik PBF extracts through Planetiler into self-hosted PMTiles, with ODbL attribution carried in the style.

STEP 02

Terrain that reads like a map

Copernicus GLO-30 COGs become three products: terrain-RGB tiles for elevation queries, a multidirectional hillshade underlay, and contours + slope gradients through GDAL — each with its own projection pitfalls documented in the runbook.

STEP 03

Routing on both sides of the signal

The server runs GraphHopper for planned routes; the device runs a local graph inside each offline package for trails where there is no server to ask. Same profile set, two engines.

STEP 04

Packages become releases

Ad-hoc files turned into a pipeline: dataset → version → run → artifacts → release → manifest. A PACKAGE_BUILD job assembles everything in one transaction — a client never meets a half-built package.

STEP 05

The map learns to listen

Community reports, a consent-gated heatmap, user-drawn ways synced across devices, and an admin panel that can review a drawn trail against the same satellite layer the client sees.

04 — System architecture

The components and how they connect

All traffic enters through caddy on :443 behind Cloudflare: the SPA, static map assets, tile proxies and the API are routed by path, and /internal/* never reaches the backend. The geodata truth lives in PostGIS and object storage; GraphHopper runs as its own container because its memory profile doesn't share well.

Clients
Android · MapLibre Native
offline packages on device
local router · GPS recording
Web
map.plexus.ing SPA
same API · same session
routes & tracks in the browser
Object storage
Cloudflare R2
versioned artifacts
immutable · sha256'd
edge :443
caddy · cloudflare
/api → core · /map /tiles → static
/r2 /osm-raster /satellite → proxied
Fallback
upstream proxies
tile.openstreetmap.de · ArcGIS
world coverage · attribution kept
mapcore
Spring Boot monolith
auth · catalog · routes · tracks
ways · packages · sync · admin
database
PostgreSQL + PostGIS
catalog · users · ways
heatmap aggregates
routing
GraphHopper 11.1
own container
hiking · mtb · gravel · road
pipeline
job_queue workers
planetiler · OSM extract
package builds · DEM ingest

Dashed border = a separate host or service. The device never depends on the edge for an already-downloaded region — the whole right side can vanish and a packaged map still renders, routes and records.

05 — Inside the backend

How the backend is organized

The monolith splits into honest modules: the pipeline owns datasets and the workers that grind them; packages own what a client may download; routing and elevation serve live queries; ways and community own what users contribute back.

geodata pipeline

job_queue
  • dataset → version → run → artifact → release chain
  • Runs are declarative commands — argv, env, declared outputs
  • Same queue contract for in-process and external workers
  • Artifacts carry checksum, schema, sources, license, zoom range
Heavy stages never run in the request path — a run is a job_queue row with progress events, retries and a result projection onto the catalog.

package builder

atomic releases
  • PACKAGE_BUILD assembles files in a single transaction
  • Manifest carries bounds, zooms, license + attribution per layer
  • offlineAllowed=false layers are structurally excluded
  • Versions are immutable — a fix ships as a new release
The client verifies every file's sha256 before the package is activated — a torn download replaces nothing.

routing + elevation

live queries
  • RoutingProvider abstracts GraphHopper — swappable by ADR
  • Five profiles: hiking, trail_running, mtb, gravel, road
  • Direct legs interpolate on a spherical geodesic — never snapped
  • Terrain-RGB PMTiles sampled server-side for route profiles
Each region ships its own embedded graph in the package — the same profiles then run on-device with no backend at all.

ways + community

user data
  • Custom ways: drawn trails, quadkey-indexed, synced per user
  • Admin review sees the trail over real satellite imagery
  • Heatmap aggregates only opt-in tracks — sparse cells suppressed
  • Condition reports + abuse moderation close the loop
Coordinates are never logged — location is stored data, not telemetry. Consent withdrawal recomputes the heatmap.
06 — Follow one tile

What happens when a user downloads a region

A user in the mountains taps a region card. This is what actually happens to the byte that becomes their map — and which box it crosses on the way.

Geofabrik · source

The raw extract

It starts as an .osm.pbf — OpenStreetMap's planet, regionally sliced by Geofabrik. Roads, trails, springs, summits: everything, none of it styled.

mapcore · job

OSM_EXTRACT run

An admin posts a pipeline run: wget the PBF into a clean work-dir, declare it an artifact. The job queue owns the lifecycle — progress, timeout, retry.

worker · planetiler

PBF becomes PMTiles

Planetiler bakes the extract plus water/relief aux data into one vector archive — z0–14, ~160 MB in, a single seekable file out.

store · artifacts

Checksummed and shelved

Every output lands in the object store with a sha256, schema, source list, license and zoom range — a dataset version, immutable forever.

admin · release

Layers compose a region

A RegionRelease pins exact layer versions: base vector, DEM, hillshade, contours, slope, routing graph. Publication is atomic — the old release stays live until the new one verifies.

mapcore · build

PACKAGE_BUILD assembles

The manifest lists every file with its URL, bytes and sha256 — written in one transaction so no client ever sees half a package.

r2 · serve

Files go out, versioned

Artifacts serve from R2 under versioned prefixes — v2, v3 — because MapLibre caches a bare URL as fresh forever.

client · download

Verify, then activate

The app pulls each file, checks its sha256 against the manifest, and only then flips the package live — a torn download changes nothing.

device · render

The map is local now

MapLibre reads the PMTiles off disk; the DEM archive answers elevation for the route profile; the bundled graph answers routing.

the ridge

And the network leaves

Somewhere above the tree line the signal drops to nothing. Tiles, terrain, routing, track recording — everything keeps working, because the hard part already happened.

07 — The offline contract

What works offline and what does not

"Offline-first" is easy to claim and rare to specify. Here the boundary is architectural, not aspirational — everything in the left column needs nothing but the phone's storage.

Works at zero bars // on-device

  • Map render — vector tiles read from the local PMTiles
  • Routing — the package's own GraphHopper graph, same profiles
  • Elevation profile — terrain-RGB sampled from the local DEM
  • GPS recording + GPX library — straight to Room, sync later

Needs a signal // the edge

  • Package downloads, style.json refresh, raster fallback
  • Server routing for cross-region plans and alternatives
  • Sync: routes, tracks, custom ways, community layers
  • Auth, search and anything the user hasn't downloaded yet
// The rule that makes the split hold: a Route is not a Track. Plans sync as route documents; recordings live as tracks. They never blur, so an offline hike records locally and reconciles later without a merge war.
08 — Release lifecycle

Every change ships as a new immutable version

A region is never "updated in place" — every change is a new immutable version moving through the same four stations, so a bad render can be rolled back, not hot-patched.

ingest

new source
  • Source registered first: license, attribution, offline rights
  • OSM_EXTRACT / DEM_INGEST runs fetch into declared artifacts
  • Each download verified — S3 errors fail the run, not the QA

derive

processing
  • PLANETILER runs PBF → PMTiles with explicit aux paths
  • GDAL one-offs build hillshade, contours, slope overlays
  • Every derivative records its inputs and parameters
  • QA gates publish: tile decode checks, summit spot-checks
Projection discipline is written down where it burned us: slopes in UTM, never Web Mercator; contours from a mosaicked DEM, never per-tile.

publish

release
  • RegionRelease pins layer versions — atomic activation
  • Manifest lists files, sha256, license per layer
  • Tile updates ship under new version prefixes — no cache lies
  • Client migrates forward; rollback is the previous release

retire

superseded
  • Old versions marked replaced once clients verify the new
  • Rollback period passes → artifacts eligible for cleanup
  • Catalog keeps provenance — which run made which file
  • Licenses stay attached to data even after retirement
A release is rollbackable by construction: nothing mutates under a live version, so reverting is a pointer move.
09 — What the server knows

What the manifest guarantees

A package's whole promise fits in one document: which files, how big, which hashes, which licenses. Everything else — the map, the routes, the trust — descends from it:

GET /api/v1/packages/caucasus/manifest — the whole contract
{
  "packageId": "caucasus", // region, versioned
  "layers": [ osm-base, dem, graph ], // each with license + attribution
  "files": [ { url, bytes, sha256 } ], // verified before activation
  "offlineAllowed": true // a license gate, not a courtesy
}
a layer without offline rights → structurally absent from the package
the client checks every hash — a torn download activates nothing
what the server logged about your hike nothing — coordinates are stored data, never telemetry.
license

Legal by construction

No layer ships offline without offlineAllowed in the source register — compliance is a pipeline gate, not a footer disclaimer.

integrity

sha256 before activation

Every file's hash rides in the manifest; the client verifies all of them before a package goes live — partial state can't leak in.

privacy

Location is data, not logs

Coordinates and tracks are stored rows a user owns — they are never written to server logs or sent to analytics.

honesty

Routes and tracks stay separate

A plan and a recording are different entities with different lifecycles — the sync layer never has to guess which one wins.

10 — Production

How the service is deployed

The edge block runs on the shared Plexus host under /opt/plexus: the monolith, its GraphHopper and Postgres in compose, static map assets as bind mounts, the heavy data in R2. Data releases ship separately from code deploys — a region can be republished without touching a container.

source lands
pbf · dem cogs
→
run grinds
job_queue worker
→
release publishes
atomic, licensed
→
client verifies
sha256, activate
→
map works
with or without signal

the edge

caddy + mapcore
  • Path-split: SPA + static assets, /api → mapcore, /r2 → storage
  • /internal and non-health /actuator → 404 at the edge
  • Rate limits on compute endpoints — per real client IP
  • Trusted-proxies = docker net + CF ranges, else buckets split
respond sorts after handle in adapted config — the 404 shields are matcher-scoped handles, or the SPA fallback swallows /internal/* into index.html first.

the data

R2 + static vol
  • Packages and tile pyramids under versioned R2 prefixes
  • style.json, glyphs, sprites — bind-mounted static, no rebuild
  • Hillshade/contours/slope TileJSONs served next to the app
  • DEM archives loaded at boot — a node serves what it hosts
Updating the style needs no app release — the client refetches style.json on start; regenerated tiles get a new version path because cached URLs never invalidate.
11 — Technical details

What exactly was built

Client
MapLibre Native AndroidRoom · Coroutines · Compose
Vector tiles
Planetiler → PMTilesGeofabrik PBF · ODbL attribution
Terrain
Copernicus GLO-30terrain-RGB · hillshade · contours · slope
Routing
GraphHopper 11.15 profiles · own container · on-device graphs
Legs
NETWORK_ROUTED · DIRECT_GEODESIC · FREEHANDspherical interpolation · never snapped
Backend
Spring Boot · modular monolithcatalog · packages · ways · sync · admin
Data
PostgreSQL + PostGISFlyway · spatial catalog · aggregates
Pipeline
job_queuedataset→version→run→artifact→release
Storage
Cloudflare R2versioned prefixes · sha256 manifests
Packages
schema'd manifestlicense gate · atomic activation
Privacy
no location telemetrycoordinates never logged · consent heatmap
Ops
Docker Composemanual deploy · data releases decoupled