KaloriN AI is a nutrition tracking web app with AI-powered food scanning, meal logging, personalized recommendations, BMI-based calorie targets, and weekly nutrition insights.
| Layer | Technology |
|---|---|
| Frontend | React, Vite, Tailwind CSS, React Router, Firebase Auth |
| Backend | Node.js, Express, Prisma |
| Database | Supabase PostgreSQL |
| AI Service | FastAPI, TensorFlow/Keras, scikit-learn, Gemini |
| Cache | Redis |
.
├── frontend/ # React app
├── backend/ # Express API and Prisma schema
├── ai_service/ # FastAPI AI microservice and ML assets
├── APP_LOGIC_DOCUMENTATION.md
├── BACKEND_DOCUMENTATION.md
└── USER_GUIDE.md
Install these before running the full app:
- Node.js 18+ and npm
- Python 3.10+
- Supabase PostgreSQL project
- Firebase project with Authentication enabled
- Gemini API key
- Redis (optional, recommended for caching)
Create local .env files in each service. Do not commit real secrets.
VITE_API_URL=http://localhost:5000Firebase config is currently set in frontend/src/config/firebase.js.
PORT=5000
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/postgres
DIRECT_URL=postgresql://USER:PASSWORD@HOST:PORT/postgres
AI_URL=http://localhost:8000
AI_TIMEOUT=15000
REDIS_URL=redis://localhost:6379
FIREBASE_SERVICE_ACCOUNT_BASE64=base64_encoded_firebase_service_account_json
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
SUPABASE_URL=https://PROJECT_ID.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
SUPABASE_AVATAR_BUCKET=avatars
# Optional external recipe APIs
SPOONACULAR_API_KEY=
EDAMAM_APP_ID=
EDAMAM_APP_KEY=Notes:
FIREBASE_SERVICE_ACCOUNT_BASE64is used by backend to verify Firebase ID tokens.CORS_ORIGINSis a comma-separated allowlist.SUPABASE_SERVICE_ROLE_KEYmust remain server-side only.
GOOGLE_API_KEY=your_gemini_api_key
REDIS_URL=redis://localhost:6379
GEMINI_TIMEOUT_SECONDS=12git clone https://github.com/ryhndastra/kalorin-ai.git
cd kalorinAicd backend
npm install
npx prisma generate
npx prisma migrate dev
npx prisma db seed
npm run devBackend runs at http://localhost:5000.
cd ai_service
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000AI service runs at http://localhost:8000.
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173.
redis-serverIf Redis is not running, the app still works but AI caching is reduced.
| Route | Access | Description |
|---|---|---|
/ |
Guest | Landing page |
/analyze |
Guest/User | Food scan and food search |
/login |
Guest | Sign in |
/register |
Guest | Create account |
/home |
User only | Dashboard |
/meals |
User only | AI meal recommendations |
/track |
User only | Daily meal tracking |
/insights |
User only | Weekly nutrition insights |
/profile |
User only | Profile, body stats, goals, and account name |
Protected routes are guarded in the frontend.
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/ |
Backend health check |
GET |
/api/foods |
Get master food list |
GET |
/api/foods/search?keyword=... |
Search foods |
GET |
/api/foods/:id |
Get one food |
POST |
/api/profile |
Create or update profile |
GET |
/api/profile/:userId |
Get profile, BMI, targets, and today's stats |
POST |
/api/track/add |
Add meal log |
GET |
/api/track/logs |
Get daily logs |
POST |
/api/ai/food-list |
Get recommended food list |
POST |
/api/ai/food-detail |
Get AI explanation for one food |
GET |
/api/insights/* |
Weekly insights endpoints |
POST |
/api/scanner/scan-food |
Analyze uploaded food image |
More backend details: BACKEND_DOCUMENTATION.md.
Prisma schema: backend/prisma/schema.prisma
Main models:
ProfileFoodDailyLogDailyInsight
Seed data: backend/data/nutrition_data.json
Run services in separate terminals:
# Terminal 1
cd backend
npm run dev
# Terminal 2
cd ai_service
source .venv/bin/activate
uvicorn main:app --reload --port 8000
# Terminal 3
cd frontend
npm run dev- Set up modular architecture (
frontend,backend,ai_service) - Implemented Firebase authentication (email/password + Google)
- Added profile onboarding and BMI/calorie/protein target calculation
- Built AI food scanner integration
- Built food recommendation and explanation flow
- Added daily tracking and weekly insight modules
- Added guest mode for limited access
- No end-to-end test suite yet
- Some external API integrations are optional and key-dependent
- Redis is optional but affects recommendation/explanation caching quality
APP_LOGIC_DOCUMENTATION.md- app flow and architecture notesBACKEND_DOCUMENTATION.md- backend implementation detailsUSER_GUIDE.md- non-technical usage guide
# Frontend
cd frontend
npm run dev
npm run build
npm run lint
# Backend
cd backend
npm run dev
npx prisma studio
npx prisma db seed
# AI service
cd ai_service
uvicorn main:app --reload --port 8000- Authenticated users must complete birthdate, weight, and height before using protected features.
- Guest users can access only landing and food analysis pages.