SLU-foodsystems / safad

A web-based tool to compute the environmental impacts of a diet, led by Elin Röös.
https://safad.se
MIT License
1 stars 0 forks source link
SLU logo    Plan'Eat logo

Sustainability Assessment of Foods and Diets (SAFAD)

A web-based implementation of the SAFAD model developed by Röös et al. (2024, in press) to benchmark environmental impacts of diets.

Instructions for common maintenance tasks

Every time a change is made on the main branch, the website is deployed to safad.se, thanks to the service Netlify.

Upload new input files

From GitHub.com: Go to src/default-input-files and, in the top-right corner, press the "Add File" button and select "Upload files". You will then be redirected to a page where you can upload the new files which will replace the old files. Remember that the name of the file is important, as is the order of the columns in the file. Files that you do not upload will remain unchanged (e.g. if you upload SAFAD IP Recipes.csv, that file will be replaced, and all other files remain unchanged).

Screenshot of location of Upload button

From CLI: Update the file in ./src/default-input-files/, stage, commit and push.

Update the version

The version consists of two component: one "major" and one "minor" version, separated by a period. Example: 2.34, where 2 is the major and 34 is the minor version.

The major version is defined explicitly, while the minor version is increased by 1 each time a commit is made, starting from a specific date.

To change it, you will need to edit the file vite.config.ts, where the variables VERSION_MAJOR (a number) and VERSION_MINOR_COUNT_SINCE (a date) can be defined. You can do this directly from github.com, using the built-in editor (go to the file and press the edit-button in the top-right corner, which is a pen-icon).

Project Structure

The project relies on extensive processing of the input data, some of which can be found in the ./data-preprocessing/ directory. The majority, however, are internal R-scripts and excel documents, as described in the above-mentioned paper.

The implementation of the website, along with the input files can be found in the ./src/ directory, with the main logic being inside the ./src/lib/ folder.

Some important files are:

One way to better understand what is going on in each file may be to look at the test files (same names, but ending with .test.ts instead of just .ts).

Technologies

The front-end uses Vue as the main framework, together with TypeScript. These tools all require a working installation of node and a package-management system (e.g. npm, included when installing node).

Tooling

Recommended IDE Setup

VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile and Minify for Production

npm run build

Run tests

npm run test