javascript workshop based on french startup https://www.convargo.com
Table of Contents generated with DocToc
- Introduction
- Objectives
- Just tell me what to do
- Steps to to
- Source and inspiration
- Licence
Convargo wants to revolutionise the freight industry, by connecting shippers with truckers in real time via a web application.
The Goods freight transport sector is a key sector of the Europe (even worldwilde) economy:
- 300 billion euros in Europe
- 43 billion euros in France
- highly fragmented with more than 40,000 road transport companies in France
- under efficient: ⅓ trucks drive empty on Fance roads!
The Convargo platform allows shippers to:
- access directy to a wide range of road transport companies with available loading capacity
- compute and display the transport price calculated according to the best opportunities on the market at a time T
- track in real-time the goods delivery
- access to proof of transport and dematerialized invoices
We focus on this platform feature: compute and display the transport price calculated according to the best opportunities on the market at a time T
.
The workshop goals are to
- compute the shipping price for the
shippers
- compute the profit of the road transport company, the
truckers
- compute the profit of
convargo
- Fork the project via
github
- Clone your forked repository project
https://github.com/YOUR_USERNAME/convargo
❯ cd /path/to/workspace
❯ git clone git@github.com:YOUR_USERNAME/convargo.git
- Open the entry point/public/index.html in your browser (that loads the
index.js
file)
# macos cli
❯ open public/index.html
# linux cli
❯ xdg-open public/index.html
# or by double-clicking in your browser files
- Check the ouput in your browser console (Use
Ctrl + Shift + J
orCmd + Opt + J
to focus to your console devtools ) - Solve each steps inside ./public/index.js file with JavaScript
- Once a step is solved, commit your modification:
❯ cd /path/to/workspace/convargo
❯ git add -A && git commit -m "feat(price): decrease pricing for higher volume"
(why following a commit message convention?)
- 5 steps, so ideally 5 commits
- Don't forget to push before the end of the workshop
❯ git push origin master
Note: if you catch an error about authentication, add your ssh to your github profile.
- Check that your codebase works by checking the console output
- If you need some helps on git commands, read git - the simple guide
- DRY - Don't repeat yourself
- DOT - Do One Thing
- KISS - Keep It Simple Stupid
- LIM - Less Is More
- English only: codebase, variables, comments...
Focus only on coding, forgot the browser display (next workshop!).
Use console.log
to display results (for the moment)
The shipper books the trucker for an itinerary and volume.
The shipping price is the sum of the distance component and the volume component with
- distance component: the number of kilometers multiplied by the trucker price per km
- volume component: the used volume multiplied by the trucker price per m3
shipping price = distance + volume
Write JS code that generates the shpping price for each shipper
from index.js
file:
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "165d65ec-5e3f-488e-b371-d56ee100aa58",
...
"price": ?
}
]
To be as competitive as possible, convargo decide to have a decreasing pricing for high volumes.
price per m3
- decreases by 10% after 5 m3
- decreases by 30% after 10 m3
- decreases by 50% after 25 m3
Adapt the shipping price computation to take these new rules into account.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"price": ?
},
{
"id": "65203b0a-a864-4dea-81e2-e389515752a8",
...
"price": ?
},
{
"id": "165d65ec-5e3f-488e-b371-d56ee100aa58",
...
"price": ?
}
]
Now, it's time to pay the truckers
There is a 30% commission on the shipping price to cover the costs.
The commission is split like this:
- insurance: half of commission
- the Treasury: 1€ by 500km range
- convargo: the rest
Compute the amount that belongs to the insurance, to the assistance and to convargo.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
...
"commission": {
"insurance": ?,
"treasury": ?
"convargo": ?
}
},
...
]
In case of an accident/theft, convargo applies a 1000€ deductible.
The shipper can reduce the deductible amount from 1000€ to 200€ with a deductible option
for a few more euros per volume.
The driver is charged an additional 1€/m3 when he chooses the deductible reduction
option.
The additional charge goes to convargo, not to the trucker.
Compute the new amount price if the shipper subscribed to deductible option
.
//example output from console.log
[
{
"id": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
'options': {
'deductibleReduction': true
},
...
"price": ?
},
...
]
It's time to debit/credit each actor!
- the shipper must pay the shipping price and the (optional) deductible reduction
- the trucker receives the shipping price minus the commission
- the insurance receives its part of the commission
- the Treasury receives its part of the tax commission
- convargo receives its part of the commission, plus the deductible reduction
- Compute the debit for the
shipper
- Compute the credit of the car
trucker
,insurance
, andconvargo
.
//example output from console.log
[
{
"deliveryId": "bba9500c-fd9e-453f-abf1-4cd8f52af377",
"payment": [
{
"who": "shipper",
"type": "debit",
"amount": ?
},
{
"who": "owner",
"type": "credit",
"amount": ?
},
{
"who": "insurance",
"type": "credit",
"amount": ?
},
{
"who": "treasury",
"type": "credit",
"amount": ?
},
{
"who": "convargo",
"type": "credit",
"amount": ?
}
]
},
...
]