Skip to content
Ramlols2604Public

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WayAware

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.

Backend

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 .env

Set 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 .
pytest

Run the API:

uvicorn app.main:app --reload --port 8000

GET /health returns {"status": "ok"}.

Destination search

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.

CORS

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.

Frontend

From frontend/, using Node 22 and pnpm:

pnpm install

Copy the environment template:

cp .env.example .env

Set 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 dev

Build and test:

pnpm build
pnpm test

The backend must be running (see above) with MAPBOX_ACCESS_TOKEN set for destination search, place selection, and route rendering to work end to end.

Deployment (DigitalOcean App Platform)

  • 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 on 0.0.0.0:${PORT:-8080}).
  • Environment variables: set MAPBOX_ACCESS_TOKEN as 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) in app/main.py to the deployed frontend's real URL once one exists; keep it an exact origin, no wildcard.

About

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.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages