The Problem
Clients that need turnâbyâturn routing, isochrones, distance matrices, or raw OSMâbased graph exports must either rely on commercial SaaS APIs or build a bespoke routing stack. Maintaining a selfâhosted, standardsâcompliant service that can be tuned to local data and deployed in containers is nonâtrivial.
What This Does
The repository is a portfolio of four Maven projects that together deliver a complete routing platform:
ors-engineâ the core graphâhopperâderived routing engine (ââŻ550 files). It builds and queries the road network, exposing Java APIs used by the API layer.ors-apiâ a SpringâBoot REST façade (ââŻ230 files). Controllers such asExportAPI.java,MatrixAPI.javaandMatchingAPI.javareceive HTTP requests, validate parameters, and forward them to the engine.ors-benchmarkâ a small benchmark harness (ââŻ52 files) for measuring request latency under different configurations.ors-testâscenariosâ curated OSM extracts and expected results used by the integration test suite (ââŻ21 files).
Documentation lives under docs/ (VitePress site) and Docker build logic under Dockerfile, .rpmâpackaging/Dockerfile, and dockerâcompose.yml.
How It Is Wired
Execution starts with the Spring Boot main class packaged in ors-api (the exact class is not listed but is the standard org.heigit.ors.Application). Maven builds the three modules and assembles a runnable JAR.
- HTTP entry â
org.heigit.ors.api.controllers.*(e.g.,ExportAPI.java,MatrixAPI.java). Each controller parses request bodies, appliesApiConfig/OpenAPIConfigsettings, and calls the corresponding service in the engine. - Engine call â Controllers invoke methods in
ors-engine(e.g.,RoutingEngine.calculateRoute). The engine loads the preâprocessed OSM graph from the data directory (referenced inors-config.jsoninside.rpmâpackaging). - Result serialization â Engine returns POJOs that the controller converts to JSON using Jackson and writes to the HTTP response.
- Auxiliary services â Health and status endpoints (
/health,/status) are implemented in the same controller package but are not exposed by the public live API.
The two Maven modules have no import cycles (static analysis reports 0 circular dependencies). The only crossâmodule dependency is ors-api â ors-engine; no other internal module imports exist, keeping the call surface small.
How To Use It
# 1. Clone the exact upstream repository
git clone https://github.com/moses-y/openrouteservice.git
cd openrouteservice
# 2. Build all modules with Maven (requires JDK 11+)
mvn clean install -DskipTests # skipTests optional; CI runs them separately
# 3. Run the service locally (Docker is the recommended production mode)
docker compose up -d # uses docker-compose.yml, builds the image
# or, run the jar directly
java -jar ors-api/target/ors-api-*.jar
Configuration lives in ors-config.json (packaged under .rpm-packaging/ors-config.json). Adjust graph.location, router.default_profile, and any API keys there before starting the container or jar. No additional environment variables are required by the code itself.
RealâWorld Use
A logistics platform can spin up the image from Docker Hub (heigit/openrouteservice) or build locally, point ors-config.json at a countryâlevel OSM extract, and issue HTTP POSTs to /v2/directions/foot-walking for realâtime routing. The same instance can serve /v2/isochrones to compute delivery zones, while the benchmark module can be used to size the deployment for expected query volume.
Code Health & Issues
Measured findings (static analysis)
- High â Deep nesting in several API controllers (e.g.,
ExportAPI.java,MatchingAPI.java,MatrixAPI.java). Indentation depthâŻ10 makes the flow hard to follow. - High â Duplicated code blocks across
APIEnums.java,ApiConfig.java,OpenAPIConfig.java, and several controllers (ââŻ1âŻ846 repeated 6âline snippets). - High â Oversized test files (
ParamsTest.java,ResultTest.java) each >âŻ1âŻ600 lines, risking brittle changes.
Codeâhealth audit
- HIGH â CI never runs the test suite (see
.github/workflows/*.yml). Add amvn teststep. - MEDIUM â Workflows lack leastâprivilege
GITHUB_TOKENpermissions; addpermissions: contents: read. - MEDIUM â No Dependabot/Renovate configured; add
.github/dependabot.yml. - MEDIUM â Base image
tomcat:9.0.75is unpinned; use a digest. - MEDIUM â No dependencyâvulnerability scan in CI; add
dependency-review-actionorosv-scanner. - MEDIUM â Large binary (
srtm_38_03.gh, 69âŻMB) stored in Git; move to GitâŻLFS or external storage. - MEDIUM â Dockerfile runs as root; create a nonâroot
USER. - LOW â Workflow jobs lack
timeout-minutes; set explicit limits.
No critical or license issues were detected; the repository includes a LICENSE, CI, Dockerfiles, and tests.
The Bottom Line
The repo delivers a mature, selfâhostable routing service with a clear separation between engine and API layers, but the codebase suffers from deep nesting, duplicated snippets, and an underâutilized CI pipeline. It is suitable for teams that need full control over routing data and are prepared to address the highlighted maintainability and security gaps.