Skip to content

Latest commit

 

History

History
110 lines (79 loc) · 1.42 KB

File metadata and controls

110 lines (79 loc) · 1.42 KB

API

All public HTTP traffic goes through the API gateway at http://localhost:4000/api.

Auth

POST /api/auth/register

{
  "name": "Alex Morgan",
  "email": "alex@example.com",
  "password": "demo1234",
  "timezone": "Europe/Belgrade"
}

Returns:

{
  "user": {
    "id": "...",
    "name": "Alex Morgan",
    "email": "alex@example.com",
    "avatarColor": "#12b886",
    "timezone": "Europe/Belgrade"
  },
  "token": "jwt"
}

POST /api/auth/login

{
  "email": "demo@lifetracker.dev",
  "password": "demo1234"
}

Dashboard

GET /api/dashboard

Requires Authorization: Bearer <token>.

Returns habits, active streak, weekly completion rate, heatmap, and category breakdown.

Habits

POST /api/habits

{
  "name": "Read for 20 minutes",
  "category": "learning",
  "color": "#3b82f6",
  "targetPerWeek": 4
}

POST /api/habits/:habitId/checkins

{
  "mood": "good",
  "note": "Finished one chapter"
}

Publishes:

  • habit.completed
  • streak.updated

Challenges

GET /api/challenges

Returns public challenges.

POST /api/challenges/join

{
  "challengeId": "..."
}

Publishes challenge.joined.

Realtime

Socket.IO endpoint: http://localhost:4003

Client auth:

io("http://localhost:4003", {
  auth: { token }
});

Events:

  • life:recent
  • life:event
  • life:public-event
  • presence:update