Technical details

Under the hood.

Tsamaya is a React Native app backed by a geospatial database and a Python data pipeline with a Claude-assisted review step. Here’s how the pieces fit.

The stack

Built on proven, boring-in-a-good-way tools.

React Native + Expo

Cross-platform app, New Architecture enabled. Expo Router for navigation, EAS for builds and over-the-air updates.

Mapbox

Map tiles, Directions API for routing, and Geocoding for search and reverse-geocoding the map.

Supabase + PostGIS

Postgres with PostGIS geometry holds every zone and corridor. The app reads live; the editor writes via typed RPC functions.

Python data pipeline

OpenStreetMap fetch → crime-density (KDE) scoring → zone/corridor classification → staging → promotion to live.

Claude review

A second-opinion review pass flags questionable classifications for a human before anything reaches drivers.

GitHub + EAS

Versioned SQL migrations keep the database reproducible; TestFlight distributes builds to testers.

Three repos, one system

How data becomes a route

Crime and map data flow through a pipeline, get reviewed, then go live for the app to read.

SourcesOpenStreetMap · SAPS crime stats · local knowledge
PipelineFetch → KDE scoring → classify zones & corridors → stage
ReviewClaude second-opinion + human approve/reject
Live DBSupabase zones & corridors (PostGIS)
AppTsamaya reads live, plans the route on-device

The routing model

Tuned thresholds keep detours honest.

The routing logic isn’t a black box — it’s a small set of explicit, tunable rules that decide when a detour is worth it and when it isn’t.

Risk bands that detourRed & orange only — yellow is shown, never forced
Route samplingEvery 3rd coordinate, ray-cast vs. all active zones
Corridor snap tolerance≈ 650 m (pass-through detection)
Max lateral deviation15% of route length, capped at 5 km
Corridor search radiusWithin 8 km of the danger area
Bypass waypointsUp to 2 injected per route
Detour reject rule> 30% longer than direct → serve direct, flagged
Time bandsDay 05–18 · Evening 18–22 · Night 22–05

Data model

Zones and corridors

Risk zones

Polygons with a name, city, three time-band risk levels, crime types, and a source. Soft-deleted (never hard-deleted) so history is recoverable.

red · orange · yellow

Corridors

LineStrings with a buffer width that mark roads as safe (preferred when threading past risk) or danger (actively avoided). Identity is always (city, name) — road names repeat across metros.

safe · danger

Geometry is stored as PostGIS and written through ST_SetSRID(ST_GeomFromGeoJSON(…), 4326) RPCs, since PostgREST can’t auto-cast GeoJSON to geometry.

Coverage

Where Tsamaya works today

Live across Gauteng (Johannesburg, Pretoria, the East & West Rand) and Cape Town. Mapped metros: Johannesburg · Pretoria · Cape Town · East Rand · Secunda — and adding a new city is a documented, repeatable runbook, not a rewrite.

5metros mapped
2,500+risk zones
1,100+safe corridors
3risk bands by time of day

Curious, or want to help build it?

We’re always glad to talk shop — or to find sponsors who want to fund the next metro.