Stack: NestJs + TypeORM + Postgres
- Docker / Docker Compose
- Node.js 18
$ yarn
First you need to start, migrate and seed the db :
$ yarn init-project
you can then start the server:
# development
$ yarn start
# watch mode
$ yarn start:dev
To run unit tests:
# unit tests
$ yarn test
# e2e tests
$ yarn test:e2e
# test coverage
$ yarn test:cov
When the data schema is updated, the database needs to be synchronised with the code. This is done by creating a migration with Typeorm using the following command:
migrationName=<name> yarn migration:generate
When working on the following exercise, in addition to answering the product need, to give particular attention to the following points:
- Readability
- Maintainability
- Unit testing
- Handling of corner cases
- Error-handling
We want to compute the Agrybalise carbonfootprint of a foodproduct (e.g.: a hamCheesePizza) that we characterize by its ingredients as shown below
const hamCheesePizza = {
ingredients: [
{ name: "ham", quantity: 0.1, unit: "kg" },
{ name: "cheese", quantity: 0.15, unit: "kg" },
{ name: "tomato", quantity: 0.4, unit: "kg" },
{ name: "floor", quantity: 0.7, unit: "kg" },
{ name: "oliveOil", quantity: 0.3, unit: "kg" },
],
};
The calculation of the Agrybalise carbon footprint can be described as below:
- The Agrybalise carbon footprint of one ingredient is obtained by multiplying the quantity of the ingredient by the emission of a matching emission factor (same name and same unit).
- The carbon footprint of the food product is then obtained by summing the carbon footprint of all ingredients.
- If the carbon footprint of one ingredient cannot be calculated, then the carbon footprint of the whole product is set to null.
The tasks of this exercice are as follows: 1/ Implement the carbon footprint calculation of a product and persist the results in database. 2/ Implement a GET endpoint to retrieve the result. 3/ Implement a POST endpoint to trigger the calculation and the saving in the database.
Once an endpoint is created, it can then be used by the front-end, build on the low code framework Retool. Altough your role will mostly consists in developing on the Typescript backend, you will have to contribute to the low code platform from time to time. In the following, you will build your first functionality on Retool. Here are the steps to follow:
1/ Create a free account on the Retool platform.
2/ In the github project you can find a file dummy_data_form_submissions containing some dummy data. Implement a table showing the data and a search bar to search over the company name.
3/ Update the table to make the company column editable
4/ Display the activity sector as a tag.
5/ Display a graphic visualization of a benchmark within each Activity sectors, where you compare companies based on their scores.
This part does not need to be shared before-hand but can be presented during the interview.