No description
- Python 100%
| .gitignore | ||
| api.py | ||
| cache.py | ||
| config.py.example | ||
| main.py | ||
| models.py | ||
| optimizer.py | ||
| README.md | ||
| renderer.py | ||
| requirements.txt | ||
| supplements.py | ||
| tui.py | ||
Muscle Feed Swap Planner
CLI + TUI tool for managing a Muscle Feed order via API:
- analyze and apply meal swaps (fat-first optimization)
- build daily supplement plans to close macro gaps
- inspect weekly supplement cost and shopping quantities
The app is optimized for a "no-cooking" workflow and currently targets:
- protein: ~180g/day (cap ~185 where possible)
- carbs: ~500g/day (prefer 490-510)
- fat: ~70g/day (hard cap 75 where feasible)
Features
- Authenticated Muscle Feed API integration (order/day/replacements/select)
- Day-by-day swap optimizer with constrained replacement options
- Auto-apply swaps to the order via API
- Supplement optimizer with quantity + amount tracking (g/ml)
- Weekly supplement cost + shopping list (qty + amount/week)
- Fast Textual TUI with:
- cached startup snapshot
- background live refresh
- non-blocking skip-combo computation for high-fat days
Requirements
- Python 3.11+ (tested on modern Python)
- Internet access to
https://muscle-feed.co.il
Install deps:
python -m pip install -r requirements.txt
Configuration
- Copy the template:
cp config.py.example config.py
- Fill in your values in
config.py:
ORDER_IDEMAILPASSWORD
Usage
TUI (default)
python main.py
or explicitly:
python main.py tui
Main keys:
Enter: open selected dayw: weekly supplement summaryr: trigger live refreshq: quit (from main screen)Ctrl+q: quit globally
Day detail keys:
a: apply suggested swaps for this dayEsc/b: back
CLI commands
python main.py analyze # analyze all days
python main.py analyze --apply # analyze and apply all swaps
python main.py apply # apply already-recommended swaps
python main.py day <day_id> # inspect one day deeply
python main.py plan # full daily + weekly supplement plan
Performance model
On startup, the TUI uses a 2-phase flow:
- load cached snapshot (
.mf_cache.json) and render immediately - refresh live data in background and patch UI when done
This gives near-instant perceived startup while still keeping data fresh.
Project layout
main.py- CLI entrypointtui.py- Textual application and screensapi.py- Muscle Feed API clientoptimizer.py- swap optimization logicsupplements.py- supplement catalog + optimizer + cachesrenderer.py- rich CLI renderingmodels.py- dataclassescache.py- startup snapshot serializationconfig.py.example- config template
Dev checks
Quick syntax check:
python -m py_compile main.py tui.py api.py optimizer.py supplements.py cache.py
Smoke checks:
python main.py day 167416
python main.py plan
Notes
- Replacements are limited by what the API returns for each day/slot.
- Some days may remain
PARTIALif no low-fat alternatives exist. - Fat-heavy days can use skip suggestions + supplement refill logic.