Meal planning microservice.
Features:
-
Rest API (FastAPI)
-
Cron scripts to:
- Update menu in Notion everyday
- Add tasks to Todoist if some meal needs unfreezing the day before
- Dabatase backup to AWS
-
Notion integration.
-
Todoist integration.
Deployment is done via docker.
Note: these are the commands to create a release manually on your computer. You don't have to do this. The docker images are compiled with github actions, in the publish workflow.
# Build and push it to dockerhub
docker buildx build -t sralloza/meal-planner:$VERSION --platform=linux/arm/v7,linux/amd64,linux/arm64 --push .
# Build without pushing it to dockerhub
docker buildx build -t sralloza/meal-planner:$VERSION --platform=linux/arm/v7,linux/amd64,linux/arm64 --load .
You need to supply the following environment variables (required ones are marked with 🚩). Settings are grouped in categories.
- 🚩 API_TOKEN (
str
): token of the API. In order to use the API, users will have to provide this token in their requests via theX-TOKEN
header. - ENABLE_PROMETHEUS (
bool
): ifTrue
, the API will enable the prometheus endpoint/metrics
. Defaults toFalse
. - PRODUCTION (
bool
): ifTrue
the server will run on production environment. Defaults toFalse
. - DISABLE_CRON_INTEGRATION (
bool
) ifTrue
, the server will not launch cron jobs. It is useful to launch replicas, enabling cron integration in only one of them. It is also useful to deploy on Kubernetes, as the cron jobs can be implemented viaCronJob
.
- 🚩 AWS_ACCESS_KEY_ID (
str
): AWS access key id. - 🚩 AWS_SECRET_ACCESS_KEY (
str
): AWS secret access key. - 🚩 S3_BUCKET_NAME (
str
): name of the S3 bucket to save the backups. - S3_FILE_NAME (
str
): filename to save the backups in the AWS S3 Bucket. Defaults tomeals.json
.
- NOTION_ADD_DAY_AFTER_TOMORROW (
bool
): ifTrue
, the meals of the day after tomorrow will also be added to Notion. Defaults toTrue
. - 🚩 NOTION_BLOCK_ID (
uuid
): id of the notion block where the meals will be showed. - 🚩 NOTION_KEY (
str
): notion key to use the notion API.
- 🚩 TODOIST_PROJECT_ID (
int
): todoist project id where the tasks will be added. - 🚩 TODOIST_TOKEN (
str
): todoist token to use the todoist API.
- 🚩 MYSQL_DATABASE (
str
): database name. - 🚩 MYSQL_HOST (
str
): mysql host. - 🚩 MYSQL_PASSWORD (
str
): mysql password. - 🚩 MYSQL_PORT (
str
): mysql port. - 🚩 MYSQL_USER (
str
): mysql user. - WAIT_FOR_IT_ADDRESS (
str
): if is set, it will wait for the database to be ready for max 120 seconds. Must be set to$MYSQL_HOST:$MYSQL_PORT
. This switch should not be used in Kubernetes deployments, asinitContainers
are designed to cover this exact use case.
- LOCALE_WEEKDAY_NAMES (
list(str)
): weekday names, starting with Monday and ending with Sunday. Must contain 7 elements (one for each week day). - NULL_STR (
str
): string to represent an emptylunch1
ordinner
. Defaults toN/A
. - VARIABLE_STR (
str
): string to represent a variable meal. Defaults toVariable
. It's used in the/shift
endpoint, where all meals which are equal toVARIABLE_STR
will be treated as empty meals.
AWS and notion settings are currently needed. If you want to use this app without one of them (or both) add an issue and I'll make it optional and configurable.