--- title: FitCal Tracker colorFrom: green colorTo: blue sdk: docker app_port: 7860 pinned: false --- # FitCal Tracker A personal weight-loss tracker with daily logs, weekly targets, iPhone Health imports, calorie budgeting, and OpenAI-powered food-photo calorie estimates. This is a separate project and can be pushed/deployed independently from the video repo. ## Features - Start weight, target weight, target date, weekly loss target, height, age, sex, activity level, and step goal. - Daily weight, steps, active calories, walking/running distance, notes, meals, and workouts. - Weekly target cards modeled after a coach-style check-in sheet. - Calorie budget from Mifflin-St Jeor BMR, activity multiplier, and weekly deficit target. - Food photo analysis via OpenAI vision with structured calorie/macros output. - Apple Health import through JSON paste or an Apple Shortcut POST. - PWA install support and local-first browser storage. - Optional server sync protected by `APP_ACCESS_TOKEN`. - Docker, Render, and Cloud Run deployment files. ## Run Locally ```bash cd fitcal-tracker cp .env.example .env python app.py ``` Open [http://localhost:8080](http://localhost:8080). For food photo analysis, set: ```bash export OPENAI_API_KEY="sk-..." export OPENAI_MODEL="gpt-5.5" python app.py ``` ## iPhone Steps and Active Calories Browser apps cannot directly read Apple Health. Use one of these routes: - Paste Apple Health JSON into the iPhone Health panel. - Create an Apple Shortcut that sends a daily POST to `/api/health-import`. See [docs/iphone-shortcuts.md](docs/iphone-shortcuts.md). ## Deploy on Render Render is the easiest free backend host for this version. Render's Free web services work for Python apps, but the local filesystem is ephemeral on the free plan. That is okay for this app because your primary data storage is the browser and export backup. Treat server sync on the free plan as temporary unless you add a database later. 1. Push this repo to GitHub. 2. Create a new Render Blueprint or Web Service from the repo. 3. Use the included `render.yaml`; it is set to `plan: free`. 4. Set secret env vars: - `OPENAI_API_KEY` - `APP_ACCESS_TOKEN` If you skip `OPENAI_API_KEY`, the app still runs, but food photo calorie analysis will not work until the key is set. ## Deploy on Hugging Face Spaces Create a Docker Space and push this repo: ```bash huggingface-cli repo create fitcal-tracker --type space --space_sdk docker -y git remote add space https://huggingface.co/spaces/ManishThota/fitcal-tracker git push space main ``` Add Space secrets in Settings: - `APP_ACCESS_TOKEN` - `OPENAI_API_KEY` ## Deploy on Cloud Run ```bash gcloud run deploy fitcal-tracker \ --source . \ --region us-central1 \ --allow-unauthenticated \ --memory 512Mi \ --timeout 120 ``` Then set secrets or environment variables for `OPENAI_API_KEY` and `APP_ACCESS_TOKEN`. Cloud Run file storage is ephemeral unless you connect a persistent backing store. For long-term server sync, Render with the included disk is simpler. ## GitHub Create the remote after the local repo exists: ```bash gh repo create fitcal-tracker --private --source . --remote origin --push ``` ## Data and Privacy The app stores logs in the browser by default. Food photos are compressed in the browser and sent to your backend only when you press Analyze. The backend sends that image to OpenAI for calorie estimation. This app is for personal tracking and is not medical advice. Calorie estimates from photos are approximate.