Crime-aware NYC navigation for walking and driving. Visualizes historical crime patterns and available incident reports along your route, provides voice alerts, and compares alternatives by travel time and modeled exposure.
From backend/, using Python 3.12:
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"Copy the environment template and add your Mapbox token:
cp .env.example .envSet MAPBOX_ACCESS_TOKEN in backend/.env to a Mapbox access token. Without
it, /health and app startup are unaffected, but /places/search and
/places/{mapbox_id} return 503.
Check and test:
ruff check .
ruff format --check .
pytestRun the API:
uvicorn app.main:app --reload --port 8000GET /health returns {"status": "ok"}.
GET /places/search?q=<text>&session_token=<uuid4> returns NYC-area address
and point-of-interest suggestions from the Mapbox Search Box API. The search
area is a bounding rectangle around the five boroughs plus margin — it is not
an exact city boundary, so results can include nearby non-NYC places and may
clip parts of the city near the edges.
GET /places/{mapbox_id}?session_token=<uuid4> resolves a suggestion (its
mapbox_id) into coordinates and address details.
session_token must be a UUIDv4 generated by the frontend. Reuse the same
token across one search (/search calls as the user types) and the
selection that follows (/{mapbox_id}), then generate a new token for the
next search — this matches Mapbox's session-based billing model.
Both endpoints return a Mapbox attribution string that must be displayed
alongside results.
The backend allows browser requests from http://localhost:8443 (the
frontend's Vite dev server default port) for GET/POST with a
Content-Type header, no credentials. This is the only origin currently
allowed; add further origins in app/main.py as real frontend deployments
exist.
From frontend/, using Node 22 and pnpm:
pnpm installCopy the environment template:
cp .env.example .envSet VITE_API_BASE_URL in frontend/.env to the running backend's URL
(http://localhost:8000 for local development against uvicorn --port 8000). VITE_MAPBOX_PUBLIC_TOKEN can stay blank — the map's base tiles come
from OpenFreeMap, not Mapbox, and the app never needs a Mapbox token
client-side; all Mapbox calls happen server-side in the backend.
Run the dev server (must match the backend's allowed CORS origin, port
8443):
pnpm devBuild and test:
pnpm build
pnpm testThe backend must be running (see above) with MAPBOX_ACCESS_TOKEN set for
destination search, place selection, and route rendering to work end to end.
- Source directory:
backend/ - Build: Dockerfile (
backend/Dockerfile) — App Platform detects and builds it automatically; no buildpack configuration needed. - HTTP port:
8080(App Platform's default expected port; the container listens on0.0.0.0:${PORT:-8080}). - Environment variables: set
MAPBOX_ACCESS_TOKENas an encrypted App Platform secret. It is only read server-side (app/config.py) and is never sent to clients. - Health check:
GET /health— already returns{"status": "ok"}with no dependencies, so it can be used as-is as the App Platform health check path. - CORS: configured for local development only (
http://localhost:8443, see above). Update the allowed origin(s) inapp/main.pyto the deployed frontend's real URL once one exists; keep it an exact origin, no wildcard.