Turn your fitness achievements into real rewards. Walk 10,000 steps, unlock an Amazon purchase.
The Health Achievement Rewards System is a complete three-tier application that gamifies fitness by connecting Apple Health data to Amazon purchases. Users set achievement goals (e.g., "10,000 steps per day"), and when they achieve them, they unlock the ability to purchase items from Amazon within a specified budget.
┌─────────────────┐
│ iOS App │ Your fitness data from Apple Health
│ (HealthKit) │
└────────┬────────┘
│ Syncs health data
▼
┌─────────────────────────────────┐
│ FastAPI Backend │ Evaluates achievements
│ (PostgreSQL + Redis) │ Manages rewards
└────────┬────────────────────────┘
│ Provides rewards
▼
┌─────────────────┐
│ Chrome Extension│ One-click purchase on Amazon
└─────────────────┘
User Flow:
- Set achievement goal: "Walk 10,000 steps daily to earn a $25 Amazon purchase"
- iOS app automatically syncs your health data from Apple Health
- Backend evaluates your progress and triggers achievement when goal is met
- Chrome extension shows a banner on Amazon product pages
- Click "Use Reward" to assign your achievement to a product
- Purchase the item and track your reward history
- Location:
health-rewards-backend/ - Tech Stack: Python 3.12, FastAPI, PostgreSQL, Redis
- Purpose: Central API for authentication, health data processing, rule evaluation, and reward management
- Key Features:
- JWT authentication
- Health data ingestion and storage
- Customizable achievement rules with streak tracking
- Amazon Product Advertising API integration
- Email and web push notifications
- Real-time rule evaluation
- Location:
ios-app/ - Tech Stack: Swift 5.9+, SwiftUI, HealthKit
- Purpose: Native iOS app for automatic health data syncing
- Key Features:
- Automatic HealthKit integration
- Real-time health dashboard
- Achievement tracking with progress visualization
- Secure Keychain-based authentication
- Background data sync
- Location:
chrome-extension/ - Tech Stack: JavaScript, Chrome Extension APIs
- Purpose: Amazon integration for one-click reward redemption
- Key Features:
- Detects Amazon product pages
- Injects reward UI with purple gradient banner
- One-click reward application
- Purchase tracking
- Real-time stats dashboard
- Location:
health-rewards-website/ - Tech Stack: Next.js 16, React 19, TypeScript, Tailwind CSS, Radix UI
- Purpose: Web dashboard for managing achievements, rewards, and analytics
- Key Features:
- Achievement creation and management with multi-step wizard
- Reward approval workflow and purchase tracking
- Health analytics and trends visualization
- Streak and tier multiplier display
- User settings and profile management
- Responsive design with mobile navigation
- Marketing landing pages
See QUICKSTART.md for a complete setup guide.
5-Minute Setup (Local Development):
# 1. Start the backend
cd health-rewards-backend
docker-compose up -d
# Backend runs at http://localhost:8000
# 2. Start the web dashboard
cd health-rewards-website
npm install && npm run dev
# Website runs at http://localhost:3000
# 3. Load Chrome Extension
# Open chrome://extensions/ → Enable Developer mode → Load unpacked → Select chrome-extension/
# 4. Build iOS App (requires Xcode on Mac)
# Open ios-app/HealthRewards.xcodeproj in Xcode
# Connect iPhone → Run (⌘R)- Flexible Rules: Create custom achievement goals with various health metrics
- Supported Metrics: Steps, active calories, exercise minutes, distance
- Periods: Daily, weekly, monthly, or streak-based
- Operators: Greater than, greater than or equal, equal to, streak count
- Automatic Triggering: Backend evaluates rules in real-time when data syncs
- Duplicate Prevention: Same rule won't trigger multiple times per day
- Automatic Sync: iOS app reads directly from Apple Health (HealthKit)
- Real-time Dashboard: View today's activity with beautiful visualizations
- Historical Summaries: Daily, weekly, and monthly health summaries
- Progress Tracking: See how close you are to your next achievement
- Pending Rewards: Achievements waiting for product selection
- Approved Rewards: Products assigned and ready for purchase
- Purchase Tracking: Complete reward history with status updates
- Price Limits: Set maximum spend per achievement
- Amazon Integration: Direct product links and affiliate tracking
- JWT Authentication: Secure token-based auth across all platforms
- Keychain Storage: iOS app stores tokens in secure Keychain
- Password Hashing: bcrypt for secure password storage
- Health Data Privacy: Data never shared with third parties
- HTTPS Ready: Production-ready security configuration
| Component | Technologies |
|---|---|
| Backend | FastAPI, PostgreSQL, SQLAlchemy (async), Alembic, Redis, JWT |
| iOS App | Swift 5.9+, SwiftUI, HealthKit, Keychain, async/await |
| Chrome Extension | JavaScript ES6+, Chrome Extension Manifest v3, Content Scripts |
| Web Dashboard | Next.js 16, React 19, TypeScript, Tailwind CSS, Radix UI, React Query, Zustand |
| Database | PostgreSQL 16 with async connection pooling |
| Deployment | Docker, Docker Compose, Vercel |
Health_Achievement_Rewards/
├── health-rewards-backend/ # FastAPI backend
│ ├── app/
│ │ ├── api/routes/ # API endpoints (auth, health, rules, rewards)
│ │ ├── models/ # SQLAlchemy database models
│ │ ├── schemas/ # Pydantic validation schemas
│ │ ├── services/ # Business logic (rule engine, notifications)
│ │ └── utils/ # Security utilities
│ ├── alembic/ # Database migrations
│ ├── tests/ # pytest test suite
│ ├── docker-compose.yml # Docker services config
│ ├── Dockerfile # Container image
│ └── requirements.txt # Python dependencies
│
├── ios-app/ # SwiftUI iOS app
│ ├── HealthRewards/
│ │ ├── Models/ # API data models
│ │ ├── Services/ # API client, auth, HealthKit manager
│ │ ├── Views/ # SwiftUI views (dashboard, achievements, rewards)
│ │ ├── Info.plist # App configuration
│ │ └── HealthRewards.entitlements
│ └── README.md
│
├── chrome-extension/ # Chrome extension
│ ├── manifest.json # Extension config
│ ├── popup.* # Main popup UI (HTML/JS/CSS)
│ ├── content.* # Amazon page injection (JS/CSS)
│ ├── background.js # Service worker
│ ├── api-client.js # Backend API wrapper
│ └── icons/ # Extension icons
│
├── health-rewards-website/ # Next.js web dashboard
│ ├── src/
│ │ ├── app/ # Next.js App Router (pages)
│ │ │ ├── (auth)/ # Login, register, forgot-password
│ │ │ ├── (dashboard)/ # Protected dashboard routes
│ │ │ └── (marketing)/ # Public marketing pages
│ │ ├── components/ # React components
│ │ │ ├── dashboard/ # Dashboard components
│ │ │ ├── marketing/ # Marketing components
│ │ │ └── ui/ # Radix UI primitives
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/api/ # API client functions
│ │ ├── stores/ # Zustand state stores
│ │ └── types/ # TypeScript interfaces
│ ├── public/ # Static assets
│ └── package.json # Node.js dependencies
│
├── docs/ # Documentation
│
└── README.md # This file
POST /api/v1/auth/register- Create new user accountPOST /api/v1/auth/login- Login and receive JWT tokenGET /api/v1/auth/me- Get current user detailsGET /api/v1/auth/me/streak- Get current user streak info
POST /api/v1/health/sync- Sync health metrics from iOS appGET /api/v1/health/summary/{period}- Get aggregated health summary
POST /api/v1/rules- Create achievement ruleGET /api/v1/rules- List all rules for current userGET /api/v1/rules/{id}- Get specific rule detailsPUT /api/v1/rules/{id}- Update existing ruleDELETE /api/v1/rules/{id}- Delete rulePOST /api/v1/rules/{id}/test- Test rule without triggeringGET /api/v1/rules/{id}/progress- Get current progress toward goalGET /api/v1/rules/{id}/tier-progress- Get tier progression for a ruleGET /api/v1/rules/tier-progress- Get tier progression for all rules
GET /api/v1/rewards/pending- Get pending reward approvalsPOST /api/v1/rewards/{id}/approve- Approve reward with product detailsPOST /api/v1/rewards/{id}/decline- Decline rewardPOST /api/v1/rewards/{id}/complete- Mark reward as purchasedGET /api/v1/rewards/history- Get complete reward history
GET /api/v1/wishlist- Get wishlist itemsGET /api/v1/wishlist/next-item- Get next affordable itemGET /api/v1/wishlist/item/{asin}- Get product details by ASINGET /api/v1/wishlist/search- Search Amazon productsPOST /api/v1/wishlist/generate-link- Generate affiliate linkPOST /api/v1/wishlist/items/batch- Get details for multiple products
Full API documentation available at http://localhost:8000/docs (Swagger UI)
Stores user accounts with authentication credentials and Amazon associate tags.
Tracks health data sources (iOS devices) for each user.
Time-series storage of all health metrics (steps, calories, exercise, distance).
Achievement rules with trigger conditions (metric, operator, threshold, period) and reward configuration.
Records of triggered achievements with status tracking (pending → approved → completed).
Tracks tier progression (Bronze → Silver → Gold → Platinum) per user per rule.
User reward destinations (Amazon wishlist URLs, gift card preferences).
- QUICKSTART.md - Complete setup guide for all components
- MACINCLOUD_TESTING.md - Step-by-step guide for testing iOS app on Mac in Cloud
- README-backend.md - Backend API documentation
- README-ios-app.md - iOS app setup and troubleshooting
- README-chrome-extension.md - Chrome extension usage guide
- README-website.md - Web dashboard documentation
Backend:
cd health-rewards-backend
pytest --cov=app --cov-report=htmliOS App:
# Open in Xcode and press ⌘Ucd health-rewards-backend
# Create migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade head
# Rollback
alembic downgrade -1Backend Logs:
docker-compose logs -f apiiOS App:
- Xcode console shows all logs
- Use breakpoints for step debugging
Chrome Extension:
- Right-click extension icon → Inspect popup
- F12 on Amazon pages for content script logs
- chrome://extensions → service worker link for background logs
Docker:
docker build -t health-rewards-api .
docker run -d -p 8000:8000 --env-file .env health-rewards-apiCloud Platforms:
- Railway: Connect GitHub repo, set env vars, auto-deploy
- Render: Same process as Railway
- AWS/GCP: Use managed PostgreSQL + container service
TestFlight:
- Archive app in Xcode (Product → Archive)
- Distribute to App Store Connect
- Submit for TestFlight review
- Share with internal/external testers
App Store:
- Complete app review requirements
- Submit for App Store review
- Publish to App Store
Chrome Web Store:
- Create developer account ($5 fee)
- Package extension as .zip
- Upload to Chrome Web Store
- Submit for review
- Publish to store
Backend requires these environment variables (see health-rewards-backend/.env.example):
Required:
DATABASE_URL- PostgreSQL connection stringSECRET_KEY- JWT secret key (32+ characters)
Optional:
AMAZON_ACCESS_KEY- Amazon Product Advertising API keyAMAZON_SECRET_KEY- Amazon PA-API secretAMAZON_PARTNER_TAG- Amazon associate tagSMTP_USER- Email for notificationsSMTP_PASSWORD- Email passwordVAPID_PRIVATE_KEY- Web push private keyVAPID_PUBLIC_KEY- Web push public key
- Check PostgreSQL is running:
docker-compose ps - Verify .env file exists with correct DATABASE_URL
- Check port 8000 is not already in use
- Ensure backend is accessible on local network
- Use your computer's IP address, not localhost
- Check firewall allows connections on port 8000
- Verify both devices on same WiFi network
- Verify backend is running at
http://localhost:8000 - Check Settings in extension for correct API URL
- Ensure account exists in backend database
- Verify data exists in Apple Health app
- Check HealthKit permissions in Settings → Health
- Try re-granting permissions to the app
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Ensure all tests pass
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Phase 1 (Complete):
- Backend API with health data ingestion
- iOS app with HealthKit integration
- Chrome extension with Amazon integration
- Achievement rule engine
- Reward approval workflow
Phase 2 (Complete):
- Web dashboard (Next.js) with full feature set
- Achievement management with multi-step wizard
- Reward management with approval workflow
- Health analytics and visualization
- User settings and profile management
- Marketing landing pages
- Streak multipliers (Phase 2A) - 10%-100% bonus based on streak length
- Achievement tiers (Phase 2B) - Bronze/Silver/Gold/Platinum progression
- iOS audit fixes & accessibility (Phase 2C) - WCAG AA, privacy manifest
- Chrome extension multiplier display (Phase 2D) - streak badges, boosted amounts
Phase 3 (Planned):
- iOS app multiplier UI display (Phase 2E)
- Background sync for iOS app
- Push notifications for achievements
- Amazon wishlist auto-sync
- Multi-region Amazon support
- Apple Watch companion app
- Team challenges and leaderboards (backend + basic UI started)
- Integration with Fitbit, Garmin
- Custom reward types (gift cards, donations)
- Advanced analytics dashboard
- Family sharing features
This project is proprietary software. All rights reserved.
For issues and questions:
- GitHub Issues: Create an issue in the repository
- Documentation: See individual component README files
- API Docs: http://localhost:8000/docs (when backend is running)
Built with:
- FastAPI - Modern Python web framework
- Next.js - React framework for web dashboard
- SwiftUI - Apple's declarative UI framework
- HealthKit - Apple's health data framework
- PostgreSQL - Advanced open source database
- Docker - Containerization platform
- Lines of Code: ~15,000+
- API Endpoints: 26
- Database Tables: 7
- Service Modules: 6 (rule engine, achievement tracker, amazon, notifications, multipliers, tiers)
- Test Files: 7 (auth, rule engine, rules API, multipliers, tiers, integration)
- Supported Health Metrics: 4 (steps, calories, exercise, distance)
- Platforms: iOS 16+, Chrome Browser, Web (all modern browsers)
- Web Dashboard Pages: 16 routes (auth, dashboard, settings, marketing)
Ready to turn your fitness achievements into rewards? See QUICKSTART.md to get started in 10 minutes!