No description
Find a file
2026-05-16 13:54:26 +03:00
.gitignore initial 2026-04-15 21:24:23 +03:00
api.py update api cus it got changed, also automatic way to find orderids 2026-05-14 19:12:48 +03:00
cache.py initial 2026-04-15 21:24:23 +03:00
config.py.example initial 2026-04-15 21:24:23 +03:00
main.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00
models.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00
optimizer.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00
README.md initial 2026-04-15 21:24:23 +03:00
renderer.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00
requirements.txt initial 2026-04-15 21:24:23 +03:00
supplements.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00
tui.py remove hardcoded nutritional targets, use config.py as single source of truth 2026-05-16 13:54:26 +03:00

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

  1. Copy the template:
cp config.py.example config.py
  1. Fill in your values in config.py:
  • ORDER_ID
  • EMAIL
  • PASSWORD

Usage

TUI (default)

python main.py

or explicitly:

python main.py tui

Main keys:

  • Enter: open selected day
  • w: weekly supplement summary
  • r: trigger live refresh
  • q: quit (from main screen)
  • Ctrl+q: quit globally

Day detail keys:

  • a: apply suggested swaps for this day
  • Esc / 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:

  1. load cached snapshot (.mf_cache.json) and render immediately
  2. 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 entrypoint
  • tui.py - Textual application and screens
  • api.py - Muscle Feed API client
  • optimizer.py - swap optimization logic
  • supplements.py - supplement catalog + optimizer + caches
  • renderer.py - rich CLI rendering
  • models.py - dataclasses
  • cache.py - startup snapshot serialization
  • config.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 PARTIAL if no low-fat alternatives exist.
  • Fat-heavy days can use skip suggestions + supplement refill logic.