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
-
Clone the repository
git clone https://github.com/yourusername/NutriPostureAI.git cd NutriPostureAI -
Install dependencies
npm install -
Install iOS dependencies (macOS only)
cd ios && pod install && cd .. -
Configure Firebase
- Create a Firebase project
- Update
firebase/config.tswith your Firebase configuration - Enable Authentication, Firestore, and Storage
-
Configure TensorFlow Models
- Replace placeholder model files in
models/with actual trained models - Update model loading code in
utils/tfSetup.ts
- Replace placeholder model files in
-
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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - 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
- Generate signed APK
- Test on multiple devices
- Upload to Google Play Store
iOS
- Archive the project in Xcode
- Test on multiple devices
- Upload to App Store Connect
Troubleshooting
Common Issues
-
TensorFlow initialization fails
- Ensure TensorFlow.js is properly installed
- Check model file paths
- Verify device compatibility
-
Camera permissions denied
- Check app permissions in device settings
- Ensure proper permission handling in code
-
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