Deploy SparkyFitness (w/ MCP)
MyFitnessPal style tracker: calories, workouts, water, weight, AI and MCP
sparkyfitness-db
Just deployed
/var/lib/postgresql
sparkyfitness
Just deployed
sparkyfitness-server
Just deployed
/data
Deploy and Host SparkyFitness on Railway
SparkyFitness is a self-hosted fitness and nutrition tracker in the spirit of MyFitnessPal. Log food with barcode and photo recognition, track workouts, water intake, body measurements and progress photos, set goals, and chat with Sparky, its built-in AI assistant. It also ships an MCP endpoint, so AI assistants like Claude can read and write your fitness data with your permission.
About Hosting SparkyFitness
This template deploys SparkyFitness v1.12.1 as three services: a Postgres 18 database, the API server, and the web app served by nginx. Only the web app is public. The API server and the database stay on Railway's private network, and the web app re-resolves the server's private address every 30 seconds, so it keeps working across server redeploys. The database and the server both get persistent volumes, so your data, uploaded photos and in-app backups survive redeploys. All secrets (database passwords, session signing key, data encryption key, your owner password) are generated at deploy time.
Common Use Cases
- Personal or household calorie counting and macro tracking without a subscription or ads
- Workout, water, sleep, body measurement and progress photo logging in one private place
- Connecting AI assistants to your nutrition data through the built-in MCP endpoint
- Syncing wearables and services like Garmin, Fitbit, Withings, Strava, Polar and Oura through the in-app integrations
Dependencies for SparkyFitness Hosting
Deployment Dependencies
- Upstream project: https://github.com/CodeWithCJ/SparkyFitness
- Docker images: codewithcj/sparkyfitness:v1.12.1, codewithcj/sparkyfitness_server:v1.12.1, postgres:18.7-alpine
Implementation Details
The deploy form asks for one value: SPARKY_FITNESS_OWNER_EMAIL, your login email. First boot takes about a minute while the server runs database migrations and creates your owner account.
Getting started:
- Open the sparkyfitness-server service, Variables tab, and copy SPARKY_FITNESS_OWNER_PASSWORD.
- Open the web app URL and sign in with your owner email and that password. The owner account is an admin. Change the password in your profile if you like; the variable is only used once, on first boot.
Public sign-up is closed by default (SPARKY_FITNESS_DISABLE_SIGNUP=true), so a stranger who finds your URL cannot create an account. To add household members, set it to false on the server service, let them sign up, then set it back to true.
Connecting an AI assistant over MCP: in the web app open Settings, create an API key, then point your MCP client at the /mcp path of your web app URL with the header Authorization: Bearer followed by the key.
Sparky AI chat: add a provider in Settings under AI service (Anthropic, OpenAI, Gemini, OpenRouter, Ollama and others) with your own API key.
Two secrets deserve care:
- BETTER_AUTH_SECRET signs sessions and encrypts two factor auth. Never change it after anyone enables 2FA, or they are locked out permanently.
- SPARKY_FITNESS_API_ENCRYPTION_KEY encrypts stored third party and AI provider API keys. Rotating it means re-adding those connections.
Optional variables you can add to the server service any time: SMTP for password resets (SPARKY_FITNESS_EMAIL_HOST, PORT, SECURE, USER, PASS, FROM) and OIDC single sign-on (SPARKY_FITNESS_OIDC_*).
The Garmin sync microservice is not included. It can be added as a fourth service later without touching this stack.
Why Deploy SparkyFitness on Railway?
Railway gives SparkyFitness exactly what a self-hosted health app needs: private networking between app and database, persistent volumes for your photos and backups, automatic TLS on your public URL, and one click deploys of the whole three service stack. Your health data stays in your own project, on infrastructure you control, for pennies a day.
Template Content
sparkyfitness-db
postgres:18.7-alpinesparkyfitness
codewithcj/sparkyfitness:v1.12.1sparkyfitness-server
codewithcj/sparkyfitness_server:v1.12.1SPARKY_FITNESS_OWNER_EMAIL
Your login email. The owner account is created with it on first boot, and it is promoted to admin.
