Basic breastfeeding data analysis and tracking
The idea of this app stemmed from the need to track and visualize breastfeeding meal statistics stored in a Pandas DataFrame. This was the opportunity to learn how to create and deploy a web app based on python-based nicegui, an alternative to streamlit with better state management and handling of user interaction. It quickly expanded to learn even more how to develop python applications with best development practices like:
- formatting and linting with ruff
- deploying with GitHub Actions
- split code using a model-view-controller design pattern
- validate data using pydantic models
- keep track of changes using git-cliff
- managing a python environment using micromamba
- Testing the code prior to releasing using pytest
- Calculating the coverage of tests using coverage
- Typing python code and checking it with mypy
Huge thanks to the Open Source community for providing such great tools to the world.
- Protect access with password
- Record meals start and end times
- Lock start time of new meal
- Keep track of meal rounds during ongoing meal
- Reminders for daily intake of vitamins
- See latest three days trends in graphs
- See daily stats in a table
- Keep a log of daily memories
- Edit and delete any meal
- Prediction of next meal's time and duration (Facebook Prophet couldn't really predict accurately -- see #15. Perhaps additional metadata would help, or another algorithm may be more addapted)
The following instructions rely on the use of micromamba for managing python environment and nginx for the web server.
- Use
env.yaml
file to create your environment:micromamba env create -f env.yaml
- Copy
milk_tracker
folder in your web server area, e.g./var/www/
- Create an
.env
file within that folder with the following content:
APP_PORT=<port_number>
PASSWORD=<argon2 password hash as login>
STORAGE_SECRET=<passphrase to protect your storage area>
- Customize the
milk_tracker/config.yaml
file - Initialize the meal journal and memories log by renaming
assets/journal.template.xlsx
and resp.assets/memories.template.csv
intoassets/journal.xlsx
and resp.assets/memories.csv
- Use
scripts/milk-tracker.conf
as example to configure the redirection of http requests to your app using nginx and your own domain - Use
scripts/milk-tracker.service
as example to configure a systemd unit to manage the start/stop of the app - Enable the unit, e.g.
systemctl --user enable milk-tracker.service
if you're running the app using a specific user and choose to run user units - Start the app, e.g.
systemctl --user start milk-tracker.service
- Go to https://<your_domain>:<port_number> and start tracking :-)
MIT License
Copyright (c) 2024 Thomas Lamant