Coder Social home page Coder Social logo

coding-challenge-data-import-scaffolding's Introduction

What is this

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

Getting started

Setup the working environment

  1. Clone this repo on your local machine
  2. Run npm install
  3. Setup a PostgreSQL database. You can also ask for a cloud instance and we will provide you with one.
  4. Configure the env variable DATABASE_URL and point it to your database.
  5. Run npm run migrate. This will create the tables in your new database. Set NODE_ENV=production if connecting to a Heroku PostgreSQL instance. Such instance requires a SSL connection which is enabled through the NODE_ENV variable.
  6. Run npm run build && npm start
  7. Navigate to http://localhost:3000 and verify that the scaffolding application is running (there should be vessels visible)

Implement

There are 2 parts that you need to implement:

  1. 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.
  2. 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

Importing data

We provide 2 out of the box ways of importing data from the API and run your merge algorithm on this real data:

  1. Click on the import button in the UI
  2. Run the import script

Tests

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

Import script

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 imo 9387425.

Environment variables.

Check the conf.ts file for all the environment variables and their use.

coding-challenge-data-import-scaffolding's People

Watchers

 avatar

Forkers

luanmuniz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.