Skip to content
← All work

Sleep

Luna

Last night's sleep from your watch, turned into a score and one plain tip

Luna's name over the PostgreSQL, Flutter and NestJS marks, beside a phone showing a Sleep Score of 89 and last night's stage chart.
Industry
Sleep
Product type
Mobile application
Period
October 2026
Platforms
iOS, Android
Services
Cross-platform ApplicationsBackend Systems
Technology
Flutter · Dart · BLoC/Cubit · GoRouter · Dio · GetIt · Hive · HealthKit · Health Connect · WorkManager · Firebase · NestJS · TypeScript · PostgreSQL · Drizzle · Docker

Luna reads last night from Apple Health or Health Connect, the sleep stages, heart rate and HRV a watch or ring has written there, and turns it into a Sleep Score, a stage chart and one plain tip each morning. In the evening it guides a short breathing wind-down, and a streak drawn as moon phases rewards doing the routine and getting to bed on time. Luna is built and not yet in the app stores.

What we did
Built the Flutter app for iPhone and Android, with sleep scoring done on the phone, offline storage and background sync, and the NestJS and PostgreSQL backend that holds the optional cloud backup.
Outcome
Built, not yet in the app stores. A morning screen that explains the night in one score and one sentence, and an evening routine that takes about five minutes.

Draft write-up. The product and the screens are real; this account of the work is a draft awaiting review by the team who built it, and by the client.

The problem

A watch records the night and then hands you a dashboard

Plenty of people already wear something that writes their sleep to Apple Health or Health Connect. What they get back is minutes per stage and a heart rate variability figure in milliseconds, which is a lot of data and very little to act on when getting ready for bed.

Sleep data is also personal. Someone who only wants a clearer picture of their nights should not have to send them to a server to get one.

Luna on a phone, scrolled past the stage chart: a recovery gauge at 70, 171 minutes of sleep debt, and a one-line tip for tonight.

The approach

Score the night on the phone, from the raw samples

Each morning the app reads the night's samples and computes a Sleep Score from 0 to 100 on the device, from four things: how long, how efficiently, how much of it was deep and REM, and how consistent the bedtime was. The score comes with a stage chart, hours asleep against time in bed, sleep debt over seven nights and one tip in plain words.

A recovery gauge compares heart rate variability and resting heart rate with the person's own baseline rather than with a population average. Week and month trends follow the score, hours, bedtime drift and deep plus REM, with short notes on what stood out, such as weekends running later.

Luna's Today screen on an angled phone: a Sleep Score ring at 89, hours asleep and in bed, and the stage chart.

Design

Quiet at night, with a small reason to come back

The whole app is a dark night palette, because it is opened in a dark bedroom. The streak is a moon: the left half lights when the evening routine is done, the right half when the person is in bed within 30 minutes of their target, and only a full moon counts. A calendar shows the last 30 nights as moons, next to the best streak so far.

Setup is a conversation with Luna, the sleep guide, instead of a form: consents, the main thing that gets in the way of sleep, schedule, goal, Health permission and a bedtime reminder. The schedule is set by dragging a moon and a sun along one track.

Luna's streak screen on a phone: nine nights in a row shown as a moon phase, and a 30-night calendar of moons.

Build

Offline first, and private by default

Every screen paints from local Hive storage, so it shows the last known data at once and works without signal. Changes go into an ordered outbox with backoff, drained in the background every six hours through WorkManager on Android and background tasks on iOS. The Flutter code follows Clean Architecture with Cubits, and the health data comes through Apple HealthKit and Health Connect.

By default the nights never leave the phone. A person can choose a backup to servers in Frankfurt, served by a NestJS and PostgreSQL backend with Drizzle, download everything as two JSON files, or delete the account from the settings.

Luna's privacy screens on two phones: download my data as two files, and a choice between phone only and phone plus EU cloud.

Result

A morning to read and an evening routine

In the evening the Wind down tab offers Coherent, Box or 4-7-8 breathing, about five minutes paced by an animated moon. An optional calm meter reads heart rate through the phone camera with the app's own signal processing, and a bedtime reminder, scheduled on the phone so it works offline, mentions the streak.

Luna is built and not yet in the app stores, and nothing here claims medical accuracy for the score or the camera reading. No usage figures are published here, because none have been measured for this site.

Luna's Wind down screen on a phone: Coherent, Box and 4-7-8 tabs, a moon, the calm meter option and a Begin button.

Inside the app

Real screens, demo data

  • Luna Today: a Sleep Score of 89, 7 h 43 m asleep, in bed from 22:39 to 06:36, and a chart of deep, REM, core and awake stages.
  • Luna trends for a month: an average Sleep Score of 86, a 30-night chart, and two notes on earlier nights and later weekends.
  • Luna wind down: a choice of Coherent, Box or 4-7-8 breathing, a moon, the optional calm meter and a Begin button.
  • Luna sleep profile: a moon and sun slider setting the night from 22:45 to 06:45, and a sleep goal of eight hours.
  • Luna streak: nine nights in a row drawn as a moon phase, and the last 30 nights laid out as a calendar of moons.
  • Luna onboarding as a chat: the guide asks what gets in the way of a good night, then offers a time wheel to pick a bedtime.

06Book a call

Building something like this?

Book thirty minutes and we'll tell you quickly whether we're the right team for it, and roughly what it takes.

Prefer to write?
  1. 01You pick the slot
  2. 02Bring anything you have
  3. 03We come prepared

Your idea stays yours. Read only by the people who would build it, never reused, never passed on. Happy to sign your NDA first.

Pick a time. We'll tell you what it takes.

Thirty minutes, no pitch deck. Bring a rough idea or a finished spec, and leave with a straight answer on scope, cost and whether we're the right team.

  1. 01
    You pick the slotA live calendar, not a queue. Most people find something inside forty-eight hours.
  2. 02
    Bring anything you haveA spec, a Figma link, screenshots, a competitor you like, or nothing at all.
  3. 03
    We come preparedWe read whatever you send beforehand, so the call starts at the interesting part.

Your idea stays yours

  • What you share stays between you and the people on your project.
  • We never reuse your concept, your research or your materials elsewhere.
  • Happy to sign your NDA before the call, or send ours.

We read every brief and reply within 60 minutes.

Prefer to write? with your files instead, or email abdullahmughal1976@gmail.com.