diary

module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: GPL-3.0

README

OFD Logo

OpenFoodDiary

Because Food Should Be Simple

Project Website

Publish OpenFoodDiary Container Server Build and Test Webapp Build and Test

This application is designed as a FOSS webapp for tracking your food. It doesn't want to do anything fancy with the data, nor try and gamify the process - it's intended to be as neutral as possible.

Just want to try it out?

I host this app for my own use at https://diary.openhealthsuite.com - it is behind simple google authentication, and should work fine if you want to try it or use it without setting up your own server.

Want to host your own?

If you've got a computer running docker at your disposal, you can quickly and easily run a single-user instance of OpenFoodDiary, using sqlite3 as the datastore:

mkdir openfooddiarydata
docker run -d -v $(pwd)/openfooddiarydata:/app/.sqlite \
  -p 3012:3012 \
  -e OPENFOODDIARY_USERID="my-ofd-userid" \
  --name openfooddiary-instance \
  ghcr.io/openhealthsuite/diary:latest

This will start OpenFoodDiary running, on port 3012. You can then access it using your web browser and you're ready to enter your logs - data will be persisted to a sqlite file in the volume mounted directory.

It's entirely possible to run OpenFoodDiary in more complicated configurations - various environment variables for configuration are listed below.

Helm?

I keep a trim helm chart in this repository, which with a small amount of manual futzing allows me to deploy updates - can be seen as a starting point to deploying OFD to your own cluster if you have one.

Running this Repo Locally

Running locally, this repo expects you to run both the server and webapp concurrently.

This repo also expects you to probably be running a node version manager such as fnm, and has the requisite .nvmrc files in the client folder.

Running the server/api

make run

Running the client

cd webapp
npm ci
npm run dev
Notes

By default, this will run the server with sqlite3 as a backing store, and will set a default userid header from the client for communicating with the server.

Environment Variables

General

  • PORT: defaults to 8080
    • sets the port OFD will run on
  • OPENFOODDIARY_USERIDHEADER: defaults to "x-openfooddiary-userid"
    • Denotes the header that will be populated with a user id
  • OPENFOODDIARY_USERID: defaults to undefined
    • Denotes userid that will always be populated - intended for dev and single-user modes
  • OPENFOODDIARY_LOGOUT_ENDPOINT: defaults to /api/logout
    • Value that will be returned when the user calls /api/logout-endpoint, allowing for different auth providers

Storage

  • OPENFOODDIARY_STORAGE_PROVIDER: defaults to undefined
    • Sets the storage provider, OFD falls back to sqlite3 if none is defined
    • options: postgres
  • OPENFOODDIARY_SQLITE3_FILENAME: defaults to ".sqlite/openfooddiary.sqlite"
    • Sets the filename/path the sqlite3 database will be stored to
    • note: this location equates to /app/.sqlite/openfooddiary.sqlite in the container
  • OPENFOODDIARY_POSTGRES_CONNECTION_STRING: Connection string for usage if provider is postgres

Directories

Path Synopsis
cmd
server command
internal
server/generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL