DEV Community

LePhuongTrung
LePhuongTrung

Posted on

How I Built an Intelligent, Budget-Friendly Meal Planner to Refactor My Fitness Journey

Every software engineer knows the concept of refactoring—improving the internal structure of code without changing its external behavior. But a few months ago, I decided to apply this exact mindset to a different kind of system: my own body.

As a full-stack developer navigating a serious fitness and body recomposition journey, I quickly hit a major bottleneck that wasn't code-related. It was meal prepping. Calculating macro targets (Protein, Carbs, Fats) manually on Excel is tedious. Worse, trying to balance those nutrient goals with a strict weekly budget while avoiding foods I dislike felt like solving an NP-hard problem every single Sunday.

So, instead of complaining, I did what any developer would do: I built a web application to automate it.

The Core Product Workflow
I designed the application to be completely streamlined, focusing on constraints that matter to real people: fitness goals, budget restrictions, and personal food preferences.

  1. Dynamic Constraint Setting (Goal & Budget) The workflow starts by letting the user choose their fitness direction—either Cut (caloric deficit for fat loss) or Bulk (caloric surplus for clean muscle gain).

Next is the strict budget input. The system is smart enough to calculate a baseline budget based on the user's physical metrics. If you try to input an unrealistic budget, the system warns you. For my current cutting phase, I locked in a budget of 700,000 VND/week (~$27 USD).

Goal and budget setup

Figure 1: English localized UI for goal and weekly budget configuration (700,000 VND / ~$27 USD).

  1. Preference Filtering (Blacklisting Ingredients) We all have foods we absolutely refuse to eat. Whether it's pork liver, specific greens, or seafood, the app allows users to toggle off ingredients. The backend algorithm dynamically excludes these food items from the pool before generating the menu.

Disliked ingredients checklist

Figure 2: Ingredient blacklist interface showing localized Vietnamese data layer mapped against an English UI framework.

  1. Smart Weekly Menu Generation Once you hit "Generate", the application builds a customized weekly meal plan. For instance, looking at my generated Sunday menu, the app successfully hit a highly optimized macro profile: 1350 kcal, 95g Protein, 199g Carbs, and 20g Fats. It broke the meals down into delicious, budget-friendly options like pan-seared tilapia fillets, boiled sweet potatoes, and steamed carrots.

Weekly meal plan generator

Figure 3: Weekly view and single-day macro breakdown using localized clean-eating ingredients.

  1. Consolidated Automated Shopping List The biggest time-saver is the automated grocery list aggregation. The app parses the entire week’s menu, calculates the exact weight needed for every ingredient, and presents a checkbox list.

According to the app, I needed exactly 1086g of tilapia fillet (costing around 84,972 VND) and 1053g of raw sweet potatoes (76,253 VND) for the week. The final calculated cost for the entire week came out to just 501,707 VND—well under my 700k budget!

Automated grocery shopping list

Figure 4: Automated grocery list aggregating exact weights. The algorithm successfully optimized the total cost well below the 700k limit.

The Engineering Behind the Scenes (Tech Stack)
To keep the system highly responsive, type-safe, and capable of scaling into a mobile app later, I leveraged a modern full-stack ecosystem:

Frontend: React / Next.js with a dark-themed, sleek user interface optimized for scannability.

Backend: Node.js & NestJS managing the heavy data parsing, modular routing, and ingredient databases.

Language: TypeScript end-to-end to ensure robust type-safety across data payloads.

How the Algorithm Thinks
The fundamental challenge was mapping fluid monetary constraints against fixed nutritional values. The database stores individual ingredients with their respective market prices per gram and their nutritional profile (P/C/F per 100g).

The application core filters out the blacklisted items first, estimates the daily caloric target based on body data, and then executes a matching mechanism to find the cheapest combinations of ingredients that successfully fulfill the required macro distribution.

🌐 A Smart Approach to Hybrid Localization
If you look closely at the application screenshots, you will notice an interesting architectural choice: The Frontend UI is fully localized in English, while the dynamic dataset (ingredients like "Bắp bò tươi", "Chả lụa") remains in Vietnamese. This is a deliberate Hybrid Localization strategy.

Frontend Presentation Layer: All static text, user instructions, navigation buttons, and system alerts are handled via localization JSONs, making the application immediately friendly to an international audience or English-speaking expats.

Dynamic Data Layer: The core database—storing ingredient names, localized nutrition profiles, and historical market pricing—is kept in the regional language. Why? Because these items are tightly coupled with physical inventory at local Vietnamese supermarkets, traditional wet markets, and regional grocery costs.

By separating the UI translation layer from the localized data layer, the system remains highly accurate for the target market's budget calculation, while the codebase is structurally prepared to scale globally just by swapping the underlying ingredient database.

What’s Next?
Building this tool in public has drastically optimized my weekly developer routine and body metrics. No more guessing at the grocery store, no more macro calculation errors, and zero wasted budget.

Moving forward, I am planning to expand this system into a cross-platform mobile application, integrate voice-transcription AI to allow seamless hands-free food logging, implement an LLM-driven cooking instruction assistant, and expand multi-language localization to global ingredient databases.

🔗 Connect With Me & Follow the Journey
I am actively building this project in public and regularly sharing deep-dives, architectural updates, and my personal fitness transformation. Let's connect!

Discover my engineering work: Check out my personal project hub at lephuongtrung.id.vn to see my portfolio and active dev experiments.

Watch the app in action: Follow my "Refactor Body" series on TikTok @lephuongtrung to see real-world grocery shopping, meal prepping, and lifting routines.

How do you manage your meal preps and fitness goals as a developer? I’d love to hear your thoughts, feature ideas, or tech suggestions in the comments below!

Feel free to drop a comment, reaction, or follow my blog here on Hashnode if you want to see more content blending Software Engineering and FitTech!

Top comments (0)