/railway-routing-service

Generates route suggestions in a virtual railway network

Primary LanguageJava

Railway Routing Service

Given a gigantic railway network with multiple junction stations, this application wishes to provide a facility to suggest routes for the bewildered traveller. Feel free to use this app in your smart phone.

Specification

This application ships with a default station map of the Republic of Singapore. Hence, the basic front-end facility is crafted specifically for it. It is also capable of creating a new virtual railway network given a different station map defined in a CSV file. Please take note the following steps depicts how the Railway Factory construct the virtual railway network:

  1. The CSV file adheres to the following format and creates a list of stations containing the following fields:
Station Code,Station Name,Opening Date
NS1,Jurong East,10 March 1990
NS2,Bukit Batok,10 March 1990
NS3,Bukit Gombak,10 March 1990
  1. The station code strictly adheres two capital letters followed by any number of numerical digits.
  2. The factory sorts the list of stations by station code in alphabetical and numerical order respectively.
  3. The factory creates connections in sequential order.
  4. The factory creates connections if their station names are equal (i.e. they are junction stations).

In the course of computing suggested routes, closed stations are not traversed. Please refer to the station map to determine which stations are closed.

Aside from providing a front-end facility, you may also access the REST API endpoint for route suggestion request:

curl "http://li1123-50.members.linode.com/railway-routing-service/compute-path?origin=Holland%20Village&target=Bugis"
# For a more human readable response
curl "http://li1123-50.members.linode.com/railway-routing-service/compute-path?origin=Holland%20Village&target=Bugis" -H 'Accept: text/plain'

The suggested routes are ordered by the number of stations travelled in ascending order. It also suggests if you need to change lines.

Deployment Instructions

Please refer to the deployment guide for further instructions.

Importing a different CSV station map

To import a different CSV station map to an existing containerized web application, please modify the "RAILWAY_CSVPATH" property in the docker-compose.yml found in the web server and just execute "docker-compose up -d" to recreate the container with a new station map. Please follow the CSV format strictly as the application will fail to boot if the parser deems the CSV file unreadable.

The Journey

The architecture is still similar to the other project which follows the vertical slices as presented here by Oliver Gierke, the Spring Data Project Lead at Pivotal.

Since this project involves more domain logic, I opted for a test-driven development approach for the entire domain model. It especially helped me to come up with a decent path finding algorithm as I come up with different test scenarios.

Furthermore, I have listed all the technologies that I've used in this project.

Back-end Technologies

  1. Java
  2. JUnit4
  3. Hamcrest
  4. Spring Boot
  5. Spring Boot Test
  6. REST
  7. Bean Validation 2.0 (JSR-380)

Front-end Technologies

  1. HTML5
  2. CSS3
  3. ReactJS
  4. React Bootstrap

Dev-ops Technologies

  1. Git
  2. Gradle
  3. Docker
  4. Ansible

Copyright

Copyright © 2019, Emmett Young, All rights reserved.

No reproduction and usage are allowed in whole or in part for distribution, personal and commercial purposes.