Skip to content

PinkyCodeMaster/habits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Habit

Next.js 16 habit tracker with Better Auth + Drizzle (SQLite/libSQL).

Local setup

  1. Install dependencies
npm install
  1. Configure .env
  • BETTER_AUTH_SECRET
  • BETTER_AUTH_URL
  • NEXT_PUBLIC_BETTER_AUTH_URL
  • DB_FILE_NAME (example: file:local.db)
  • MAIL_FROM
  • RESEND_API_KEY (required in production)
  • Optional local React Email relay: REACT_EMAIL_API_URL (example: http://127.0.0.1:5000/api/send)
  • Optional Sentry: SENTRY_DSN, NEXT_PUBLIC_SENTRY_DSN, SENTRY_ORG, SENTRY_PROJECT, SENTRY_AUTH_TOKEN
  • Optional request logging flag: REQUEST_LOGGING_ENABLED=1
  • Optional providers: GOOGLE_*, FACEBOOK_*, MICROSOFT_*
  • Optional admin IDs: BETTER_AUTH_ADMIN_USER_IDS
  • Optional infra key: BETTER_AUTH_API_KEY
  1. Run migrations
npm run db:migrate
  1. Start app
npm run dev

Database operations

  • Generate migration: npm run db:generate
  • Apply migrations: npm run db:migrate
  • Backup DB: npm run db:backup
  • Restore DB (destructive): npm run db:restore -- --from backups/<file>.db --yes
  • Restore drill + integrity check: npm run db:restore:test

Backup config via env:

  • DB_BACKUP_DIR (default backups)
  • DB_BACKUP_PREFIX (default habits)
  • DB_BACKUP_KEEP_COUNT (default 30)

Test commands

  • Integration/auth tests (Vitest): npm test
  • Browser E2E (Playwright): npm run test:e2e
  • Full suite: npm run test:all

First-time Playwright setup:

npx playwright install chromium

Production operations

Error tracking (Sentry)

Sentry is wired via:

  • sentry.server.config.ts
  • sentry.edge.config.ts
  • instrumentation-client.ts
  • instrumentation.ts
  • next.config.ts (withSentryConfig)

Set DSNs and project env vars in production to enable tracking.

Request logging

Structured request logs are emitted for:

  • proxy auth guard requests (src/proxy.ts)
  • Better Auth route handler (src/app/api/auth/[...all]/route.ts)
  • health endpoint (src/app/api/health/route.ts)

Enable/disable with REQUEST_LOGGING_ENABLED.

Uptime checks and alerts

  • Health endpoint: GET /api/health (returns 200 when DB is reachable, 503 otherwise).
  • Configure your uptime provider (Better Stack, UptimeRobot, Pingdom, etc.) to monitor /api/health.
  • Configure Sentry alert rules for:
    • new issues in production
    • spike in error rate
    • throughput drop / transaction latency threshold

CI pipeline

GitHub Actions workflow is provided at:

  • .github/workflows/ci.yml

Pipeline runs:

  1. npm ci
  2. npm run db:migrate
  3. npm run lint
  4. npm test
  5. npm run test:e2e
  6. npm run build

Auth routes

  • /login
  • /signup
  • /forgot-password
  • /reset-password
  • /verify-email
  • /dashboard (protected)
  • /accept-invitation/[invitationId]

Better Auth handler is mounted at /api/auth/[...all].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors