This is the rust backend for the Protein DIAAS calculator
See also the frontend project DIAAS calculator angular
- Language: rust
- Dependencies: cargo
- Database: postgresql (dockerized for development)
- Webservice framework: actix-web , actix-web on github
- The service exposed is a
REST API
- The service exposed is a
- ORM: diesel, diesel on github
Use the provided docker-compose.yml
file to run a local postgresql database:
# first time only
docker network create diaas-db
cd postgres-and-adminer
docker-compose up -d
You can browse the database content with adminer at http://localhost:8080 . The credentials and other information can be found in the docker-compose.yml
. Note that server
is db
(the service name)
- Install rust and cargo: https://rustup.rs/
- Install diesel cli (ref). Example for ubuntu/WSL:
sudo apt install libpq-dev
cargo install diesel_cli --no-default-features --features postgres
- Run the diesel migration to populate the database:
cp .env.localhost .env
diesel migration run
- Run the application (configured by
.env
file too)
cargo run
cd fixtures
docker run -v $(pwd):/tmp --network diaas-db --rm --name pgloader dimitri/pgloader:latest pgloader /tmp/csv.load.localhost
docker run -v $(pwd):/tmp --network diaas-db --rm --name pgloader dimitri/pgloader:latest pgloader /tmp/csv.load.i18n.localhost
API requests can be done against http://localhost:9090/api
(or https://diaas-calculator.com/api
in production)
For testing you can use the postman collection provided under /test
.
Note that all the endpoints that modify data are deactivated for now (waiting for access control implementation). You can re-activate the missing endpoints in main.rs:
// waiting for authentication implementation
.service(food::create)
.service(food::delete)
.service(food::update)
This is an opensource project. All the contributions are welcome!
In case something inspires you, here's the top of my todo list (please contact on on slack before starting anything significant):
-
Front + Back:
-
giving suggestion based on current mix (a specific search request with the current mix diaaas, so that the backend sorts the food items by better match first.)
-
suggested / example mixes
-
-
g co2/g of protein
-
equivalent g of complete protein
-
hidden flag: for diaas that we keep for comparison but we want to hide to most users because we believe there is a better result
-
-
unit test, ci-cd
- user profile
-
personal recipes (shared or not)
-
personal food items
-
mode compare: food items and/or mix
-
add more details about studies in case links go dead (name, authors, date, journal). new table?
-
special editor profiles who are allowed to update/delete/create food items (with validation of the administrator)
-
Front
-
display details about the types of DIAAS in the detailed view. ex DIAAS-rat-> DIAAS on rodents
-
contextual help (especially for mobile devices)
-
add "clear mix" button
-
switch to other age diaas (it is a simple multiplication)
-
search that starts running without entering "search" button (after a pause in typing)
-
more elements translated in the GUI
-
You can help with food item translation into other languages. See for example fixtures/food_i18n.csv
for the expected format
You can enrich our current dataset by adding lines in the fixtures/food.csv
and fixtures/food_i18n.csv
files
Things to be careful with:
- Preparation of the food: see https://www.diaas-calculator.com/diaas-information#limitations-and-precautions
- Score standard, animal model, digestibility model : see the user manual
- The amino acids are often given in the same order, but not always.
- Age reference pattern: the reference pattern used is often
6month->3years
(it is the default one as per the FAO recommendations). We chose to display the information for the reference pattern>3y
by default as you can hardly have a 6 month old eat grains and legumes, and mixing grains and legumes are one of the best strategies for what we want to achieve. It is a simple multiplicative factor to get from the 6m->3y to the >3y pattern:
his | iso | leu | lys | met+cys | phe+tyr | thr | trp | val |
---|---|---|---|---|---|---|---|---|
1,25 | 1,06666667 | 1,08196721 | 1,1875 | 1,17391304 | 1,26829268 | 1,24 | 1,28787879 | 1,075 |
To convert from the PDCAAS 2-5 years old reference pattern to the DIAAS >3years old reference pattern, use those coefficients:
his | iso | leu | lys | met+cys | phe+tyr | thr | trp | val |
---|---|---|---|---|---|---|---|---|
1,1875 | 0,93333333 | 1,08196721 | 1,20833333 | 1,08695652 | 1,53658537 | 1,36 | 1,66666667 | 0,875 |
Don't hesitate to reach us should you find any error, be it English error, or scientific fact error.
Don't hesitate to contact us on slack if you have any questions or want to discuss anything about this project.