Skip to content

A nutrition tracker app built in react native with the goal of ending unhealthy habits

Notifications You must be signed in to change notification settings

AMEND09/Logwise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

34a150f · · Aug 23, 2025

History

29 Commits
Aug 11, 2025
Aug 23, 2025
Aug 10, 2025
Aug 23, 2025
Aug 23, 2025
Aug 6, 2025
Aug 11, 2025
Aug 23, 2025
Aug 23, 2025
Aug 11, 2025
Aug 23, 2025
Aug 6, 2025
Aug 6, 2025
Aug 11, 2025
Aug 12, 2025
Aug 11, 2025
Aug 11, 2025
Aug 10, 2025
Aug 6, 2025
Aug 6, 2025
Aug 6, 2025
Aug 10, 2025
Aug 11, 2025
Aug 6, 2025
Aug 11, 2025
Aug 6, 2025
Aug 6, 2025
Aug 6, 2025
Aug 6, 2025

Repository files navigation

LogWise Nutrition & Habit Trackercker

Overview

LogWise is a modern nutrition and habit tracking app designed to help users build healthier routines, break unhelpful habits, and monitor progress over time. It combines food logging, behavioral insights, habit coaching, and progress photo tracking in a single, privacy-first experience.

The app offers two modes:

  • Guest Mode: Complete privacy with local-only data storage
  • Account Mode: Cloud sync across devices with Supabase backend

Features

  • Food Logging: Track meals, macros, and calories with custom foods and quick entry
  • Habit Coaching: Get daily behavioral tips and track habit streaks
  • Progress Photos: Capture and review transformation photos over time
  • Water & Weight Tracking:ing: Log hydration and weight changes, view charts
  • Insights: See trends, achievements, and suggestions based on your data
  • Push Notifications: Get meal reminders and habit coaching notifications
  • Dual Storage Modes:
    • Guest Mode: Complete privacy with local-only storage
    • Account Mode: Cloud sync with Supabase + local backup
  • Offline-first: Works seamlessly offline with optional cloud sync
  • Cross-platform: Web, iOS, and Android support

Tech Stack

  • Frontend: React Native (Expo), TypeScript, Expo Router
  • Local Storage: AsyncStorage for guest mode and local backup
  • Cloud Backend: Supabase (PostgreSQL, Auth, Real-time)
  • State Management: React Context with modular architecture
  • Notifications: Expo Notifications
  • Charts: React Native Chart Kit
  • Nutrition: USDA Food Data Central & OpenFOodFactsacts

Getting Started

Prerequisites

  • Node.js (16+) & npm npm
  • Expo CLI (npm install -g @expo/cli)
  • Optional: Supabase account for cloud features

Quick Setup

git clone https://github.com/AMEND09/Reality.git

cd Reality
npm install
npm run devev

The app will run in guest mode by default. Users can create accounts later if you set up Supabase.

Supabase Setup (Optional - Enable Cloud Sync)

If you want to enable user accounts and cloud synchronization:

1. Create Supabase Project

  1. Go to supabase.com and create a new project
  2. Wait for the project to be ready (usually 1-2 minutes)

2. Set Up Database Schema

  1. Open your Supabase project dashboard
  2. Go to the SQL Editor
  3. Copy and run the SQL commands from supabase-schema.sql:
-- Create profiles table

CREATE TABLE profiles (
  id UUID DEFAULT gen_random_uuid()  PRIMARY KEY,
  user_id UUID  REFERENCES auth.users(id) ON DELETE CASCADE,
  name  TEXT NOT NULL,
  age  INTEGER NOT NULL,
  sex  TEXT NOT NULL CHECK (sex IN ('male', 'female')),
  weight_kg  DECIMAL NOT NULL,
  height_cm  INTEGER NOT NULL,
  start_weight_kg  DECIMAL NOT NULL,
  goal_weight_kg  DECIMAL NOT NULL,
  activity_level  TEXT NOT NULL CHECK (activity_level IN ('sedentary', 'light', 'moderate', 'active', 'very_active')),
  goals JSONB  NOT NULL,
  eating_triggers  TEXT[] DEFAULT '{}',
  problem_foods  TEXT[] DEFAULT '{}',
  preferred_habits  TEXT[] DEFAULT '{}',
  motivation_reason  TEXT DEFAULT '',
  meal_times JSONB DEFAULT  '{"breakfast": "08:00", "lunch": "12:30", "dinner": "18:30"}',
  notifications_enabled  BOOLEAN DEFAULT false,
  created_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);



-- Create daily_logs table

CREATE TABLE daily_logs (
  id UUID DEFAULT gen_random_uuid()  PRIMARY KEY,
  user_id UUID  REFERENCES auth.users(id) ON DELETE CASCADE,
   date DATE NOT NULL,
  meals JSONB DEFAULT  '{}',
  workout_entries JSONB DEFAULT  '[]',
  water_ml  INTEGER DEFAULT 0,
  daily_habits JSONB DEFAULT  '{}',
  mood_checkins JSONB DEFAULT  '{}',
  reflection JSONB DEFAULT  '{}',
  habit_streak JSONB DEFAULT  '{}',
  created_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  UNIQUE(user_id,  date)
);



-- Create custom_foods table

CREATE TABLE custom_foods (
  id UUID DEFAULT gen_random_uuid()  PRIMARY KEY,
  user_id UUID  REFERENCES auth.users(id) ON DELETE CASCADE,
  name  TEXT NOT NULL,
  grams  INTEGER NOT NULL,
  calories  DECIMAL NOT NULL,
  protein_g  DECIMAL NOT NULL,
  carbs_g  DECIMAL NOT NULL,
  fats_g  DECIMAL NOT NULL,
  created_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);



-- Create weight_logs table

CREATE TABLE weight_logs (
  id UUID DEFAULT gen_random_uuid()  PRIMARY KEY,
  user_id UUID  REFERENCES auth.users(id) ON DELETE CASCADE,
   date DATE NOT NULL,
  weight_kg  DECIMAL NOT NULL,
  created_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  UNIQUE(user_id,  date)
);



-- Create progress_photos table

CREATE TABLE progress_photos (
  id UUID DEFAULT gen_random_uuid()  PRIMARY KEY,
  user_id UUID  REFERENCES auth.users(id) ON DELETE CASCADE,
   date DATE NOT NULL,
  image_url  TEXT NOT NULL,
  notes  TEXT,
  created_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
  updated_at  TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);



-- Enable Row Level Security

ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;

ALTER TABLE daily_logs ENABLE ROW LEVEL SECURITY;

ALTER TABLE custom_foods ENABLE ROW LEVEL SECURITY;

ALTER TABLE weight_logs ENABLE ROW LEVEL SECURITY;

ALTER TABLE progress_photos ENABLE ROW LEVEL SECURITY;


-- Create policies
CREATE POLICY  "Users can view own profile" ON profiles FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY  "Users can insert own profile" ON profiles FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY  "Users can update own profile" ON profiles FOR UPDATE USING (auth.uid() = user_id);

CREATE POLICY Y "Users can view own daily logs" ON daily_logs FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY  "Users can insert own daily logs" ON daily_logs FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY  "Users can update own daily logs" ON daily_logs FOR UPDATE USING (auth.uid() = user_id);

CREATE POLICY Y "Users can view own custom foods" ON custom_foods FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY  "Users can insert own custom foods" ON custom_foods FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY  "Users can update own custom foods" ON custom_foods FOR UPDATE USING (auth.uid() = user_id);
CREATE POLICY  "Users can delete own custom foods" ON custom_foods FOR DELETE USING (auth.uid() = user_id);

CREATE POLICY Y "Users can view own weight logs" ON weight_logs FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY  "Users can insert own weight logs" ON weight_logs FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY  "Users can update own weight logs" ON weight_logs FOR UPDATE USING (auth.uid() = user_id);

CREATE POLICY Y "Users can view own progress photos" ON progress_photos FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY  "Users can insert own progress photos" ON progress_photos FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY  "Users can delete own progress photos" ON progress_photos FOR DELETE USING (auth.uid() = user_id);

3. Configure Authentication

  1. In Supabase dashboard, go to Authentication → Settings
  2. Enable email authentication
  3. Configure email templates (optional)
  4. Set site URL to your app's URL if deploying

4. Environment Variables

Create a .env file in your project root:

# Supabase Configuration

EXPO_PUBLIC_SUPABASE_URL=https://your-project-ref.supabase.co

EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key

Get these values from your Supabase project settings → API.

5. Test the Setup

npm run dev

The app will now offer both guest mode and account creation options.

Deployment Options

Web (Cloudflare Pages)

npm run build:web
npm run deployy

Mobile (Expo)

expo build:android
expo build:ioss

Usage Guide

Authentication Modes

Guest Mode

  • Privacy-first: All data stays on your device
  • No sign-up required: Start using immediately
  • Local storage only: Uses AsyncStorage
  • Upgrade anytime: Can create an account later to sync data

Account Mode

  • Cloud sync: Data synced across all your devices
  • Backup protection: Never lose your data
  • Email/password: Simple authentication
  • Local fallback: Works offline, syncs when online

Getting Started

  1. First launch: Choose "Continue as Guest" or "Create Account"
  2. Profile setup: Enter your basic info and goals
  3. Start tracking: Log meals, workouts, water, and habits
  4. View insights: Check your progress in the Insights tab

Core Features

Food Tracking

  • Tap the "+" button to log meals
  • Search foods or add custom entries
  • Track macros, calories, and portions
  • Monitor eating triggers and mindfulness

Habit Coaching

  • Set daily habit goals
  • Track streaks and progress
  • Get behavioral insights and tips
  • Monitor mood and reflection

Progress Monitoring

  • Take progress photos
  • Log weight changes
  • Track water intake
  • View charts and trends

Notifications

  • Set meal reminder times
  • Get coaching tips and encouragement
  • Configure in Profile → Notification Settings

Data Management

Guest to Account Migration

  • Create an account anytime from the Profile tab
  • Your local data will be automatically synced
  • Continue using the app seamlessly

Data Export/Import

  • All data is accessible via Supabase dashboard
  • JSON export available for developers
  • Standard PostgreSQL backup/restore

Architecture

Storage Strategy

┌─ App Launch ─┐
│              │
├─ Guest Mode ─┤─── AsyncStorage (Local Only)
│              │
└─ Account ────┤─── Supabase (Primary) + AsyncStorage (Backup)
   Mode        │
               └─── Offline: Local → Online: Sync
 Sync

Authentication Flow

App Start → Check Auth State
├─ No User & No Guest Flag → Show Auth Screen
├─ Guest Mode → Load Local Data
└─ Authenticated → Load Cloud Data + Local Backup
kup
up

Data Sync Logic

  • Write: Always write locally first, then sync to cloud
  • Read: Try cloud first (if authenticated), fallback to local
  • Conflict Resolution: Cloud data takes precedence
  • Offline: All features work offline, sync when reconnected

Development

Project Structure

app/
├─ (tabs)/          # Main app tabs
├─ auth.tsx         # Authentication screen
└─ _layout.tsx      # Root layout with providers

components/
├─ AuthGate.tsx     # Authentication wrapper
└─ [Other components]

contexts/
├─ AuthContext.tsx  # Authentication state
└─ DataContext.tsx  # App data state

utils/
├─ storage.ts       # Local storage (AsyncStorage)
├─ cloudStorage.ts  # Supabase storage
└─ supabase.ts      # Supabase client config
e client config

Running in Development

# Start the development server
npm run dev



# Run on specific platform
expo start --ios
expo start --android
expo start --web

b

# Clear cache if needed
expo start --clearr

Environment Variables

The app detects Supabase configuration automatically:

  • With Supabase: Shows auth options
  • Without Supabase: Guest mode only

Testing Authentication

  1. Guest Mode: Just run the app normally
  2. Account Mode: Set up Supabase and test sign-up/sign-in
  3. Migration: Test creating account from guest mode
  4. Sync: Test data sync across devices/browsers

Troubleshooting

Common Issues

"Cannot find module '@/utils/supabase'"

  • Check that all imports use relative paths
  • Ensure TypeScript path mapping is correct
  • Try npm install and restart Metro

Supabase Connection Issues

  • Verify environment variables are set correctly
  • Check Supabase project is active
  • Ensure RLS policies are properly configured

Data Not Syncing

  • Check network connectivity
  • Verify user is authenticated
  • Check Supabase project logs for errors

Metro/Build Issues

npm install
expo start --clearr

Getting Help

  • Check the Issues page
  • Review Supabase documentation
  • Test in guest mode to isolate auth issues

Contributing

We welcome contributions! Please:

  1. Fork and branch: Create a feature branch from main
  2. Test both modes: Ensure guest and account modes work
  3. Follow patterns: Use existing code patterns and context structure
  4. Document changes: Update README for new features
  5. Test thoroughly: Test on web and mobile platforms

Development Setup

git clone your-fork-url

cd Reality
npm install
cp .env.example .env    # Add your Supabase credentials
npm run devv

Roadmap

Near Term

  • Social features and sharing
  • Food database integration
  • Enhanced analytics
  • Meal planning features

Long Term

  • AI-powered recommendations
  • Fitness tracker integration
  • Nutrition coaching
  • Community features

License

This project is licensed under the MIT License.

Support

For questions or support:

  • 📧 Open an issue
  • 💬 Check existing discussions
  • 📚 Review this documentation

Built with ❤️ using React Native, Expo, and Supabase.

About

A nutrition tracker app built in react native with the goal of ending unhealthy habits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published