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
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
Three repos, one system
Crime and map data flow through a pipeline, get reviewed, then go live for the app to read.
01 · Sources
OpenStreetMap, published SAPS crime statistics, drivers' reports
02 · Pipeline
Fetch, score for density, classify areas and roads, stage
03 · Review
A Claude second opinion, then a person sense-checks what stands out
04 · Live database
Rated areas and roads in Supabase (PostGIS)
05 · App
Tsamaya reads it live and plans the route
The routing model
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.
Data model
Rated areas
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
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
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.
Talk shop
We are always glad to talk shop, or to find sponsors who want to fund the next metro.