Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

KotlinintermediatemobileAI generated

Habit Analytics App

Build an Android habit tracker in Kotlin focused on insights: besides ticking habits off each day, it calculates your current and longest streaks, your completion rate over the last 7 and 30 days, and draws a calendar heatmap (like GitHub's contribution graph) showing each day's activity at a glance. Habits can be daily or on specific weekdays (such as gym on Monday, Wednesday and Friday), and streaks respect that, so a rest day doesn't break a streak. Everything is stored with Room and drawn with Jetpack Compose. You'll learn Room, working with dates using java.time, writing correct date-based calculations, drawing custom charts with Compose Canvas, and testing tricky date logic.

Estimate
~12.5h
Steps
7
Completed by
0
Proposed by
codeseed.app

Jetpack Compose · Room

Project roadmap

  1. 01

    Define the rules

    ~1.5h

    Write DESIGN.md: a habit has a name, a color, a schedule (every day, or chosen weekdays) and a start date; completions are dates. Define precisely: a streak counts consecutive scheduled days completed, where unscheduled days don't break it and today doesn't break it until the day is over; the completion rate is completed scheduled days divided by scheduled days in the period. Include worked examples. Done when: DESIGN.md defines every calculation with examples.

  2. 02

    Store habits with Room

    ~1.5h

    Create Room entities for habits and completions (habit id and date, with a unique index so a day can't be completed twice), with type converters for LocalDate and the weekday schedule. Write DAOs returning Flow for habits with their completions in a date range. Done when: DAO tests with an in-memory database pass.

  3. 03

    Build the daily screen

    ~2h

    Build a Compose screen listing today's scheduled habits with a checkbox each, and the others marked as rest days. Ticking and unticking updates Room immediately. Add screens to create and edit habits with their schedule and color, and to fill in a missed day from the past. Done when: habits can be managed and ticked, and the list shows only today's scheduled habits as due.

  4. 04

    Calculate the analytics

    ~2.5h

    Write pure Kotlin functions using java.time: current streak, longest streak, and completion rates for the last 7 and 30 days, all following the schedule rules. Show them on each habit's detail screen. Done when: unit tests covering schedules, rest days, gaps, the start date and today's special case all pass.

  5. 05

    Draw the calendar heatmap

    ~2.5h

    Draw a heatmap with Compose Canvas: one small square per day for the last 6 months, in columns by week, colored by completion (and by how many habits were done on the all-habits view), with unscheduled days drawn differently, month labels, and tapping a day to see its details. Done when: the heatmap matches the completions, and tapping days shows them.

  6. 06

    Handle edge cases

    ~1h

    Handle a habit's schedule changing (past days keep their old schedule, or document your choice), time zone changes and the date changing at midnight while the app is open, and habits with no completions. Done when: each case gives sensible numbers.

  7. 07

    Test it

    ~1.5h

    Write unit tests for all analytics with fixed dates (use a Clock you can control), including weekday schedules across month and year boundaries, and ViewModel tests with a fake repository. Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~12.5h · 7 steps

Tech stack

Jetpack ComposeRoom