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

Map-data fetch → proprietary crime-density 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 → density 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

A principled, carefully-tuned model.

The routing logic is a small set of deliberate rules, tuned over real South African routes, that decide when a detour is worth it and when it isn’t.

What triggers a detourOnly higher-risk areas; caution-level zones are shown, never forced
Route checkThe route is sampled and tested against every active zone for the current time
Corridor awarenessRecognises when a route already runs a known-safe corridor, and leaves it be
Detour limitsBypasses are capped so they never wander unreasonably far from the direct line
Corridor selectionOnly nearby safe corridors are used to steer around a risk area
Sanity checkAny detour that ends up excessively longer than direct is rejected. You get the direct route, clearly flagged
Time-awareSeparate risk weighting for daytime, evening and night

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), because 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, Ekurhuleni and the West Rand), Cape Town, Stellenbosch and Secunda. Mapped metros: Johannesburg · Cape Town · Pretoria · Ekurhuleni · West Rand · Secunda · Stellenbosch. Adding a new city is a documented, repeatable runbook, not a rewrite.

7metros mapped
3,254risk zones
2,083safe 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.