A safe-route navigation system. SafePath finds walking routes that balance distance against real-world safety — combining crime density, street lighting, and crowd-sourced user reports into a single routing weight, so the "best" route isn't just the shortest one, but the safest sensible one.
Course project — PBL3, Group H.
- Safety-aware routing — a custom GraphHopper weighting blends crime, lighting, and user reports instead of optimising for distance alone.
- Crime heatmaps — Kernel Density Estimation (KDE) over historical crime data, served to the client as a compressed heatmap overlay.
- Lighting maps — a bright/dark overlay built from municipal streetlight data.
- Crowd-sourced reports — users submit and verify safety reports that feed back into route weighting.
- Gamification — points, badges, levels, and a leaderboard to reward
participation (see
docs/gamificationreport.md). - Multi-city — ships with Boston and Philadelphia support.
| Layer | Technology |
|---|---|
| Backend | Java (built-in com.sun.net.httpserver), GraphHopper 11 routing engine |
| Frontend | React 19 + TypeScript, OpenLayers maps, bundled with webpack |
| Data pipeline | Python scripts for crime KDE + streetlight processing |
PBL3GROUPH_SafePath/
├── Backend/ # Java backend
│ ├── *.java # Server, Routing, WeightCombiner, Crime, Lighting, ...
│ ├── data/ # Datasets (large data git-ignored — see Backend/data/README.md)
│ ├── lib/ # graphhopper-web-11.0.jar
│ └── scripts/ # Python data-processing pipeline
├── Frontend/ # React + TypeScript client
│ └── src/ # App.tsx, index.tsx, ...
├── Startup/ # RunAll.java — application entry point
├── Tests/ # Java + JS tests
├── docs/ # SRS, gamification report, UML diagrams, notes
├── run.cmd # Cross-platform build & run script
└── README.md
- JDK 17+ (
javac/javaon your PATH) - Node.js 18+ and npm
- No data download required. The prebuilt routing graph (
graph-cache/) and the safety inputs (kde_grid.byte,streetlights_processed.csv) are committed, so the app runs out of the box. Only the large raw source datasets are excluded — see Backend/data/README.md if you want to regenerate them.
The run.cmd script compiles the Java sources, installs frontend dependencies,
and launches the server. It works on Windows, Linux, and macOS (Intel + ARM).
# macOS / Linux — make it executable once
chmod +x run.cmd
# Start SafePath for a city
./run.cmd --city boston
# or
./run.cmd --city philadelphiaOn Windows, run run.cmd --city boston from the project root.
Then open the app in your browser:
http://localhost:3000/
The backend API listens on http://localhost:8080 (configurable in
Frontend/config.js).
Server.java ──► Routing.java ──► WeightCombiner.java ──┬─► Crime.java ──► Crime_KDE.java ──► Crime_KDE_Heatmap.java
(HTTP) (GraphHopper) (combined weight) ├─► Lighting.java ──► Lighting_Lightmap.java
└─► UserReports.java
Logging.java (error logging, per SRS REQ-OBS-001)
Server.java— HTTP server; receives GET/POST, calls routing, returns responses.Routing.java— GraphHopper init, custom weighting, route computation.WeightCombiner.java— merges lighting, crime, and user-report scores into one weight.Crime.java/Crime_KDE.java— crime scoring via Kernel Density Estimation.Lighting.java— streetlight-based lighting weight.UserReports.java— stores/loads user safety reports.
Full details are in docs/project-notes.txt and the
Software Requirements Specification. UML diagrams live
in docs/diagrams/.
- Software Requirements Specification
- Gamification report
- Project & architecture notes
- UML diagrams
- Data setup & regeneration
Java and JavaScript tests live in Tests/ (route comparison, safety
cost, reporting, logging, and performance tests). They are compiled alongside the
backend by run.cmd.