r/coolgithubprojects • • 3d ago

I built a free, self-hosted alternative to MyFitnessPal & MacroFactor: openCalory

Post image

I built this for myself because I wanted a fast nutrition tracker without subscriptions, account lock-in, or sluggish network requests every time I log a meal. Figured I'd clean it up, MIT-license it, and share it here in case anyone else wants to self-host it or contribute.

How it's built:

  • Offline-first: Reads and writes hit browser IndexedDB (Dexie.js) locally so logging feels instant, even with zero connection.
  • Optional self-hosted sync: Runs on SQLite locally (docker compose up -d) or Turso libSQL if deployed serverlessly, using 90-day tombstones for conflict-safe deletes across devices.
  • BYOK AI (optional): Hooks into any OpenAI-compatible vision endpoint (OpenRouter, Gemini, OpenAI, or local Ollama) for meal photo estimation and nutrition label OCR, with sliders to adjust gram weights before saving.
  • Adaptive TDEE & no-nonsense UI: Calculates weight trend smoothing and estimated adaptive TDEE without turning everything angry red when you go slightly over your calories.
  • Bundled food data: Includes ~2,500 offline whole-food staples alongside live USDA/Open Food Facts search, browser barcode scanning, and full JSON/CSV export.

Repo: https://github.com/NathanP278/openCalory

It's still evolving, so if you self-host it and run into edge cases or want to help improve the sync engine, regional food datasets, or UI, issues and PRs are super welcome!

228 Upvotes

19 comments sorted by

14

u/Fine_League311 2d ago

Devlopers & Fitness? Thats good, no time for it 😂

5

u/DealerEnough7389 2d ago

Haha fair point, that's literally why I added the AI meal scanning feature! You just snap a pic of your food on the go and move on. No time to sit there searching and weighing every gram when there's code to debug

1

u/Fine_League311 2d ago

Looks good but: Many people talk about how exercise extends your lifespan but what about all the time I spend doing it? Id rather stay fit and happy, and just die sooner! ⬇️

PS: I eat the usual stuff: gummy bears, coffee, chocolate, and yet I’m still thinner than all my colleagues; at 1.76 meters tall, I weigh only 82 kilos :D

2

u/DealerEnough7389 2d ago

Yeah I get that honestly. I'm in senior high school right now and my schedule is super jam-packed compared to when I was in highschool. So I also had a really hard time fitting in workouts and eating right at first

What clicked for me though is you don't need to spend 2-3 hours in the gym - 45-60 minutes is plenty. That's also the exact reason I built openCalory, just to save as much time as possible when tracking calories. Trust me, in the 1.5+ years since I started, I've noticed huge changes not just in my health and physique, but in other parts of my life too like discipline, focus, and energy. Definitely feels worth the time investment!!

5

u/Ok_Carry_8711 2d ago

Thank you! I need to remember to try to get this to work when I'm not busy.

2

u/DealerEnough7389 2d ago

No problem! Really open for any suggestions and feedback. Looking to improve this even more

3

u/ericthahalfabee 2d ago

Does the barcode scanning access some network of calorie and nutrition data?

I always assumed the reason to be paying for a big networked fitness app (at least now that vibe coding exists) is to access the network of food data.

2

u/DealerEnough7389 2d ago

Yep! Barcode scanning pulls from Open Food Facts, and regular search also uses USDA FoodData Central plus ~2,500 bundled offline staples. You're totally right though, a huge curated database is basically the main thing you're paying for with big apps. Open Food Facts is solid for common stuff, and if something's missing, you can just use the BYOK AI label OCR to snap a pic of the nutrition label and save it locally. Not quite as seamless as a massive paid database, but for free it gets you like 90% of the way there. 

2

u/green_stone 2d ago

This is awesome, thanks for building this! I just deployed it and I'm using it now.

Curious why you left out the weight goal feature of MacroFactor? Right now you can pick the calorie deficit rate, but there's no way to set a target weight. For beginners, it's hard to know what deficit to pick, most of us naturally think in terms of how many kg/lbs we want to lose, not how many calories.

1

u/DealerEnough7389 2d ago

Thanks, great to have people use this!

Reason to why the weight goal feature was not included, was because this was supposed to be a personal app, which I just then decided to share for free use. Since I already knew how many calories I needed, I didn’t think of adding it.

However, thanks to your feedback, it would be a great idea to implement this to the app. Will be working on this alongside a few more features to complete the feature set.

2

u/CleverDaddy24 1d ago

Hi! I Like it! Been thinking to make my own, but probably it's better fork yours and make some adjustment. Thank's!

1

u/DealerEnough7389 1d ago

Great to hear! If you have any feedback and suggestions, feel free to tell me!

1

u/thebig_lebowskii 1d ago

Just ripped the entire UI element from MacroFactor, did not even try doing something different. GG

2

u/DealerEnough7389 1d ago

No hiding that, I leaned heavily on MacroFactor's UI because I think it's the cleanest layout out there. Doe again, it’s just a free personal project I built for myself and shared in case anyone else wants a self-hosted option ^-^

3

u/AmuRAA 2d ago

could someone compare this to sparkyfitness?

1

u/ExaminationSerious67 1d ago

Looks interesting. I might check it out later

1

u/ExaminationSerious67 21h ago

I have been making my own food tracking software that closely matches this one, but, I never had the TDEE in it, I used the one that you posted. I have no need for some of the other things you have in your application, but thanks very much for what you did. I have added the MIT notice on my own private github page, is there anywhere else I need to have it. (this is a personal project only)

1

u/the-lazy-platypus 21h ago

Ive been debating building this myself.