reports#
Crime & safety data products by neighbourhood with tiered access (snapshot, subscription, premium, professional), Stripe checkout, token-based downloads, and dataset management.
Models#
Model |
Description |
|---|---|
|
One-time or subscription purchase granting crime data access |
|
Idempotency record for reports-specific Stripe webhooks |
|
Purchasable dataset with R2 storage path and Stripe product/price mappings |
|
Grants a user/email access to a specific dataset |
URL Routes#
Path |
View |
Description |
|---|---|---|
|
|
Index of available crime reports |
|
|
Full crime dashboard (requires access) |
|
|
Interactive crime map |
|
|
Detailed statistics |
|
|
Incident listing |
|
|
Safety guide |
|
|
Free preview JSON (limited) |
|
|
GET pricing options |
|
|
POST create Stripe checkout |
|
|
Post-purchase success |
|
|
Check current access status |
|
|
Token-based data download |
|
|
Manage data subscription |
Management Commands#
Command |
Description |
|---|---|
|
Create new crime dataset records |
|
Update dataset pricing, status, or metadata |
|
Migrate legacy |
Access Model#
Data Taxonomy System#
The reports app includes a data taxonomy that provides machine-readable metadata
for all data products. Each product is described by a DataProductManifest containing
one or more DatasetMetadata sub-datasets.
Data Class Taxonomy#
Class ID |
Colour |
Description |
|---|---|---|
|
🟢 Green |
Event / incident data (daily cadence) |
|
🔵 Blue |
Aggregated official statistics (quarterly) |
|
⚪ Grey |
Slow-changing reference data (yearly+) |
|
🟡 Amber |
Derived rolling-window metrics |
|
🟡 Amber |
Derived quarterly calculations |
|
🟡 Amber |
Derived cumulative KPIs |
|
🟣 Purple |
Assembled composite of sub-datasets |
|
🟣 Purple |
Weekly point-in-time snapshot |
|
🟢 Green |
Near-real-time status feed |
|
🔵 Blue |
Time-series history of live data |
|
🔵 Blue |
Aggregated market data |
Registered Products#
Product |
Slug |
Registry file |
Sub-datasets |
|---|---|---|---|
Sea Point Crime & Safety |
|
|
7 |
Cape Town Dam Levels |
|
|
4 |
SA Loadshedding Status |
|
|
5 |
Cape Town Ward Crime & Safety |
|
|
7 |
Cape Town Housing Market |
|
|
7 |
Architecture#
Each registry file defines:
Identity — name, slug, source, description
Classification —
DataClassIDenum valueUpdate schedule — cadence, staleness threshold, cache TTL
Refresh mechanics — incremental vs full, lookback window, backfill policy
Dependencies — other sub-datasets that must run first (topological sort)
Storage paths — R2 key, R2 history path, local fallback path
Pipeline integration — management command to run
Adding a new product#
Create
reports/<slug>_registry.pywithDatasetMetadatainstances and aDataProductManifestRegister it in
reports/manifest_registry.py→_build_registry()The admin taxonomy page automatically discovers it
Key Design Decisions#
Dataset stores dual Stripe IDs (test/live) and R2 bucket/path for direct cloud access.
DatasetAccess unifies one-time purchases and subscription-based access behind a single token-based download mechanism.
Legacy migration:
CrimeDataPurchaseis the original model;Dataset+DatasetAccessare the newer abstraction. The migration command bridges the two.Free preview: The
/api/endpoint returns limited data without authentication, encouraging conversion to paid access.