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 is how the pieces fit.

The stack

Proven tools, boring in a good way

React Native and Expo
Cross-platform app, New Architecture enabled. Expo Router for navigation, EAS for builds and over-the-air updates.
Mapbox
Map tiles, the Directions API for routing, and Geocoding for naming the place you tap on the map. Search itself runs on Google Places.
Supabase and PostGIS
Postgres with PostGIS geometry holds every rated area and road. The app reads it live; the editor writes through typed RPC functions.
Python data pipeline
Map data fetched, scored for crime density, classified into rated areas and roads, staged, then promoted to live.
Claude review
An AI second opinion on the ratings, researched against local reporting. A person then sense-checks the results and looks closely at any rating that stands out.
GitHub and EAS
Versioned SQL migrations keep the database reproducible; TestFlight and Google Play open testing get 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.

  1. 01 · Sources

    OpenStreetMap, published SAPS crime statistics, drivers' reports

  2. 02 · Pipeline

    Fetch, score for density, classify areas and roads, stage

  3. 03 · Review

    A Claude second opinion, then a person sense-checks what stands out

  4. 04 · Live database

    Rated areas and roads in Supabase (PostGIS)

  5. 05 · App

    Tsamaya reads it live and plans the route

The routing model

How a detour gets decided

A small set of deliberate rules, tuned over real South African routes, that decide when a detour is worth it and when it is not.

What triggers a detour
Only higher-risk areas. Caution-level areas are drawn on the map but never trigger a detour.
Route check
The route is sampled and tested against every active area for the current time.
Checked roads
Recognises when a route already runs along a road we have checked, and leaves it be.
Detour limits
Bypasses are capped so they never wander unreasonably far from the direct line.
Choosing a way round
Only nearby checked roads are used to steer around a high-risk area.
Sanity check
Any detour that ends up excessively longer than the direct route is rejected. You get the direct route, clearly flagged.
Time-aware
Separate ratings for daytime, evening and night.

Walk through the steps

Data model

Rated areas and roads

Rated areas

Polygons

Each has a name, a city, a rating for each of the three time bands, crime types and a source. Soft-deleted, never hard-deleted, so history can be recovered.

red · orange · yellow · none

Rated roads

Line strings

Each has a buffer width and marks a road as checked (preferred when threading past risk), flagged (avoided where there is a sensible way round) or closed (gated or impassable, so routed around without being counted as risk). The stored values are safe, danger and blocked: a checked road is one we have reviewed, not a promise about it. Identity is always (city, name), because road names repeat across metros.

checked · flagged · closed

Geometry is stored as PostGIS geometry and written through ST_SetSRID(ST_GeomFromGeoJSON(...), 4326) RPCs, since PostgREST cannot cast GeoJSON to geometry by itself.

Coverage

Where Tsamaya works today

Live across Gauteng (Johannesburg, Pretoria, Ekurhuleni and the West Rand), Durban, Pietermaritzburg, Gqeberha, East London, Port Alfred, Mthatha, Cape Town and Stellenbosch, Rustenburg and Pilanesberg, Mossel Bay and George, Beaufort West, Secunda, eMalahleni and Middelburg, Bloemfontein with Botshabelo and Thaba Nchu, Polokwane, and Kruger National Park with Mbombela and the Lowveld. Adding a city follows a documented runbook, which is how the map went from one city to 22 places.

22 Places mapped
6 649 Rated areas
2 931 Checked road stretches
3 Time bands

Coverage by place

Talk shop

Curious, or want to help build it?

We are always glad to talk shop, or to find sponsors who want to fund the next metro.

Get in touch Sponsor a metro