A Full Stack Next.js application that turns your daily tasks into a fun thing — gamify your habits, complete quests, and track your progress over time across three life categories: Health, Work, and Social.
- Session-Based Authentication — Secure session management with a Vercel cron job that automatically cleans up expired sessions from the database. Sessions are optimized with a B-tree index on the
created_atfield for fast lookups and efficient deletions. - Compact Activity Encoding — User activity (last 365 days) is stored as a string encoding rather than a separate database schema, keeping the data model lean and queries fast. All transformation operations run server-side using array parsing from the encoding string.
- Server-Side Auth Caching — Authentication is checked on server components using a cached function (via React's
cache()) that deduplicates user detail lookups within a single request lifecycle, avoiding redundant database calls. - Client-Side Validation — Forms are validated client-side using Zod schemas and React Hook Form, giving users immediate feedback before any server round-trip.
- Data Access Layer (DAL) — Auth logic is encapsulated in a dedicated DAL instead of relying on Next.js middleware (the legacy proxy pattern), following modern Next.js best practices for secure and composable data access.
- Next.js
- React
- TypeScript
- PostgreSQL
- Prisma ORM
prisma@prisma/clientbcryptzodreact-hook-formtailwindcssshadcn/uidotenv
| Field | Type | Description |
|---|---|---|
id |
String |
UUID primary key |
username |
String |
Unique username |
password |
String |
Bcrypt-hashed password |
healthXP |
Int |
XP accumulated in the Health category |
workXP |
Int |
XP accumulated in the Work category |
socialXP |
Int |
XP accumulated in the Social category |
last365Days |
String |
Compact string encoding of daily activity for the past year |
lastActivityDate |
DateTime |
Timestamp of the user's last recorded activity |
quests |
Quest[] |
Relation — quests owned by this user |
sessions |
Session[] |
Relation — active sessions for this user |
| Field | Type | Description |
|---|---|---|
id |
String |
UUID primary key |
userId |
String |
Foreign key → User.id |
title |
String |
Quest title / task description |
category |
QuestCategory |
Enum: health, work, social |
xp |
Int |
XP reward granted on completion |
status |
DateTime |
Completion timestamp |
| Field | Type | Description |
|---|---|---|
id |
String |
UUID primary key |
userId |
String |
Foreign key → User.id |
token |
String |
Unique session token |
expires_at |
DateTime |
Session expiry timestamp |
created_at |
DateTime |
Session creation timestamp (B-tree indexed) |
Note: The
@@index([created_at])onSessionenables the Vercel cron job to efficiently range-scan and bulk-delete expired sessions without a full table scan.
health | work | social
- Email: alexmita04@gmail.com
See LICENSE