XP and points are the same concept in Mais Hábito. There is a single unified
points field on the User model. There is no separate XP currency.User model — gamification fields
models/User.ts
Task points
Every task carries a configurablepoints field. When you create a task, you choose how many points completing it awards.
models/Task.ts
points must be greater than zero:
services/task.service.ts
How points are earned — task completion flow
When a client callsPOST /api/task-completions, the taskCompletionService.completeTask() function runs the following steps:
Validate task ownership
The service fetches the task by ID and confirms it exists and belongs to the authenticated user.
services/taskCompletion.service.ts
Check for prior completion today
The service queries for any completions by this user with a
completed_at timestamp within today’s date (UTC). The result determines whether the streak should increment.services/taskCompletion.service.ts
Create the TaskCompletion record
A new row is inserted into the
task_completions table, recording the task_id, user_id, and completed_at timestamp.services/taskCompletion.service.ts
Challenge completion
Completing a user challenge (POST /api/user-challenges/:id/complete) is a separate action from task completion and is handled by userChallengeService.completeChallenge(). It marks the UserChallenge record with status: 'COMPLETED' but does not directly award points — point rewards come from completing the individual tasks associated with the challenge.
models/UserChallenge.ts