An AI-powered progressive web application for meal tracking with personalized encouragement and habit building
My Progress Planner is an enterprise-grade progressive web application that transforms meal tracking from a mundane task into an engaging, supportive experience. Built with modern web technologies and powered by AI, it provides users with personalized feedback while maintaining complete privacy and data sovereignty.
- AI-Driven Engagement: GPT-4 powered responses provide contextual, encouraging feedback
- Progressive Web App: Native app experience with offline-first architecture
- Privacy-First Design: Complete user data isolation with row-level security
- Scalable Architecture: Built for high availability and horizontal scaling
- Modern Tech Stack: Leverages industry-leading technologies for optimal performance
graph TB
A[Client PWA] --> B[Next.js API Routes]
B --> C[Supabase PostgreSQL]
B --> D[OpenAI GPT-4 API]
A --> E[Service Worker]
E --> F[IndexedDB Cache]
B --> G[Push Notification Service]
| Layer | Technology | Version | Purpose |
|---|---|---|---|
| Frontend | Next.js | 14.x | React framework with App Router |
| Language | TypeScript | 5.x | Type-safe development |
| Styling | Tailwind CSS | 3.x | Utility-first CSS framework |
| Animation | Framer Motion | 11.x | Production-ready motion library |
| Database | Supabase (PostgreSQL) | Latest | Real-time database with auth |
| Authentication | Supabase Auth | Latest | OAuth 2.0 + JWT tokens |
| AI Engine | OpenAI GPT-4 | Latest | Natural language processing |
| State Management | React Hooks + Context | - | Client-side state management |
| PWA | Workbox + Next.js | Latest | Service worker and caching |
| Deployment | Vercel | Latest | Edge computing platform |
Ensure you have the following installed and configured:
- Node.js β₯ 18.17.0 (LTS recommended)
- npm β₯ 9.0.0 or yarn β₯ 1.22.0
- Git for version control
- Supabase project with PostgreSQL database
- OpenAI API account with GPT-4 access
-
Clone and Install
git clone https://github.com/dinesh-git17/my-progress-planner.git cd my-progress-planner npm install -
Environment Configuration
Copy the example environment file:
cp .env.example .env.local
Configure the following environment variables:
# Database & Authentication NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key SUPABASE_SERVICE_ROLE_KEY=your_service_role_key # AI Integration OPENAI_API_KEY=sk-your_openai_api_key # Security (Production) CRON_SECRET=your_secure_random_string ADMIN_PASSWORD=your_secure_admin_password # Push Notifications (Optional) VAPID_PUBLIC_KEY=your_vapid_public_key VAPID_PRIVATE_KEY=your_vapid_private_key PUSH_CONTACT_EMAIL=mailto:[email protected]
-
Database Setup
Run the database migrations:
npm run db:setup
-
Development Server
npm run dev
Access the application at
http://localhost:3000
- Connect your GitHub repository to Vercel
- Configure environment variables in Vercel dashboard
- Deploy with automatic CI/CD on every push
npm run build
npm run start- Multi-Provider OAuth: Google, GitHub, email/password
- JWT Token Management: Automatic refresh with secure storage
- Row-Level Security (RLS): Database-level user isolation
- CSRF Protection: Built-in Next.js security features
- Rate Limiting: API endpoint protection against abuse
-- Core user profiles
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT UNIQUE NOT NULL,
name TEXT,
friend_code TEXT UNIQUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT now()
);
-- Meal tracking entries
CREATE TABLE meals (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
meal_type meal_type_enum NOT NULL,
content TEXT NOT NULL,
ai_response TEXT,
logged_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()
);
-- Daily AI summaries
CREATE TABLE summaries (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
summary_date DATE NOT NULL,
content TEXT NOT NULL,
meals_count INTEGER DEFAULT 0,
created_at TIMESTAMP WITH TIME ZONE DEFAULT now(),
UNIQUE(user_id, summary_date)
);- Client Input β Form validation β API endpoint
- Server Processing β Database operation β AI processing (if applicable)
- Response Generation β Client update β PWA cache sync
interface AIResponse {
content: string;
context: {
mealType: 'breakfast' | 'lunch' | 'dinner';
streak: number;
previousMeals: Meal[];
userPreferences: UserPreferences;
};
metadata: {
tokens: number;
model: string;
timestamp: string;
};
}- Streak Recognition: Celebrates consistency milestones
- Meal Pattern Analysis: Identifies healthy habits and improvements
- Time-Sensitive Responses: Different encouragement based on meal timing
- Personalization: Learns from user interaction patterns
- Cache-First Strategy: Static assets and shell resources
- Network-First Strategy: API calls with offline fallback
- Background Sync: Queue operations when offline
- Push Notifications: Optional engagement features
- Complete meal logging interface
- Local data persistence with IndexedDB
- Automatic sync when connection restored
- Conflict resolution for concurrent updates
# Unit Tests
npm run test
# Integration Tests
npm run test:integration
# E2E Tests
npm run test:e2e
# Type Checking
npm run type-check
# Linting
npm run lint
# Performance Audit
npm run lighthouse- Test Coverage: >90% for critical business logic
- Type Safety: 100% TypeScript coverage
- Performance: Lighthouse score >95
- Accessibility: WCAG 2.1 AA compliance
- Security: Regular dependency audits
- Image Optimization: Next.js automatic optimization
- Code Splitting: Route-based and component-based
- Tree Shaking: Automatic dead code elimination
- Compression: Gzip/Brotli compression enabled
- CDN Integration: Global edge caching
- Real User Monitoring (RUM): Core Web Vitals tracking
- Error Tracking: Comprehensive error reporting
- Performance Metrics: API response times and database queries
- User Analytics: Privacy-compliant usage analytics
main- Production-ready codedevelop- Integration branch for featuresfeature/*- Individual feature developmenthotfix/*- Critical production fixes
# Pre-commit hooks
npm run pre-commit
# Automated formatting
npm run format
# Comprehensive linting
npm run lint:strict# .github/workflows/ci.yml
name: CI/CD Pipeline
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- run: npm ci
- run: npm run type-check
- run: npm run lint
- run: npm run test
- run: npm run buildWe welcome contributions that align with our mission of creating supportive, privacy-focused user experiences.
- Fork the repository and create your feature branch
- Follow TypeScript best practices and maintain type safety
- Write comprehensive tests for new functionality
- Ensure accessibility compliance (WCAG 2.1 AA)
- Maintain the supportive tone in user-facing features
- Document API changes and update relevant documentation
- Update documentation for any new features
- Ensure all tests pass and coverage remains >90%
- Add screenshots for UI changes
- Request review from maintainers
- Address feedback and maintain clean commit history
| Endpoint | Method | Purpose | Auth |
|---|---|---|---|
/api/auth/callback |
GET | OAuth callback handling | Public |
/api/meals |
GET/POST | Meal CRUD operations | Required |
/api/summaries |
GET | Daily summary retrieval | Required |
/api/ai/chat |
POST | AI response generation | Required |
/api/admin/stats |
GET | System statistics | Admin |
interface APIResponse<T> {
data: T | null;
error: string | null;
meta?: {
total: number;
page: number;
limit: number;
};
}- HTTPS Everywhere: Strict transport security
- Content Security Policy: XSS protection
- CORS Configuration: Restricted origin access
- Input Validation: Server-side sanitization
- SQL Injection Prevention: Parameterized queries
- Data Minimization: Collect only necessary information
- User Consent: Clear opt-in for optional features
- Data Portability: Export functionality available
- Right to Deletion: Complete data removal option
- Anonymization: No PII in analytics
- API Documentation:
/docs/api - Architecture Guide:
/docs/architecture.md - Deployment Guide:
/docs/deployment.md - Contributing Guide:
/CONTRIBUTING.md
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. See the LICENSE.md file for details.
For commercial licensing options, please contact me at [email protected].
- OpenAI for providing the GPT-4 API that powers our AI features
- Supabase for the robust backend infrastructure
- Vercel for the exceptional deployment platform
- The Next.js team for the outstanding React framework
Built with β€οΈ for people who deserve encouragement on their wellness journey