{"id":16999164,"url":"https://github.com/pintowar/opta-router","last_synced_at":"2025-03-17T09:30:45.672Z","repository":{"id":37734694,"uuid":"120393481","full_name":"pintowar/opta-router","owner":"pintowar","description":"Sample CVRP Application using Kotlin + Optaplanner/Timefold/Jsprit/Or-Tools/Jenetics + Graphhopper + Spring Boot + Apache Camel + Jooq + Websockets","archived":false,"fork":false,"pushed_at":"2024-08-24T01:32:26.000Z","size":1545,"stargazers_count":41,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-27T21:50:26.983Z","etag":null,"topics":["docker","graphhopper","jenetics","jsprit","kotlin","optaplanner","or-tool","spring-boot","websocket"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pintowar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-06T02:57:37.000Z","updated_at":"2025-02-17T01:22:05.000Z","dependencies_parsed_at":"2024-01-03T02:22:29.706Z","dependency_job_id":"e582d475-b454-4d35-8e74-a3ac31a33f5b","html_url":"https://github.com/pintowar/opta-router","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pintowar%2Fopta-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pintowar%2Fopta-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pintowar%2Fopta-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pintowar%2Fopta-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pintowar","download_url":"https://codeload.github.com/pintowar/opta-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858811,"owners_count":20359257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","graphhopper","jenetics","jsprit","kotlin","optaplanner","or-tool","spring-boot","websocket"],"created_at":"2024-10-14T04:07:28.038Z","updated_at":"2025-03-17T09:30:44.488Z","avatar_url":"https://github.com/pintowar.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Opta Router Boot\n\n![master status](https://github.com/pintowar/opta-router/actions/workflows/master.yml/badge.svg?branch=master)\n\n![GitHub tag (latest)](https://img.shields.io/github/v/tag/pintowar/opta-router)\n![GitHub license](https://img.shields.io/github/license/pintowar/opta-router)\n\nSample CVRP Application using Kotlin + Optaplanner/Timefold/Jsprit/Or-Tools/Jenetics + Graphhopper + Spring Boot + Apache Camel + Jooq + Websockets\n\n## What is CVRP?\n\nCVRP is a variation of VRP (Vehicle Routing Problem). VRP is a combinatorial optimization problem which asks \"What is the optimal set of routes for a fleet of vehicles to traverse in order to deliver to a given set of customers?\".\n\nOn CVRP (Capacitated Vehicle Routing Problem), the vehicles have a limited carrying capacity of the goods that must be delivered and customers have a given demand.\n\nDetermining the optimal solution to VRP is NP-hard, so the size of problems that can be optimally solved using mathematical programming or combinatorial optimization may be limited. Therefore, commercial and open source solvers tend to use heuristics due to the size and frequency of real world VRPs they need to solve.\n\n## About the project\n\nThis is a playground project for educational purpose. I usually use this project to explore some JVM/Kotlin libs, new Gradle features/plugins, Constraint Solvers, Design Architectures on distributed systems and CI pipes (using github actions).\n\n### Project Modules\n\nThe project uses a [hexagonal architecture](https://jmgarridopaz.github.io/content/articles.html) and was broken into the following modules:\n\n* opta-router-core: domain modules with main business logic;\n* opta-router-geo: adapter module for reading geo data using Graphhopper;\n* opta-router-repo: adapter module for relational database persistence using Jooq;\n* opta-router-solver: modules containing several solvers;\n* opta-router-webcli: webclient app (SPA) using Vue3;\n* opta-router-app: webserver application using Spring Boot.\n\nThe `opta-router-solver` module contains several submodules that uses different Open Source solvers (Constraint Programming and Meta Heuristics) implementations. They are:\n\n* jenetics: a Genetic Algorithm library, written in modern-day Java;\n* jsprit: lightweight, flexible toolkit for solving VRP, based on a single all-purpose meta-heuristic currently solving;\n* optaplanner: solves constraint satisfaction problems with construction heuristics and meta-heuristic algorithms;\n* or-tools: a for solving linear programming, mixed integer programming, constraint programming, vehicle routing, and related optimization problems;\n* timefold: is a fork of OptaPlanner.\n\n### Screenshots\n\nPortfolio List\n\n![image](https://github.com/pintowar/opta-router/assets/354264/6449a598-49d0-4faa-8cf4-4d9dbf37b75a)\n\nSolver View\n\n![image](https://github.com/pintowar/opta-router/assets/354264/12e9f924-cd4c-42fd-b9ad-404318bbc1f7)\n\nSolver History\n\n![image](https://github.com/pintowar/opta-router/assets/354264/ef81013b-122b-48d3-8493-a8d744f3249e)\n\n### Building and running\n\nThe project has 3 build/run profiles:\n\n* local (**default**): for development setup;\n* single: single process with an embedded h2 database;\n* dist: app being able to connect with an external postgres database. This profile is also meant to run for different modules (look into `docker-compose.yml` file to check how to proper setup this environment):\n  * rest-app: client ui + main rest endpoints;\n  * solver-app: backend with solver. It reads solver requests from a distributed queue;\n  * geo-app: another backend serving data concerning to geo data.\n\nThis project contains a sample of pre-defined problems on belgium area. An OSM (Open Street Map) map is needed to make the road path calculation process possible. The `opta-router-geo` is responsible to extract this information from the map that can be found on this [link](http://download.geofabrik.de/europe/belgium-latest.osm.pbf).\n\nDownload it and point the ENV `GRAPH_OSM_PATH` to its system path. This way the `opta-router-geo` will parse and extract the relevant road data and persist it on another folder (defined by `GRAPH_OSM_LOCATION` path). This process can take some minutes, but will run only once (as long as the relevant data is already stored on the `GRAPH_OSM_LOCATION` path).\n\n#### Development profile\n\nIn order to run the project in development mode, the `local` profile must be used. Since it is the default profile, the explicit definition is optional.\n\n##### Web Server App\n\nTo run the web-server module, run on `opta-router-app` folder:\n\n    gradle bootRun\n\nThis command will run a Spring Boot application on port `8080`.\n\n##### Web Client App\n\nTo run the client module, make sure you have node installed on your system, then run on `opta-router-webcli` folder:\n\n    npm run dev\n\nPoint your browser to `http://localhost:3000`. This module will run on port `3000`, but will proxy remote calls to port `8080`.\n\n##### Both Modules\n\nGradle can run both modules together\n\n    gradle bootRun -parallel\n\nThis task will run both modules on port `3000` and `8080`.\n\n#### Single assembled jar\n\nTo build a jar that contains an embedded h2 database and both server and client modules assembled on the same app. Just run the task on the root folder:\n\n    gradle -PenvironmentName=single assembleApp\n\nThis will generate a jar named `app.jar` on the `build` folder. To run the generated app, then run `GRAPH_OSM_PATH=\u003cpath_to_osm_map\u003e GRAPH_OSM_LOCATION=\u003cpath_to_graphhopper_folder\u003e java -jar app.jar`.\n\n#### Docker Image with Single assembled jar\n\nA full packaged docker image (with single profile) can be found at Dockerhub. In order to run the sample, you have to download the belgium OSM map and add the ENVS config mentioned above.\n\nTo run a working sample of opta-router image, run the following commands:\n\n```shell\nmkdir -p /tmp/osm/gh-tmp\nwget http://download.geofabrik.de/europe/belgium-latest.osm.pbf -P /tmp/osm\n\ndocker run --rm -e GRAPH_OSM_PATH=/tmp/osm/belgium-latest.osm.pbf -e GRAPH_OSM_LOCATION=/tmp/osm/gh-tmp -v /tmp/osm:/tmp/osm -p 8080:8080 pintowar/opta-router:single-latest\n```\n\nPoint your browser to `http://localhost:8080`.\n\n#### Dist assembled jar\n\nTo build a jar that contains **only** server and client modules assembled on the same app with drivers to a postgres database. Just run the task on the root folder:\n\n    gradle -PenvironmentName=dist assembleApp\n\nOne pre-requisite for building with this profile is a running instance of a postgres instance with a database \"opta-router\" already created. This is needed in order to `opta-router-repo` module be able to run the migrations and generate the base JOOQ classes. The initial postgres connection configuration can be redefined on `gradle-dist.properties` file.\n\nThis will generate a jar named `app.jar` on the `build` folder. To run the generated app, then run `GRAPH_OSM_PATH=\u003cpath_to_osm_map\u003e GRAPH_OSM_LOCATION=\u003cpath_to_graphhopper_folder\u003e java -jar app.jar`.\n\n#### Docker Compose with Single dist jar\n\nThere is a `docker-compose.yml` file on the base directory of this project. It is configured with a postgres database and a docker images with a dist profile build.\n\nOn the base directory, you can run the following command:\n\n```shell\nmkdir -p /tmp/osm/gh-tmp\nwget http://download.geofabrik.de/europe/belgium-latest.osm.pbf -P /tmp/osm\n\ndocker-compose up\n```\n\nThen point your browser to `http://localhost:8080`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpintowar%2Fopta-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpintowar%2Fopta-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpintowar%2Fopta-router/lists"}