This is a scaffolding project for you to get started quickly on Portchain's coding challenge. It is built with the following technologies in mind:
- Sequelize connected to PostgreSQL
- NodeJS + Typescript on the backend
- React + Typescript on the front-end
- Easy and fast deployment to Heroku
- Clone this repo on your local machine
- Run
npm install
- Setup a PostgreSQL database. You can also ask for a cloud instance and we will provide you with one.
- Configure the env variable
DATABASE_URL
and point it to your database. - Run
npm run migrate
. This will create the tables in your new database. SetNODE_ENV=production
if connecting to a Heroku PostgreSQL instance. Such instance requires a SSL connection which is enabled through the NODE_ENV variable. - Run
npm run build && npm start
- Navigate to
http://localhost:3000
and verify that the scaffolding application is running (there should be vessels visible)
There are 2 parts that you need to implement:
- The merging algorithm to import the vessel schedules
- You can rely on the existing tests that cover some basic scenarios. See below on how to run the tests.
- The User Interface including a couple of new API endpoints. You need to display two additional pages:
- The list of port calls for a given vessel
- The history of each port call
We provide 2 out of the box ways of importing data from the API and run your merge algorithm on this real data:
- Click on the import button in the UI
- Run the import script
There are some existing tests that will get you started in building the merging algorithm. These tests consist in fixtures describing 2 inputs and and an expected output:
- The schedules as they currently are in the database (input)
- The schedules as they currently are in the provider API (input)
- A list of 'actions' that the merge algorithm should generate. See the API of the merge algorithm for more detailed information in vessel-schedule-merger.ts
Run the following to run all tests:
npm test
Run the following to run a single fixture:
TEST_FIXTURE=008 npm test
The TEST_FIXTURE
environment variable is evaluated as a regular expression so you can be creative in the use of this variable.
For example:
TEST_FIXTURE=(007|008) npm test
There is an import script that runs your merge algorithm on the real data provided by the coding challenge import API.
You can run this script on ALL vessels or on a specific vessel by IMO:
npm run import
runs on all vessels.VESSEL_IMO=9387425 npm run import
only runs the importer on the vessel with imo9387425
.
Check the conf.ts file for all the environment variables and their use.