This document provides full technical and product context for a habit tracking application focused on:
- Extreme simplicity
- Zero friction when marking habits
- Daily usage
- Web + smartphone support
The goal is to build a clean MVP that is scalable, easy to maintain, and fast to iterate.
- One-tap habit tracking
- Minimal UI, no unnecessary steps
- Fast load time
- Works offline (basic support)
- Focus on consistency, not complexity
- Web (desktop & mobile)
- Smartphone via PWA (installable)
- User authentication (Google + email)
- Habit CRUD
- Daily habit completion tracking
- Weekly overview
- Streak calculation
- Basic statistics
- Responsive UI
- PWA support
- Push notifications
- Social features
- Gamification
- Health integrations
- Templates & routines
- Advanced analytics
Frontend (Next.js + React)
│
├── UI (Client Components)
├── State Management (Zustand + React Query)
├── PWA (Service Worker + Manifest)
│
└── Supabase SDK Calls
Backend (Supabase)
│
├── Authentication (Google / Email)
├── PostgreSQL Database
├── Row Level Security (RLS)
├── Edge Functions (optional)
└── Realtime (optional)
Deployment:
- Frontend: Vercel
- Backend: Supabase
- React
- Next.js 14 (App Router)
- TypeScript
- TailwindCSS
- shadcn/ui
- React Query (server state)
- Zustand (UI & local state)
- Supabase
- Auth
- PostgreSQL
- RLS
- Edge Functions
- Progressive Web App (PWA)
app/
auth/
login/
page.tsx
callback/
page.tsx
dashboard/
page.tsx
habits/
page.tsx
[id]/
page.tsx
api/
habits/
route.ts
logs/
route.ts
components/
HabitCard.tsx
HabitList.tsx
AddHabitModal.tsx
CalendarGrid.tsx
Header.tsx
BottomNav.tsx
hooks/
useHabits.ts
useHabitLogs.ts
useAuth.ts
store/
ui.ts
habits.ts
lib/
supabaseClient.ts
auth.ts
api.ts
validators.ts
constants.ts
styles/
globals.css
public/
manifest.json
icons/
middleware.ts
- Supabase Auth
- Providers:
- Google OAuth
- Email + password
- Next.js middleware to protect private routes:
/dashboard/habits
- No user can access data that does not belong to them
- Enforced via PostgreSQL Row Level Security (RLS)
| Field | Type |
|---|---|
| id | uuid |
| user_id | uuid |
| title | text |
| icon | text |
| color | text |
| frequency | jsonb |
| created_at | timestamp |
| Field | Type |
|---|---|
| id | uuid |
| habit_id | uuid |
| date | date |
| completed | boolean |
Example policy for habits:
CREATE POLICY "user can access own habits"
ON habits
USING (user_id = auth.uid());
Same logic applies to habit_logs via habit_id.
- Direct Supabase SDK calls from the frontend
- Simpler, faster, less boilerplate
Used only when:
- Extra validation is required
- Combining multiple queries
- Business logic grows
Future use cases:
- Daily streak calculations
- Scheduled jobs
- Notifications (future)
- Open app
- Sign in with Google or email
- Empty dashboard
- CTA: “Create your first habit”
- Open app
- See today’s habits
- One tap to mark as completed
- Visual feedback (streak / progress)
- Fetch habits
- Fetch daily logs
- Handle caching & revalidation
- Optimistic updates when marking habits
- UI state (modals, selected habit)
- Local habit state if needed
- Installable on mobile
- Cached UI
- Offline-first reading
- Sync when connection returns (future)
manifest.json- Service worker
- Vercel
- Automatic deployments
- Preview environments
- Supabase hosted services
- Web app
- Google / email authentication
- Habit CRUD
- Daily & weekly views
- Streak tracking
- PWA support
- Clean, minimal UI
When assisting with this project:
- Prefer simplicity over abstraction
- Avoid overengineering
- Favor direct Supabase usage
- Keep UI minimal and fast
- Optimize for daily habit usage
- Assume MVP mindset