Life XP is a gamified productivity and habit tracker that turns your real-world tasks into an RPG. Earn XP, level up, gain stats (Intelligence, Strength, Discipline, Wealth), and unlock witty titles.
- RPG Progression: Earn XP and level up.
- Stats System: Tasks are categorized into INT, STR, DIS, WLTH.
- Habit Streaks: Forgiving streak system with decay (miss a day, lose a bit, don't reset to 0).
- Daily Quests: Randomly generated quests every day.
- Witty Titles: Unlock titles like 'Wandering Potato' or 'Productivity Menace'.
- Full Stack: Next.js (App Router), Node.js/Express, PostgreSQL, Prisma.
- Frontend: Next.js 14, TypeScript, TailwindCSS, Zustand.
- Backend: Node.js, Express, TypeScript, Zod.
- Database: PostgreSQL, Prisma ORM.
- DevOps: Docker, Docker Compose.
The easiest way to run the entire stack is with Docker Compose.
- Clone the repository
- Run Docker Compose
�ash docker-compose up --build - Access the App
- Web: http://localhost:3000
- API: http://localhost:3001
The database will be automatically seeded with a demo user:
- Email: demo@lifexp.app
- Password: DemoPass123!
If you want to run services individually:
- Node.js 20+
- PostgreSQL
Copy .env.example to .env in the root (or set vars manually).
�ash npm install
Ensure Postgres is running. Update DATABASE_URL in .env if needed. `�ash
npm run prisma:migrate --workspace=apps/api
npm run seed --workspace=apps/api `
`�ash
npm run dev `
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/YOUR_USERNAME/lifexp.git
git push -u origin main- Go to railway.app and sign in with GitHub
- Click "New Project" → "Deploy from GitHub repo"
- Select your LifeXP repository
- Click "Add Service" → "Database" → "PostgreSQL"
- Click on your main service, go to Settings:
- Set Root Directory:
apps/api - Set Build Command:
npm install && npx prisma generate && npm run build - Set Start Command:
npm run start
- Set Root Directory:
- Go to Variables tab and add:
DATABASE_URL: Click on PostgreSQL service → Variables → CopyDATABASE_URLJWT_SECRET: Generate a random string (e.g.,openssl rand -base64 32)FRONTEND_URL:https://your-app.vercel.app(add after Vercel deploy)NODE_ENV:production
- Go to Settings → Networking → Generate Domain
- Copy your Railway URL (e.g.,
https://lifexp-api.up.railway.app)
Run Database Migration:
- In Railway, go to your service → Settings → Deploy → Add deploy command:
npx prisma migrate deploy && npm run seed
- Go to vercel.com and sign in with GitHub
- Click "Add New" → "Project"
- Import your LifeXP repository
- Configure the project:
- Root Directory:
apps/web - Framework Preset: Next.js (auto-detected)
- Root Directory:
- Add Environment Variable:
NEXT_PUBLIC_API_URL:https://your-railway-url.up.railway.app/api/v1
- Click Deploy
After both are deployed, update Railway's FRONTEND_URL variable with your Vercel URL.
Backend:
- Create a Web Service on render.com
- Set Root Directory:
apps/api - Build Command:
npm install && npx prisma generate && npm run build - Start Command:
npm start - Add Env Vars:
DATABASE_URL,JWT_SECRET,FRONTEND_URL,NODE_ENV=production
Database:
- Create a PostgreSQL database on Render
- Copy the connection string to
DATABASE_URL
- Monorepo: Managed via npm workspaces.
- Shared Package: @life-xp/shared contains Zod schemas and game mechanics (XP formulas) shared between FE and BE.
- API: Express server with layered architecture (Controllers -> Services -> Data Access).
- Web: Next.js App Router with Client Components for interactive UI.
�ash npm test
Runs Jest tests for the API.
- Auth: JWT stored in HttpOnly cookies.
- Validation: Zod schemas for all inputs.
- Headers: Helmet for security headers.
- Passwords: Bcrypt hashing.
Built for the 'Life XP' Challenge.