Getting Started - Jashan-randhawa/AI-FitnessTracker1 GitHub Wiki

๐Ÿš€ Getting Started

This guide walks you through setting up and running FitTrack AI locally on your development machine.


๐Ÿ“‹ Prerequisites

Ensure you have the following installed:

  • Node.js: >= 20.0.0 (Recommended: v20.x or v22.x)
  • npm: >= 8.0.0
  • MongoDB: Local MongoDB instance running at mongodb://localhost:27017 or a free MongoDB Atlas cluster
  • OpenRouter API Key: Free or paid key from openrouter.ai for AI coaching & vision nutrition analysis

๐Ÿ“ฅ 1. Clone the Repository

git clone https://github.com/Jashan-randhawa/AI-FitnessTracker1.git
cd AI-FitnessTracker1

โš™๏ธ 2. Backend Server Setup (server/)

Step 1: Install Dependencies

cd server
npm install

Step 2: Configure Environment Variables

Create a .env file in server/:

HOST=0.0.0.0
PORT=1337
NODE_ENV=development
CLIENT_URL=http://localhost:5173

# Database Connection
MONGODB_URI=mongodb://127.0.0.1:27017/fittrack
# Or MongoDB Atlas:
# MONGODB_URI=mongodb+srv://<user>:<password>@cluster0.mongodb.net/fittrack?retryWrites=true&w=majority

# Security & JWT Auth
JWT_SECRET=super_secret_jwt_random_key_fittrack_2026
JWT_EXPIRES_IN=30d

# Artificial Intelligence (OpenRouter)
OPENROUTER_API_KEY=sk-or-v1-your_openrouter_api_key_here
OPENROUTER_MODEL=openai/gpt-4o-mini
OPENROUTER_FALLBACK_MODEL=google/gemini-2.0-flash-001
LOG_LEVEL=info

# External Media & News APIs (Optional)
NEWS_API_KEY=your_newsapi_key
RAPIDAPI_KEY=your_rapidapi_key

# OAuth & Password Reset (Optional for basic local dev)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_CALLBACK_URL=http://localhost:1337/api/connect/google/callback
BREVO_API_KEY=your_brevo_api_key
EMAIL_FROM="FitTrack AI <[email protected]>"

Step 3: Run Unit Tests (Optional but Recommended)

npm test

Executes the 139-test suite across 37 suites covering authentication & JWT, dual sign-in matrix & password policies, signup email verification, Brevo transactional email resilience (F1โ€“F5), calorie/food estimation, AI prompt guardrails & fallback, structured logging with secret scrubbing, health checks, and production error masking using Node's native test runner (node --test).

Step 4: Launch the Backend

npm run dev

The server boots at http://localhost:1337 and automatically seeds initial fitness blog articles if the database collection is empty.


๐Ÿ’ป 3. Frontend Client Setup (client/)

Step 1: Install Dependencies

Open a second terminal window:

cd client
npm install

Step 2: Configure Client Environment

Create a .env file in client/:

VITE_API_URL=http://localhost:1337

(Note: Legacy VITE_STRAPI_API_URL is also supported for backward compatibility).

Step 3: Launch Vite Development Server

npm run dev

Open your browser and navigate to: ๐Ÿ‘‰ http://localhost:5173


๐Ÿงช Quick Test Flow

  1. Click Sign Up to create an account or use the quick login.
  2. Complete the onboarding questionnaire (Age, Height, Weight, Activity Level, Target Goal).
  3. Check your Dashboard to see your dynamic goal rings, hydration meter, and streak milestones!
  4. Navigate to Food Log or Activity Log to view the interactive 90-Day Calendar Heatmap, and test AI Food Snap or natural language meal estimation.
  5. Open AI Assistant to chat with FitBot about your training goals.
โš ๏ธ **GitHub.com Fallback** โš ๏ธ