Welcome to the fullstack assignment for engineering positions at Lepaya.
We hope you have a good time working on this assignment. We are looking forward to seeing your solution.
Feel free to ask for clarification if something is unclear.
Let's imagine a scaleup in the candy-space called Chocolate Inc.
Due to providing what the people want most, quality chocolate, it has grown from a small kitchen to having offices in several locations across Europe and the UK.
Like any other thriving organization, it tries to keep its personnel happy and healthy, and away from the tasty chocolate, by providing fresh fruit in all of its offices.
Your task will be to build an application that will help the office managers at Chocolate Inc. track the fruit purchasing and consumption.
- A frontend (React) application
- An API server to support the frontend
- Answers to some technical questions
The frontend must implement the following 2 features.
As an office manager
I want to be able to specify an office and a year
So that I can see which fruit has the most pieces eaten in that office that year
As an office manager
I want to be able to specify an office and a year
So that I can see how much fruit was consumed per person on average in that office that year
As an office manager
I want to be able to specify an office and a list of fruit including quantity for each fruit
So that I can update the stock of fruit in that office in one go
As an office manager
I want my stock update to be rejected if the total calories of all combined fruit of this update exceeds 250kcal
So that the system prevents me from buying too many high-calorie fruits
We envision you will probably need two endpoints to satisfy the Frontend requirements ( maybe /purchase
and /report
).
Having said that, you do have the full freedom to organize how many endpoints you need and however you want to organize them, as long as the frontend requirements are satisfied.
You are free to use any out of the box server or any libraries you want; we'd suggest express
or koa
.
You DO NOT need to provide endpoints to get a list of office locations or available fruits. If you don't have the time or energy feel free to hardcode these lists, this will not be taken into consideration. The way you do hardcode them, will.
Ensure you provide enough automated tests to cover the key functionalities.
Please answer the following questions in a markdown file called "ANSWERS.md".
-
How long did you spend on the coding test?
-
What would you add to your solution if you had more time? If you didn't spend much time on the coding test then use this as an opportunity to explain what you would add.
-
Describe your solution in plain english. Point out your design decisions and the reasoning behind them.
-
Have you learned something new doing this test? If yes, describe it here.
-
Describe yourself using JSON.
The database that they use to keep track of fruit is provided to you as a PostgreSQL database defined in the docker-compose.yml
To run the database, you can use the following command:
docker-compose up -d
It should start on port 5432 by default, but feel free to modify the docker-compose.yml
as it suits you.
The default connection data would be (unless otherwise specified in the docker-compose.yml
):
POSTGRES_DB: fruity
POSTGRES_USER: candidate
POSTGRES_PASSWORD: candidate
It holds 3 tables
- location - Which holds all the locations where there are offices, along with the count of people in that office
- fruit - Fruits available for purchase, along with their name and caloric (kcal) value per unit.
- ledger - This table holds records of all the fruits that were purchased for an office or were eaten at the office.
Records with a negative integer in the amount column would represent the number of certain fruits that were eaten at an office, while the ones with the positive amounts would represent the purchase of those fruits at the office.
Example:
fruit_id | location_id | amount | time |
---|---|---|---|
3 | 2 | 4 | 2018-06-09 20:00:03.629 +0200 |
3 | 1 | -2 | 2017-05-09 23:33:15.233 +0200 |
Where the first row represents the purchase of apples (fruit #3), at the Berlin office by purchasing 4 pieces.
And the second row would represent an eating of 2 pieces of apples at the Amsterdam office.
ℹ️ Parts of the database records are generated randomly, don't expect consistancy if you recreate the container volumes.
- Build the app using TypeScript
- Preferably use React for the frontend
- The API should be a standalone server (not something like Next.js)
- Feel free to use any publicly available libraries that you are comfortable with.
- [OPTIONAL] Configure Docker to run the entire project, including both the API server and the frontend application, using a Dockerfile or docker-compose. Ensure that the setup instructions are included in the HOWTO.md file.
When you are finished, add your project to Github and invite lepaya-code-reviewer
as a collaborator.
Make sure there is a consise one or two-line command to start your project. If any explanation is necessary, please create a
HOWTO.md
file and explain how to run your solution.
Email to your Lepaya HR contact informing them that you have completed your assessment.
We will evaluate your solution based on the following criteria.
We will treat this as a real project, so we will evaluate how easy it is to maintain and scale your solution. Apply patterns where it makes sense, but be careful not to over-engineer.
Try to create something that reflects your abilities and the job you are applying for. Consider checking the job description again.