← All posts

How I built Habits Aura: a gamified habit tracker with streaks and aura points

By ·

Habits Aura landing page showing a 47-day streak and today's habit checklist

I'm Adarsh Raut, a full stack software developer based in Pune. Habits Aura is a habit tracker I built to make consistency feel like a game. You pick the days a habit is scheduled, mark each day as done or skipped, and earn "aura" for showing up. The code is on GitHub.

It uses Next.js (App Router), TypeScript, Prisma, PostgreSQL on Neon, NextAuth with Google sign-in, and DaisyUI for styling. Here's how a few of the interesting parts work.

Three states, not two

Most trackers have a checkbox. I wanted a day to be able to be completed, skipped or untouched, so each click cycles through NONE → COMPLETED → SKIPPED → NONE. Skipping on purpose is different from forgetting, and it makes the aura score meaningful.

Habits Aura habit list with streak counts and done or untouched states

Aura points that can't drift

Every user starts with 100 aura. A completed day is worth +10 and a skipped day is worth −10. Undoing a state reverses it, so moving a day from skipped to completed changes the score by +20.

The rule lives in one small module as pure functions: the value of a state, the change when a day moves from one state to another, and the score a user should have, given their completion counts. Because the expected score can always be calculated from the completion rows, I could write a script that checks stored aura against it and catches any drift.

Streaks that respect your schedule

A habit scheduled for Monday, Wednesday and Friday shouldn't lose its streak on Tuesday. So streaks are calculated against the scheduled days only:

  • Only completions on scheduled days, after the habit was created and not in the future, count.
  • The current streak walks backwards from the latest scheduled day while each one is completed.
  • If today is scheduled but you haven't done it yet, the streak isn't broken until the day is over.
  • The longest streak is found in one pass over the sorted completions.

I used to store streaks in the database. Later I dropped those columns and compute streaks from completions instead, so there's no second copy to get out of sync. The habit list only loads about the last 800 days of history, which keeps the query small.

Habits Aura stats page with the current streak, longest streak and yearly heatmap

Dates belong to the user, not the server

The server runs in UTC, but "today" is a local idea. Completions are stored under a date key in the user's time zone, and the streak and heatmap code work on those keys. A habit finished at 11:30 pm in India counts for that day.

Optimistic UI with rollback

Tapping a habit should feel instant, so the UI updates before the server answers. With React Query, onMutate updates the cached list immediately, and onError restores the previous state if the request fails. Deleting a habit works the same way.

Habits Aura leaderboard ranking users by aura points

Protecting the leaderboard

The leaderboard ranks users by aura, so the write endpoints need protection. Toggling, creating, updating and deleting habits are rate limited per user with Upstash (for example, 30 toggles per minute). Without Redis credentials, as in local development, the limiter switches itself off so the app still runs.

Small touches

There's a GitHub-style yearly heatmap for each habit, confetti when you create one, a sound on completion, and a mobile drawer for navigation.

What I'd do next

  • Add reminders for habits scheduled today.
  • Let friends follow each other's streaks.
  • Add more tests around streak edge cases.

You can try Habits Aura here, and I'm happy to talk about it on LinkedIn.