Skip to content

harry-david-brown/SnackTrackApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

161 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“± Snack Track App

A React Native/Expo app that shows you how much you wasted on food delivery through Uber CSV imports, then roasts you.

πŸ“… Future Enhancements

  • Forgot Password - Password reset flow (shipped with OTP UX)
  • Email Verification - Verify user emails on registration
  • Social Login - Google and Apple Sign In
  • Biometric Auth - Face ID / Touch ID support
  • Multi-Template Sharing - Additional Wrapped-style slide variations
  • Currency Auto-Detection - Detect CAD/USD/EUR from CSV or locale
  • Receipt List View - Browse individual transactions
  • Performance Optimization - Bundle size and loading improvements

πŸš€ Getting Started (New Developers)

Prerequisites

  • Node.js 20+ (LTS recommended)
  • Docker Desktop
  • Git

Quick Setup (5 minutes)

  1. Clone and setup

    git clone https://github.com/harry-david-brown/SnackTrackApp.git
    cd SnackTrackApp
    npm run setup

    The setup script will:

    • βœ… Check system requirements
    • βœ… Install dependencies
    • βœ… Create .env file with default configuration
    • βœ… Start development databases

    Windows users: Run scripts\setup.bat instead

  2. Configure API URL (optional)

    The setup script creates a .env file with Railway production API as default. You can update it if needed:

    # .env (defaults to Railway production)
    EXPO_PUBLIC_API_URL=https://snacktrackapi-production.up.railway.app
    EXPO_PUBLIC_APP_ENV=development

    Default: EXPO_PUBLIC_API_URL defaults to Railway production API

    • Default: https://snacktrackapi-production.up.railway.app (Railway production)
    • Local dev: http://localhost:3000 (if running backend locally)
    • Mobile testing: http://YOUR_IP:3000 (use your computer's IP for local backend)

    ℹ️ The app defaults to Railway production API. Set EXPO_PUBLIC_API_URL only if you need a different API.

  3. Start the backend API (in a separate terminal)

    cd path/to/SnackTrackAPI
    docker-compose up --build -d
  4. Start the app

    npm start
    # Press 'w' to open in browser
  5. Verify setup

    npm run verify

Troubleshooting

App won't start?

  • Check that EXPO_PUBLIC_API_URL is set in .env
  • Run npm run verify to check all requirements

Can't connect to API?

  • Ensure the backend API is running (docker-compose up -d)
  • For mobile testing, use your computer's IP address instead of localhost

Need help?


πŸ› οΈ Development Guide

Environment Variables

Optional (with defaults):

  • EXPO_PUBLIC_API_URL - API base URL, defaults to https://snacktrackapi-production.up.railway.app (Railway production)
  • EXPO_PUBLIC_APP_ENV - Environment type (development, staging, production), defaults to development
  • EXPO_PUBLIC_SENTRY_DSN - Sentry DSN for error tracking (optional - app works without it)

The npm run setup script creates a .env file automatically with Railway production API as default. Edit it to customize your configuration (e.g., for local development).

Error Tracking (Sentry):

  • Sentry is integrated for production error tracking and crash reporting
  • Set EXPO_PUBLIC_SENTRY_DSN in your environment to enable (get DSN from https://sentry.io)
  • App works normally without Sentry configured (errors are logged to console in development)

Development Commands

# App Development
npm start              # Start Expo dev server
npm run start:clean    # Clean start (kills existing processes)
npm run stop-expo     # Stop all Expo/Metro processes

# Code Quality
npm run lint          # Run ESLint
npm run type-check    # TypeScript type checking
npm test             # Run tests
npm run ci           # Run all CI checks (type-check + lint + test)
npm run verify       # Verify setup and environment

Mobile Testing

  1. Install Expo Go on your device

  2. Start the dev server

    npx expo start
  3. Open Expo Go the development server should show up automatically. Or scan the QR code in your terminal

For mobile to connect to local API:

  • Find your computer's IP: ip addr show (Linux) or ifconfig (Mac)
  • Update .env: EXPO_PUBLIC_API_URL=http://YOUR_IP:3000 (overrides Railway default)
  • Restart Expo

Manual Testing

For comprehensive manual testing of network/offline features, error handling, and file uploads:


πŸ“ Project Structure

πŸ“± Snack Track App/
β”œβ”€β”€ 🏠 app/                   # Expo Router pages
β”‚   β”œβ”€β”€ (tabs)/               # Tab navigation screens
β”‚   β”‚   β”œβ”€β”€ index.tsx         # Dashboard
β”‚   β”‚   β”œβ”€β”€ upload.tsx        # CSV/ZIP Upload
β”‚   β”‚   β”œβ”€β”€ wrapped-journey.tsx # Analytics journey
β”‚   β”‚   └── profile.tsx        # User Profile
β”‚   β”œβ”€β”€ _layout.tsx           # Root layout
β”‚   └── index.tsx             # Authentication
β”‚
β”œβ”€β”€ πŸ”§ components/            # Reusable components
β”‚   β”œβ”€β”€ LoginScreen.tsx       # Authentication UI
β”‚   β”œβ”€β”€ PasswordResetModal.tsx # Password reset flow
β”‚   β”œβ”€β”€ EmailVerificationModal.tsx # Email verification
β”‚   β”œβ”€β”€ UberDataUpload.tsx    # File upload
β”‚   β”œβ”€β”€ WrappedShareJourney.tsx # Analytics journey
β”‚   └── [Other components]   # Charts, sharing, etc.
β”‚
β”œβ”€β”€ 🎣 contexts/              # React Context
β”‚   β”œβ”€β”€ UserContext.tsx       # User state & auth
β”‚   └── OnboardingContext.tsx # Onboarding state
β”‚
β”œβ”€β”€ 🌐 services/              # API services
β”‚   β”œβ”€β”€ api.ts                # API client
β”‚   β”œβ”€β”€ authApi.ts            # Authentication
β”‚   └── analyticsApi.ts       # Analytics
β”‚
β”œβ”€β”€ πŸͺ hooks/                 # Custom hooks
β”‚   β”œβ”€β”€ useNetworkStatus.ts   # Network monitoring
β”‚   └── useOfflineSync.ts     # Offline sync
β”‚
β”œβ”€β”€ πŸ› οΈ utils/                 # Utilities
β”‚   β”œβ”€β”€ tokenManager.ts       # Token storage (SecureStore)
β”‚   └── offlineCache.ts       # Analytics caching
β”‚
β”œβ”€β”€ πŸ“Š types/                 # TypeScript types
β”‚   └── api.ts                # API types
β”‚
β”œβ”€β”€ πŸ“œ scripts/               # Development scripts
β”‚   β”œβ”€β”€ setup.sh              # Automated setup
β”‚   └── verify-setup.js       # Environment verification
β”‚
└── πŸ“„ Configuration          # Package.json, Docker, etc.

πŸ” Authentication & Security

JWT Authentication

  • Registration/Login: Email + password (8+ chars, 1 uppercase, 1 number)
  • Token Management: Automatic refresh every 15 minutes
  • Secure Storage: Tokens stored in encrypted Keychain/Keystore (Expo SecureStore)
  • Session Management: Persistent login with auto-logout on expiry

Password Reset & Email Verification

  • Password Reset: 4-step OTP flow (request β†’ verify β†’ reset β†’ success)
  • Email Verification: Optional OTP-based verification (non-blocking)
  • Rate Limiting: Built-in protection against abuse

πŸ”„ CI/CD Pipeline

Status: βœ… Automated quality checks on every push

Active Checks

  • βœ… TypeScript type checking
  • βœ… ESLint linting
  • βœ… Unit tests
  • βœ… Security audit

Pre-Commit Hooks

Automatically runs type-check and lint before each commit.

Run checks locally:

npm run ci  # Runs all CI checks

🀝 Contributing

See CONTRIBUTING.md for contribution guidelines.


πŸ“š Additional Resources

  • Launch Checklist: LAUNCH_TODO.md
  • Backend Integration: See backend project documentation

Questions? Run npm run verify to diagnose setup issues, or check the troubleshooting section above.

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •