🏆Recruiting challenge junior #1

Welcome, JS Guardian Angels ! Find here the challenge to prove your worth to Seraphin's Team

🎯 Objectives & Mindset

This challenge aims at making sure that we've got a clear understanding of your current JS level. No need to be an expert, the important is that you do your best so we can transparently assess whether you're technically a good fit for the job.

There is no perfect answer to the challenge, and we'll be pleased to hear how and why you came to the solution you propose. There are however wrong answers (the ones that do not meet the specifications), so we'll assume it's a sign of laziness from you to submit an answer which is factually not correct (unless the specifications were provably unclear). Please don't be that person 😉.

We invite you to take enough time to provide a well-crafted solution, learning new things along the way. We love structure, clear code, well commented source files, green tests, explicitly named variable and function names, simple architectures...Do consult best practices online, do look for other solutions to similar problems. It would be really cool if you could also surprise us with things you teach us that we did not know!

This challenge is only the technical part, remember that for us the human part is also extremely important - but that is something to be discussed face-to-face afterwards.

Good luck, JS Guardian Angel!

🏆 The Challenge

Your mission is to create a small nodejs HTTP REST API server to compute prices for an insurance policy offered by Seraphin to its potential customers. The product at hand is a car insurance 🏎️, with a price and eligibility that depends on characteristics of the driver 👨‍💼 and of the car to be insured.

Seraphin uses a lot of such so-called micro-services in its architecture, as they are simple to maintain due to their limited size (they do only one thing and do it well).

We provide specifications only for the service interface; for the rest it is up to you to define the full implementation of your service. You are literally free to do anything you want as long as it's cool and meets the specifications! Just please use the most recent Node version (1O or above) as well as ES6 JavaScript (please, no var !).

To ease development and to impress us, we strongly suggest that you write unit tests to test your price computation module, and integration tests to test your server HTTP API. Have a look at mocha and chai to this purpose.

🚧 Specifications

Please conform to the following specifications. The first set is about how the price should be computed, whereas the second set concerns how the server API exposes the pricing service.

Price computation module

The product is a simple insurance product with 2 components:

  • Civil liability:

    • Protects the driver in case there is a crash in which (s)he's responsible, paying out the damage to the victims

    • Not eligible for drivers under 18 years old (excluded)

    • Costs the following:

      • €1000/year for drivers up to 25 years old (included)

      • €500/year for drivers 26 years old or more

  • Omnium:

    • Protects the car in case of material damage

    • Not eligible for drivers under 18 years old (excluded)

    • Costs 3% of the value of the car

REST HTTP API

We will verify the validity of your API implementation manually from our terminals with curl

Quote

POST http://localhost:8080/v1/quote/car-insurance

Your API should respect this specification: when submitting a request we should get a response as described here.

Request Body

// Driver eligible for the insurance
{
    "success": true,
    "message": "quote successfully computed",
    "data": {
        "eligible": true,
        "premiums": {
            "civil_liability": 1000.00,
            "omnium": 702.4
        }
    }
}  

// Driver NOT eligible for the insurance
{
    "success": true,
    "message": "quote successfully computed",
    "data": {
        "eligible": false,
        "premiums": null
    }
}       

🗓️ Practicalities

Please publish your code to a public GitHub repository and send us the link. You have 1 week as of the moment you're assigned the challenge to send us a working version. We expect that we can test your challenge by running the following commands

git clone REPO_NAME
cd REPO_NAME
npm install
npm run test

It is up to you to decide what you put in these tests. We also expect to be able to run npm run dev (or npm run startdepending on what standard command is used in your version of node) and runcurl against the API endpoint with a valid payload, getting the right response in return. For reference, here is a sample curl command:

curl -X POST -H "Content-Type: application/json" localhost:8080/api/v1/quote/car-insurance --data '{"car_value": 20000.0, "driver_birthdate": "15/10/1990"}'

Your GitHub repository should ideally include a little schematic overview of the different modules of your code and how they interact.

We'll review your submission in the week after we receive it, and invite you to talk face-to-face if you rocked the challenge.

Now, let's get started. All the best! 🚀

Last updated