{"id":35273484,"url":"https://github.com/nikitadanilenko/foodie","last_synced_at":"2026-05-17T19:09:46.322Z","repository":{"id":44417050,"uuid":"120260667","full_name":"nikitaDanilenko/foodie","owner":"nikitaDanilenko","description":"Food statistics calculator based on the Canadian Nutrient File","archived":false,"fork":false,"pushed_at":"2026-04-11T16:09:02.000Z","size":5931,"stargazers_count":0,"open_issues_count":16,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-11T18:09:08.911Z","etag":null,"topics":["database","elm-lang","hacktoberfest","nutrients-calculator","postgresql","property-testing","scala"],"latest_commit_sha":null,"homepage":"https://danilenko.io/foodie/#/login","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikitaDanilenko.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-02-05T05:48:53.000Z","updated_at":"2026-04-11T16:09:07.000Z","dependencies_parsed_at":"2023-02-15T15:31:11.208Z","dependency_job_id":"3960a115-722e-4348-a9f4-0fe2b0dbae44","html_url":"https://github.com/nikitaDanilenko/foodie","commit_stats":null,"previous_names":[],"tags_count":231,"template":false,"template_full_name":null,"purl":"pkg:github/nikitaDanilenko/foodie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaDanilenko%2Ffoodie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaDanilenko%2Ffoodie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaDanilenko%2Ffoodie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaDanilenko%2Ffoodie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikitaDanilenko","download_url":"https://codeload.github.com/nikitaDanilenko/foodie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikitaDanilenko%2Ffoodie/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31937733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T12:37:54.787Z","status":"ssl_error","status_checked_at":"2026-04-17T12:37:25.095Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","elm-lang","hacktoberfest","nutrients-calculator","postgresql","property-testing","scala"],"created_at":"2025-12-30T13:17:55.504Z","updated_at":"2026-04-17T17:03:38.353Z","avatar_url":"https://github.com/nikitaDanilenko.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Caveats\n\n1. There are no values for iodine in the database.\n2. Several values may be incomplete. For instance, biotin is only listed for a handful of foods.\n\n### Database\n1. Create a database, a corresponding user, and connect the two:\n   ```\n   \u003e psql -U postgres\n   psql\u003e create database \u003cfoodie\u003e;\n   psql\u003e create user \u003cfoodie\u003e with encrypted password \u003cpassword\u003e;\n   psql\u003e grant all privileges on database \u003cfoodie\u003e to \u003cfoodie\u003e;\n   psql\u003e grant pg_read_server_files to \"\u003cfoodie\u003e\";\n   ```\n   The last command is important for the population of the actual CNF database.\n   When `psql` is running in Docker it may also be necessary to add\n   ```\n   psql\u003e\\c \u003cfoodie\u003e\n   foodie\u003egrant all privileges on all tables in schema public to \u003cfoodie\u003e;\n   ```\n   Additionally, at least one migration may require super-user access for the user,\n   unless the extension `uuid-ossp` is already defined.\n2. Populate the CNF database by once running the script under `scripts/populate_cnf_db.sql`.\n   To achieve that run the following steps:\n   1. Open a console in the project folder \n   2. `\u003e psql -U postgres`\n   3. It may be necessary to switch to the project folder in `psql` as well.\n      This can be achieved with `psql\u003e \\cd \u003cabsolute path\u003e;`.\n   4. `psql\u003e \\ir scripts/populate_cnf_db.sql`\n   5. In case of Docker:\n      1. The script files are copied to `/tmp/scripts` via `docker-compose.yml`.\n      2. Connect to container `docker exec -it postgres /bin/bash`.\n      3. Change into `tmp` via `cd /tmp`.\n      4. Run `psql -U \u003cfoodie-user\u003e -d \u003cfoodie-database\u003e -h db`, enter the password.\n      5. Run the script exactly as above.\n   6. Why not a migration?\n      There are several reasons for that:\n      1. To `copy from` via SQL the user needs to be a superuser, which may be problematic.\n      2. `copy from` does not handle relative paths, i.e. one needs an absolute path.\n         Absolute paths present an unnecessary constraint and impede development, and deployment.\n      3. In theory one may use a different population set or no population at all.\n         Both work fine with an external population, but not with a migration.\n3. The system scans for migrations in the folder `conf/db/migrations/default`\n   and applies new ones.\n   After a migration one should re-generate database related code:\n    1. `sbt slickGenerate` generates the base queries, and types.\n    \n### Minimal Docker database backup strategy\n\nDepending on the setup the commands below may need to be prefixed with `sudo`.\n\n1. Start containers detached `docker compose up -d`\n1. Connect to the container `docker compose run db bash`\n1. Dump the database as insert statements (for better debugging):\n   `pg_dump -h \u003ccontainer-name\u003e -d \u003cdatabase-name\u003e -U \u003cuser-name\u003e --inserts -W \u003e /tmp/\u003cbackup-file-name\u003e.sql`.\n   You will be prompted for the password for said user.\n   Moving the file to `/tmp` handles possible access issues.\n   Even better - dump only the relevant tables by listing them with `-t \u003ctable_name\u003e` for each\n   table (prefixed with `public.`).\n   ```\n   pg_dump -h foodie-postgres -d foodie -t public.user -t public.session -t public.meal_entry -t public.meal -t public.complex_food -t public.recipe -t public.complex_ingredient -t public.recipe_ingredient -t public.reference_entry -t public.reference_map  -U foodie --insert -W \u003e /tmp/\u003cdate\u003e.sql\n   ```\n1. Find the id the desired container: `docker ps`\n1. In a third CLI copy the backup file to your local file system:\n   `docker cp \u003ccontainer-id\u003e:/tmp/\u003cbackup-file-name\u003e.sql \u003cpath-on-local-file-system\u003e`\n\n### Deployment\n\nFor the moment the deployment is handled manually.\nThere needs to be a running Docker service running on the target machine.\n\n1. Connect to the target machine.\n2. If this is the first deployment, clone Git project into a folder of your choosing.\n3. Change into the local Git repository of the project.\n4. Run `git pull`. It is possible that there will be a conflict with the `db.env`,\n   if the development password has changed.\n5. Make sure that `db.env` contains deployment values.\n6. If this is the first deployment, create a file `deployment.env` containing\n   all necessary environment variables (cf. `application.conf`).\n7. Make sure that all necessary environment variables are set in `deployment.env`,\n   and these variables contain the desired deployment values.\n   As a reference, one can use the `.env` file - every key present in the `.env` file\n   needs to be set in the `deployment.env` as well.\n   Caveat: Avoid `#` symbols, because these can behave differently between\n   `dotenv` and Docker.\n8. Run `docker compose up` (possibly with `sudo`).\n   If you want to deploy a specific version, update the image from `latest`\n   to the desired tag in the `docker-compose.yml`.\n9. If this is the first deployment,\n   connect to a bash in the Docker `db` container,\n   and perform the database setup steps described above.\n10. If this is the first deployment, restart the service (only the back end is sufficient).\n    There is a tricky optimisation in the code: Some of the CNF tables are kept in memory to avoid queries\n    (particularly in the case of statistics).\n    However, the tables are loaded only once at the start of the service.\n    Since the CNF database is initially empty, so are the memory values.\n\n### CI\n\n[![Run tests](https://github.com/nikitaDanilenko/foodie/actions/workflows/verify-pull-request.yml/badge.svg)](https://github.com/nikitaDanilenko/foodie/actions/workflows/verify-pull-request.yml)\n[![Build and publish back end](https://github.com/nikitaDanilenko/foodie/actions/workflows/build-and-publish-back-end.yml/badge.svg)](https://github.com/nikitaDanilenko/foodie/actions/workflows/build-and-publish-back-end.yml)\n[![Build and publish back end](https://github.com/nikitaDanilenko/foodie/actions/workflows/build-and-publish-front-end.yml/badge.svg)](https://github.com/nikitaDanilenko/foodie/actions/workflows/build-and-publish-front-end.yml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitadanilenko%2Ffoodie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikitadanilenko%2Ffoodie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikitadanilenko%2Ffoodie/lists"}