Skip to content

Latest commit

Β 

History

501 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HabitFlow

A modern, full-featured habit tracking and productivity application built with React, TypeScript, and Vite. Includes a multi-mode timer (stopwatch/countdown/intervals), achievements, AI insights, analytics, exports, social/messaging, integrations with Google/Notion/Slack/Spotify/Fit, and email + TOTP MFA authentication. Ships as a Vite web app, a Capacitor Android wrapper, and a static landing page. Backend is Supabase (Postgres + Edge Functions) with Cloudflare Turnstile bot protection.

🌳 Branch Structure

We follow a simplified two-branch flow:

  • main β€” Production-ready code (protected)
  • docs/*, feat/*, chore/*, fix/* β€” short-lived branches off main, squash-merged via PR

πŸ“– See CONTRIBUTING.md for the workflow details.

✨ Features

Core

  • βš›οΈ React 18 β€” Concurrent rendering
  • πŸ“˜ TypeScript (strict) β€” Type safety end-to-end
  • ⚑ Vite 6 β€” Fast HMR and builds

State, Data & Routing

  • 🐻 Zustand 5 β€” Lightweight state with persistence (8 global stores + 8 domain stores)
  • πŸ—„οΈ Supabase β€” Postgres + Auth + Storage + Edge Functions (the only data layer)
  • πŸš€ React Router 7 β€” Declarative routing

Forms & Validation

  • πŸ“ React Hook Form β€” Performant, flexible forms
  • βœ… Zod 3 β€” TypeScript-first schema validation

UI & Styling

  • 🎨 Tailwind CSS 3 β€” Utility-first, with dark mode
  • 🎬 Framer Motion β€” Animations
  • 🧱 dnd-kit β€” Accessible drag-and-drop
  • πŸ“Š Recharts β€” Charts and analytics
  • 🍞 react-hot-toast β€” Notifications
  • πŸ“„ html2canvas + jspdf β€” Premium exports

Security & Auth

  • πŸ” Supabase Auth β€” Email/password + JWT sessions
  • πŸ›‘οΈ Custom TOTP MFA β€” In src/lib/auth/mfa.ts
  • πŸ€– Cloudflare Turnstile β€” Bot protection on auth gateway
  • πŸͺ΅ Sentry 10 β€” Error monitoring (opt-in via VITE_ENABLE_SENTRY)

Testing & Quality

  • πŸ§ͺ Vitest 4 β€” Unit + component tests (jsdom)
  • 🧩 React Testing Library β€” Component tests
  • β™Ώ jest-axe β€” Accessibility assertions
  • 🎭 Playwright β€” E2E tests (Firefox)
  • πŸ“ ESLint 9 β€” Flat config, with @ts-nocheck debt awareness
  • ✨ Prettier 3 β€” Formatter with Tailwind plugin
  • 🐢 Husky 9 β€” Pre-commit hook (installed via npm run prepare)

Utilities

  • πŸ“… date-fns β€” Date utilities
  • πŸ”§ Custom Hooks β€” useDebounce, useLocalStorage, etc.
  • πŸ“ Path Aliases β€” @/ maps to src/

πŸ“ Project Structure

Feature-sliced architecture β€” domain code lives in src/features/<domain>/, cross-domain primitives in src/shared/ and the classic shared layers. See docs/ARCHITECTURE.md for the full architecture guide, dependency rules, and testing policy.

.
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ features/       # Domain features (timer, social, tasks, habits,
β”‚   β”‚                   #   categories, today, integrations, auth,
β”‚   β”‚                   #   accessibility, onboarding)
β”‚   β”œβ”€β”€ shared/         # Cross-domain UI primitives + layout shell
β”‚   β”œβ”€β”€ lib/            # Framework-free logic (auth, storage, security, env, errors)
β”‚   β”œβ”€β”€ store/          # Global persisted Zustand stores
β”‚   β”œβ”€β”€ pages/          # Routing composition
β”‚   β”œβ”€β”€ hooks/ utils/ schemas/ types/ constants/
β”‚   β”œβ”€β”€ __tests__/      # Cross-cutting tests only
β”‚   β”œβ”€β”€ App.tsx         # Main App component
β”‚   └── main.tsx        # Application entry point
β”œβ”€β”€ e2e/                # Playwright specs (Firefox)
β”œβ”€β”€ scripts/            # Codegen tooling (leagues β†’ constants)
β”œβ”€β”€ public/             # Static assets
β”œβ”€β”€ index.html          # HTML template
└── vite.config.ts      # Vite configuration

πŸš€ Getting Started

Prerequisites

  • Node.js v20+
  • npm v10+
  • A Supabase project (for the backend)
  • Cloudflare Turnstile site key (for auth bot protection)

Installation

# Install dependencies
npm ci

# Copy env template and fill in your values
cp .env.example .env

# Start the dev server (validates env on boot)
npm run dev

# Typecheck + production build
npm run build

# Preview the production build locally
npm run preview

πŸ“œ Available Scripts

Command What it does
npm run dev Vite dev server (port 3000)
npm run build Typecheck then Vite build
npm run typecheck tsc --noEmit over the strict tsconfig
npm run lint ESLint flat config
npm run lint:strict ESLint with --max-warnings 0 (gated on debt burn-down)
npm run lint:debt ESLint in strict mode over @ts-nocheck files
npm run lint:fix ESLint with --fix
npm run format Prettier write
npm run format:check Prettier check (CI gate)
npm test Vitest watch
npm run test:coverage Vitest with v8 coverage
npm run test:e2e Playwright (Firefox)
npm run audit npm audit --audit-level=high

πŸ”§ Configuration

Environment Variables

All VITE_* variables are validated at module load time by src/lib/env.ts. Required vars throw in production; optional vars warn and fall through.

Var Required Notes
VITE_SUPABASE_URL yes Supabase project URL
VITE_SUPABASE_ANON_KEY yes Supabase anon JWT
VITE_API_URL no Backend base URL (unused in current build)
VITE_APP_NAME no Display name (default: HabitFlow)
VITE_APP_VERSION no Display version (default: unknown)
VITE_SENTRY_DSN no Sentry DSN for error reporting
VITE_ENABLE_SENTRY no true to enable Sentry init
VITE_ENABLE_ANALYTICS no true to enable analytics
VITE_TURNSTILE_SITE_KEY no Cloudflare Turnstile site key
VITE_TURNSTILE_DISABLED no true to bypass Turnstile in dev
VITE_GOOGLE_CLIENT_ID / _SECRET / _REDIRECT_URI no Google integration
VITE_NOTION_CLIENT_ID / _SECRET / _REDIRECT_URI no Notion integration
VITE_SLACK_CLIENT_ID / _SECRET / _REDIRECT_URI no Slack integration
VITE_SPOTIFY_CLIENT_ID / _SECRET / _REDIRECT_URI no Spotify integration
VITE_GOOGLE_FIT_REDIRECT_URI no Google Fit integration

In production, missing required vars throw on import β€” the build fails fast. In development, missing required vars log to the console and fall back to placeholders so the dev server can boot.

Path Aliases

Imports use the @/ alias (mapped to src/ in both tsconfig and vite.config.ts):

// Instead of
import Component from '../../../components/Component'

// You can use
import Component from '@/components/Component'

πŸ§ͺ Testing

npm test              # Vitest in watch mode
npm run test:coverage # Vitest with v8 coverage report
npm run test:e2e      # Playwright (Firefox; install via `npx playwright install firefox`)

Tests are colocated with their subjects in __tests__/ directories. Two cross-cutting suites live in src/__tests__/. See docs/ARCHITECTURE.md for the testing policy and known-debt caveats.

πŸ“¦ Building for Production

npm run build

The build runs tsc --noEmit first, then Vite. Output is in dist/, ready to be deployed to any static hosting service.

πŸš€ Deployment

The app is configured for dual-target deployment β€” both kept intentionally:

  • Vercel β€” vercel.json at the repo root
  • Netlify β€” netlify.toml at the repo root

Both build the SPA statically; the Supabase backend is a separate concern managed in the Supabase dashboard.

🀝 Contributing

See CONTRIBUTING.md for setup, branching strategy, commit conventions, and the PR process.

πŸ“„ License

MIT

About

A high-performance React.js Todo application focused on privacy and availability. Features a decentralized architecture using WebRTC for seamless P2P synchronization and task sharing without a central server. Fully optimized as a PWA for offline-first reliability, featuring a robust theme engine and deep-link task sharing.

Topics

Resources

Contributing

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages