Tools to help track and measure household groceries.
Daniel Sheffield 5ee550a53d add mapping directives | před 1 týdnem | |
---|---|---|
app | před 6 měsíci | |
archive | před 2 roky | |
db | před 4 týdny | |
recipes | před 8 měsíci | |
sqlpage | před 3 týdny | |
test | před 7 měsíci | |
.gitignore | před 2 roky | |
LICENSE | před 7 měsíci | |
convert_to_mealie.py | před 8 měsíci | |
docker-compose.yml | před 2 týdny | |
example.sql | před 2 týdny | |
grocery_transactions.py | před 1 týdnem | |
grocery_transactions.sh | před 1 týdnem | |
maintenance.sql | před 1 rokem | |
mealie_units.json | před 8 měsíci | |
mock.py | před 2 roky | |
price_check.py | před 1 rokem | |
readme.md | před 7 měsíci | |
recipe.py | před 1 rokem | |
reconcile.py | před 1 týdnem | |
requirements.txt | před 1 rokem | |
run.sh | před 2 týdny | |
scratch.sql | před 2 roky | |
units.sql | před 1 rokem |
This a database driven app - meaning it's all about the data and nothing but the data.
The database is assumed to be postgresql, but any modern relational database should work with some tweaks.
The following apps make the data useful:
grocery_transactions.py
- facilitate data entry with a TUIprice_check.py
- show price history graph per product (TUI)SQLPage
- basic website to view price trendsThe database itself is designed to be the first class UI.
This is because I wanted data integrity first and foremost, and I wanted to be able to start using the data without need for a UI (I hate UI development).
However, there are helper tools to ease the workflow.
This is a python
+ urwid
TUI to help make data entry easy.
Once done, the app can be exited by hitting ESC on the keyboard.
The result is a .txn
file that can be commited to the database using grocery_transactions.sh
Not all features of the database are supported including (needs to be done manually for now):
This is another python
+ urwid
TUI to look up products to see their price history.
It's designed to be usable on mobile (I use termux and have a shortcut to ssh into a jumphost)
SQLPage is a lightweight webserver written in Rust and generates web pages from SQL.
Features the SQLPage grocery website provides:
The schema is designed to protect data from human error.
Stored procedures are supplied where CHECK
constraints can not be used to prevent all invalid usage.
All the helper apps are written it python
psycopg
is used heavily.
No ORM is used in any apps.
Remember the database is designed to keep queries simple.
Queries are built up from SQL fragments in app. While postgresql is assumed, it should be straight forward to replace the db connection with another RBDMS db connecion and adjust query syntax where needed.
Some window functions are used it the TUI apps but only because it was convienient at the time. This is the most significant thing that may need reworking to interact with other RBDMS.
Some client side data transforms are done with pandas
.
SQLPage provides web components out-of-the-box to generate beautiful web pages.
I make heavy use of the table, form and chart components.
The filter options are internally stored as JSON format and stored in a cookie to preserve the filter on page changes.
I'll revisit this later with aim to avoid using cookies entirely.
pip3 install -r requirements.txt
Enter receipt from New World (TUI)
python3 grocery_transactions.py 2023-06-02-NW.txn
Commit when done
# check all is looking good first
./grocery_transactions.sh -d 2023-06-02 < 2023-06-02-NW.txn
# then commit (supply -c)
./grocery_transactions.sh -d 2023-06-02 -c < 2023-06-02-NW.txn
Check prices (TUI)
python3 price_check.py
Check the web inerface: https://shandan.one/grocery/internal/apply.sql?title=Trend&apply=Apply&groups[]=Fish%2C+Meat%2C+Eggs