Skip to content

Hariksh/Adaptive-Fitness-AI-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adaptive Fitness AI Chatbot

Status Tech Stack

A smart, personality-adaptive fitness companion that grows with you. This application uses Google's Gemini AI to provide personalized fitness coaching based on user personality, usage duration, and lifestyle data.

Download APK

You can download the Android APK directly from this repository:

Place the AdaptiveFitnessAI.apk file in the apk/ folder (or replace the placeholder there) so the above link works, or attach the APK to a GitHub Release for distribution.


Demo Video

Watch Project Demo


Key Features

1. Adaptive AI Personality Engine

The core of the application is an AI that shifts its tone based on your personality type:

  • Type A (The Encouragement Seeker): Warm, supportive, and positive coaching.
  • Type B (The Creative Explorer): Fun, unconventional, and adventurous advice.
  • Type C (The Goal Finisher): Direct, efficient, and no-nonsense guidance.

2. Usage Duration Logic

The AI adapts its coaching style based on how long you've been using the app:

  • New User (< 3 days): Empathetic and grounded onboarding.
  • Week 1 (< 8 days): Friendly listening and habit building.
  • Regular User (> 8 days): Seasoned coaching and advanced tips.

3. Customizable Profile & Context Injection

Users can update their Age, Height, Weight, and Fitness Goal directly in the app. The AI automatically reads this updated profile before every response to provide age-appropriate and goal-specific advice.

4. Lifestyle Integration (Dummy Data)

Demonstrates the ability to use context from wearables by injecting dummy data into the AI context:

  • Steps: Tracks daily movement.
  • Exercise: Monitors workout minutes.
  • Sleep: Considers rest for recovery advice. Note: This data is currently mocked for demonstration purposes.

5. Safety Guardrails & RAG-lite

  • Medical Safety: The AI is strictly instructed to refuse providing medical diagnoses or advice on injuries.
  • Knowledge Base: Uses a "RAG-lite" approach (Retrieval Augmented Generation) to inject verified fitness facts into the system prompt for accurate answers.

AI Implementation Details

This section details the Prompt Engineering and Logic used to drive the adaptive behavior.

Prompt Composition Strategy

The system prompt is dynamically assembled in backend/services/geminiService.js before every API call. It combines:

  1. Personality System Instruction (selected based on user profile).
  2. Duration Instruction (selected based on signup date).
  3. Knowledge Context (injected knowledgeBase.js data).
  4. User Profile & Dummy Lifestyle Data.

Usage Logic

  • Core Logic: if (usageDays <= 3) ... else if (usageDays <= 8) ...
  • Effect: Ensures new users aren't overwhelmed, while regular users get efficient advice.

Safety Refusal Handling

The System Prompt includes strict negative constraints:

  • "Do NOT provide medical diagnosis."
  • "If they ask about medical/injury, Say: 'I cannot give medical advice. Please see a doctor.'"

AI Tools Used

  • Model: Google Gemini gemini-2.5-flash
  • SDK: @google/generative-ai

Tech Stack

  • Frontend: React Native (Expo)
  • Backend: Node.js, Express.js
  • Database: MongoDB
  • AI Engine: Google Gemini API (gemini-2.5-flash)

Prerequisites

Before running the project, ensure you have the following installed:

  • Node.js (v14 or higher)
  • npm
  • Expo Go app on your physical device (Android/iOS) or an Emulator.
  • MongoDB Connection URI (Local or Atlas)
  • Google Gemini API Key

Installation & Setup

1. Backend Setup

Navigate to the backend directory and install dependencies:

cd backend
npm install

Create a .env file in the backend directory with the following variables:

PORT=8000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
GEMINI_API_KEY=your_google_gemini_api_key
GEMINI_API_KEY_2=optional_backup_key

Start the backend server:

npm start
# or for development with auto-restart:
npm run dev

2. Frontend Setup

Open a new terminal, navigate to the frontend directory, and install dependencies:

cd frontend
npm install

Start the Expo development server:

npm start
  • Scan the QR code with the Expo Go app on your phone.
  • Press a to run on Android Emulator or i to run on iOS Simulator (if configured).

API Endpoints

The backend provides the following RESTful API routes:

Route Description
/api/auth User registration and login.
/api/chat Interactions with the Gemini AI coach.
/api/workouts Logging and retrieving workout data.
/api/meals Logging nutrition and calories.
/api/weight Tracking weight progress.

Project Structure

Adaptive-Fitness-AI-Chatbot/
├── backend/             # Node.js/Express Server
│   ├── controllers/     # Route logic
│   ├── models/          # Mongoose Schemas
│   ├── routes/          # API Endpoints
│   ├── services/        # Gemini AI Integration
│   └── server.js        # Entry point
├── frontend/            # React Native Expo App
│   ├── src/
│   │   ├── components/  # Reusable UI components
│   │   ├── screens/     # App screens (Chat, Profile, etc.)
│   │   └── navigation/  # App navigation setup
│   └── App.js           # Entry point
├── AI_README.md         # Detailed AI prompt engineering docs
└── README.md            # Main documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published