NutriPostureAI

Stars
9
Updated

NutriPostureAI šŸŽšŸ§˜

An AI-powered React Native mobile application that combines nutrition tracking and posture monitoring to help users maintain a healthy lifestyle.

Features

šŸ½ļø Nutrition Tracking

  • AI Food Recognition: Take a photo of your meal and get instant nutritional analysis
  • Automatic Calorie Counting: AI identifies food items and calculates calories, protein, carbs, and fat
  • Meal History: Track your daily nutrition intake with detailed meal logs
  • Nutrition Goals: Set and monitor personalized nutrition targets

🧘 Posture Monitoring

  • Real-time Posture Detection: AI analyzes your sitting posture in real-time
  • Posture Alerts: Get notifications when your posture needs correction
  • Posture Tips: Receive personalized recommendations for better posture
  • Progress Tracking: Monitor your posture improvement over time

šŸ“Š Health Analytics

  • Progress Visualization: Beautiful charts showing your nutrition and posture progress
  • Daily Summaries: Get insights into your daily health patterns
  • Goal Tracking: Monitor progress towards your health goals

šŸ”§ Smart Features

  • Offline Support: Works without internet connection
  • Data Sync: Cloud backup with Firebase integration
  • Customizable Settings: Personalize notifications and monitoring preferences
  • Export Data: Download your health data for analysis

Tech Stack

  • Frontend: React Native with TypeScript
  • State Management: Redux Toolkit
  • Navigation: React Navigation
  • AI/ML: TensorFlow.js with TensorFlow Lite models
  • Camera: React Native Vision Camera
  • Storage: AsyncStorage for local data, Firebase for cloud sync
  • UI Components: Custom components with modern design

Project Structure

NutriPostureAI/
ā”œā”€ā”€ App.tsx                 # Main app component
ā”œā”€ā”€ package.json            # Dependencies and scripts
ā”œā”€ā”€ app.json               # React Native configuration
ā”œā”€ā”€ babel.config.js        # Babel configuration
ā”œā”€ā”€ metro.config.js        # Metro bundler configuration
ā”œā”€ā”€ assets/                # Static assets
│   └── images/           # App images and icons
ā”œā”€ā”€ components/            # Reusable UI components
│   ā”œā”€ā”€ CameraView.tsx    # Camera interface for food/posture capture
│   ā”œā”€ā”€ MealCard.tsx      # Meal display component
│   ā”œā”€ā”€ PostureAlert.tsx  # Posture warning component
│   └── ProgressBars.tsx  # Progress visualization
ā”œā”€ā”€ screens/              # App screens
│   ā”œā”€ā”€ HomeScreen.tsx    # Dashboard with overview
│   ā”œā”€ā”€ MealLogScreen.tsx # Meal logging interface
│   ā”œā”€ā”€ PostureScreen.tsx # Posture monitoring
│   ā”œā”€ā”€ SettingsScreen.tsx # App settings
│   └── AuthScreen.tsx    # Login/registration
ā”œā”€ā”€ navigation/           # Navigation configuration
│   └── AppNavigator.tsx  # Main navigation setup
ā”œā”€ā”€ redux/               # State management
│   ā”œā”€ā”€ store.ts         # Redux store configuration
│   └── slices/          # Redux slices
│       ā”œā”€ā”€ mealSlice.ts # Meal state management
│       └── postureSlice.ts # Posture state management
ā”œā”€ā”€ utils/               # Utility functions
│   ā”œā”€ā”€ tfSetup.ts       # TensorFlow initialization
│   ā”œā”€ā”€ classifyFood.ts  # Food classification logic
│   ā”œā”€ā”€ detectPosture.ts # Posture detection logic
│   └── localDB.ts       # Local database operations
ā”œā”€ā”€ models/              # AI models
│   ā”œā”€ā”€ foodClassifier.tflite # Food classification model
│   └── poseModel.tflite     # Pose detection model
ā”œā”€ā”€ data/                # Static data
│   └── foodDatabase.json    # Nutritional database
ā”œā”€ā”€ firebase/            # Firebase configuration
│   └── config.ts        # Firebase setup
└── README.md            # Project documentation

Installation

Prerequisites

  • Node.js (v16 or higher)
  • React Native CLI
  • Android Studio (for Android development)
  • Xcode (for iOS development, macOS only)

Setup Instructions

  1. Clone the repository

    git clone https://github.com/yourusername/NutriPostureAI.git
    cd NutriPostureAI
    
  2. Install dependencies

    npm install
    
  3. Install iOS dependencies (macOS only)

    cd ios && pod install && cd ..
    
  4. Configure Firebase

    • Create a Firebase project
    • Update firebase/config.ts with your Firebase configuration
    • Enable Authentication, Firestore, and Storage
  5. Configure TensorFlow Models

    • Replace placeholder model files in models/ with actual trained models
    • Update model loading code in utils/tfSetup.ts
  6. Run the app

    # For iOS
    npm run ios
    
    # For Android
    npm run android
    

AI Models

Food Classification Model

  • Purpose: Identify food items from photos
  • Input: 224x224x3 RGB image
  • Output: Food classification with confidence scores
  • Training: Transfer learning from ImageNet, fine-tuned on food datasets

Pose Detection Model

  • Purpose: Detect human pose and analyze posture
  • Input: 256x256x3 RGB image
  • Output: 17 keypoints with confidence scores
  • Training: Transfer learning from ImageNet, fine-tuned on pose datasets

API Reference

Food Classification

import { classifyFood } from './utils/classifyFood';

const result = await classifyFood(imagePath);
// Returns: { foodName, confidence, calories, protein, carbs, fat, imagePath, suggestions }

Posture Detection

import { detectPosture } from './utils/detectPosture';

const result = await detectPosture(imagePath);
// Returns: { posture, confidence, keypoints, imagePath, suggestions, score }

Local Database

import localDB from './utils/localDB';

// Save meal data
await localDB.addMeal(mealData);

// Get user settings
const settings = await localDB.getUserSettings();

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

Code Style

  • Use TypeScript for all new code
  • Follow React Native best practices
  • Use functional components with hooks
  • Implement proper error handling
  • Add comprehensive comments for complex logic

Testing

  • Write unit tests for utility functions
  • Test Redux actions and reducers
  • Test component rendering and interactions
  • Test AI model integration

Performance

  • Optimize image processing for mobile devices
  • Implement proper memory management for TensorFlow
  • Use lazy loading for heavy components
  • Optimize bundle size

Deployment

Android

  1. Generate signed APK
  2. Test on multiple devices
  3. Upload to Google Play Store

iOS

  1. Archive the project in Xcode
  2. Test on multiple devices
  3. Upload to App Store Connect

Troubleshooting

Common Issues

  1. TensorFlow initialization fails

    • Ensure TensorFlow.js is properly installed
    • Check model file paths
    • Verify device compatibility
  2. Camera permissions denied

    • Check app permissions in device settings
    • Ensure proper permission handling in code
  3. Firebase connection issues

    • Verify Firebase configuration
    • Check network connectivity
    • Ensure Firebase services are enabled

Debug Mode

# Enable debug logging
export DEBUG=nutri-posture-ai:*

# Run with debug information
npm run start -- --reset-cache

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • TensorFlow.js team for the excellent ML framework
  • React Native community for the robust mobile framework
  • Food-101 and COCO datasets for training data
  • All contributors and beta testers

Support

For support, email [email protected] or create an issue in the GitHub repository.

Roadmap

  • Voice commands for hands-free operation
  • Integration with fitness trackers
  • Social features and challenges
  • Advanced analytics and insights
  • Multi-language support
  • Apple Watch companion app
  • Web dashboard for detailed analysis

Made with ā¤ļø for better health and posture # NutriPostureAI