{"id":31696710,"url":"https://github.com/danielabar/meal_composer","last_synced_at":"2025-10-08T17:15:31.167Z","repository":{"id":317117609,"uuid":"1066030647","full_name":"danielabar/meal_composer","owner":"danielabar","description":"A Rails app that generates ingredient-based meal plans from macro targets using USDA nutrition data and constrained optimization.","archived":false,"fork":false,"pushed_at":"2025-10-07T00:00:39.000Z","size":354,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-07T00:20:45.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielabar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T22:53:34.000Z","updated_at":"2025-10-06T23:16:06.000Z","dependencies_parsed_at":"2025-09-29T01:08:30.065Z","dependency_job_id":"fb530a19-64f5-4924-84a1-b0ba18150eee","html_url":"https://github.com/danielabar/meal_composer","commit_stats":null,"previous_names":["danielabar/meal_composer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielabar/meal_composer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielabar%2Fmeal_composer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielabar%2Fmeal_composer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielabar%2Fmeal_composer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielabar%2Fmeal_composer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielabar","download_url":"https://codeload.github.com/danielabar/meal_composer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielabar%2Fmeal_composer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278981534,"owners_count":26079641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-08T17:15:29.455Z","updated_at":"2025-10-08T17:15:31.159Z","avatar_url":"https://github.com/danielabar.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meal Composer\n\nA Rails application that generates meal plans based on target macro-nutrient goals.\n\n## Problem\n\nPeople following specific diets (keto, low-carb, bodybuilding, etc.) need to hit precise macro-nutrient targets daily. Manually planning meals to achieve exact gram targets for carbohydrates, protein, and fat is time-consuming and often results in repetitive, boring meal plans.\n\n## Solution\n\nThis app generates ingredient-based meal plans by:\n\n- Taking user-specified macro targets (e.g., 50g carbs, 100g protein, 150g fat)\n- Selecting foods from a comprehensive USDA nutrition database\n- Ensuring meal variety by requiring specific food categories per meal, currently fixed at:\n  - **Breakfast**: Dairy/eggs + cooking fats + fruits\n  - **Lunch**: Poultry + cooking fats + vegetables\n  - **Dinner**: Beef + cooking fats + vegetables\n- Calculating precise portions to meet daily macro targets within tolerance\n- Providing realistic, cookable meals (no raw meat without cooking fats)\n\n**Note**: This app provides ingredient quantities per meal, not recipes. For example, the output tells you how much chicken, broccoli, and olive oil you need for lunch, but not how to prepare them. This approach is ideal for people who want macro-precise meal planning without complexity. You avoid detailed cooking instructions, long ingredient lists, and exotic spices or sauces you may not have on hand.\n\nThe app uses a constrained optimization algorithm that balances nutritional accuracy with meal palatability and variety.\n\n## Requirements\n\n- Docker and Docker Compose\n- Ruby (version specified in `.ruby-version`)\n- PostgreSQL client (version matching `docker-compose.yml`)\n\n## Setup\n\n1. **Start the database**:\n   ```bash\n   docker-compose up\n   ```\n\n2. **First-time setup** (in another terminal):\n   ```bash\n   bin/setup\n   ```\n\n3. **Start the development server**:\n   ```bash\n   bin/dev\n   ```\n\nThe setup process will install dependencies, create the database, and load USDA nutrition data.\n\n## Usage\n\n**With default meal structure**\n\n```ruby\nmacro_targets = MacroTargets.new(carbs: 25, protein: 60, fat: 180)\nresult = ThreeIngredientComposer.new.compose_daily_meals(macro_targets: macro_targets)\n\nif result.composed?\n  puts result.daily_plan.pretty_print\nelse\n  puts \"Failed: #{result.error}\"\nend\n```\n\nSample output:\n```\n=== BREAKFAST ===\n127.5g of Cottage cheese, full fat, large or small curd\n58.5g of Oil, safflower\n17.9g of Kiwifruit (kiwi), green, peeled, raw\nBreakfast macros: carbs=8.3g, protein=15.0g, fat=60.0g\n\n=== LUNCH ===\n109.6g of Chicken, thigh, meat and skin, raw\n48.4g of Oil, sunflower\n130.5g of Cabbage, green, raw\nLunch macros: carbs=8.3g, protein=20.0g, fat=60.0g\n\n=== DINNER ===\n63.0g of Beef, round, top round roast, boneless, separable lean only, trimmed to 0\" fat, select, raw\n61.8g of Oil, corn\n144.6g of Mushroom, pioppini\nDinner macros: carbs=8.3g, protein=20.0g, fat=60.0g\n\n=== DAILY TOTALS ===\nTarget: 25.0g carbs, 60.0g protein, 180.0g fat\nActual: 24.999999999999993g carbs, 54.999999999999986g protein, 180.0g fat\nDifference: carbs 0.0g, protein -5.0g, fat 0.0g\nWithin tolerance: true\n```\n\n**With custom meal structure**\n\n```ruby\nmeal_structure = {\n  breakfast: [ \"Dairy and Egg Products\", \"Fats and Oils\", \"Vegetables and Vegetable Products\" ],\n  lunch: [ \"Finfish and Shellfish Products\", \"Fats and Oils\", \"Vegetables and Vegetable Products\" ],\n  dinner: [ \"Beef Products\", \"Fats and Oils\", \"Cereal Grains and Pasta\" ]\n}\nmacro_targets = MacroTargets.new(carbs: 100, protein: 150, fat: 95)\nresult = ThreeIngredientComposer.new.compose_daily_meals(macro_targets: macro_targets, meal_structure: meal_structure)\nif result.composed?\n  puts result.daily_plan.pretty_print\nelse\n  puts \"Failed: #{result.error}\"\nend\n```\n\nSample output:\n```\n=== BREAKFAST ===\n55.5g of Egg, white, dried\n28.3g of Oil, coconut\n202.6g of Corn, sweet, yellow and white kernels,  fresh, raw\nBreakfast macros: carbs=33.3g, protein=50.0g, fat=31.7g\n\n=== LUNCH ===\n256.1g of Fish, cod, Atlantic, wild caught, raw\n30.6g of Oil, corn\n449.7g of Beans, snap, green, raw\nLunch macros: carbs=33.3g, protein=50.0g, fat=31.7g\n\n=== DINNER ===\n188.1g of Beef, round, eye of round roast, boneless, separable lean only, trimmed to 0\" fat, select, raw\n25.8g of Oil, corn\n47.8g of Oats, whole grain, steel cut\nDinner macros: carbs=33.3g, protein=50.0g, fat=31.7g\n\n=== DAILY TOTALS ===\nTarget: 100.0g carbs, 150.0g protein, 95.0g fat\nActual: 99.99999999999999g carbs, 149.99999999999997g protein, 94.99999999999997g fat\nDifference: carbs 0.0g, protein 0.0g, fat 0.0g\nWithin tolerance: true\n```\n\n## Current Status\n\nEarly development. The algorithm successfully generates meal plans within macro tolerances but may require multiple attempts for very restrictive targets.\n\nThe meal structures can be customized wrt categories at each meal, but are limited to exactly three categories per meal. Future versions may include flexibility to customize the number of meals per day and the number of foods from each category within each meal.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielabar%2Fmeal_composer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielabar%2Fmeal_composer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielabar%2Fmeal_composer/lists"}