No description
Find a file
2025-01-29 01:24:52 +01:00
.vscode initial commit 2024-02-27 22:09:39 +01:00
config initial commit 2024-02-27 22:09:39 +01:00
migrations Add food products and their ingredients, with their carbon footprint calculator. 2025-01-29 01:24:52 +01:00
src Add food products and their ingredients, with their carbon footprint calculator. 2025-01-29 01:24:52 +01:00
test-e2e Add food products and their ingredients, with their carbon footprint calculator. 2025-01-29 01:24:52 +01:00
.env initial commit 2024-02-27 22:09:39 +01:00
.gitignore fix gitignore 2024-02-28 10:20:18 +01:00
docker-compose.yml initial commit 2024-02-27 22:09:39 +01:00
dummy_data_form_submissions.csv upload csv file for Front end low code hiring test 2025-01-17 14:21:16 +01:00
jest.json update coverage test 2024-02-28 10:09:28 +01:00
nest-cli.json initial commit 2024-02-27 22:09:39 +01:00
notes.txt initial commit 2024-02-27 22:09:39 +01:00
package-lock.json initial commit 2024-02-27 22:09:39 +01:00
package.json Add food products and their ingredients, with their carbon footprint calculator. 2025-01-29 01:24:52 +01:00
README.md Update README.md 2025-01-17 14:20:33 +01:00
tsconfig.build.json initial commit 2024-02-27 22:09:39 +01:00
tsconfig.json initial commit 2024-02-27 22:09:39 +01:00
yarn.lock initial commit 2024-02-27 22:09:39 +01:00

How to use

Stack: NestJs + TypeORM + Postgres

Requirements

  • Docker / Docker Compose
  • Node.js 18

Installation

$ yarn

Running the app

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

Test

To run unit tests:

# unit tests
$ yarn test

# e2e tests
$ yarn test:e2e

# test coverage
$ yarn test:cov

Database Migration

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

Hiring Test

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.

Explorate the Front End

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.