90sleep - a sleep cycle calculator

I've launched a new project: 90sleep.com - a sleep cycle calculator to help you figure out the best times to sleep and wake.

I was inspired by an old sleep calculator that's no longer available. The original app worked by calculating sleep cycles between now and your targeted wake time, helping you wake during the shallow phase of your sleep rather than in the middle of a deep sleep cycle. I rebuilt it as 90sleep.

The science is straightforward: sleep cycles are roughly 90 minutes each, and an assumption is made that it takes approximately ~14 minutes to fall asleep. The calculator helps you find optimal bedtimes and wake times based on this rhythm.

There are two modes: "I need to wake up at..." which calculates the closest shallow sleep phase before your desired wake-up time, and "I'm going to bed now" which I see as a sort of emergency mode when I've stayed up farrrrr to late yet still need to be semi-functional in a few hours. This displays the optimal wake times from now.

The site is a static site, generated using Python and Jinja2 templates. It's a similar approach to what I use for this blog (Pelican), but I've written a much simpler custom generator for this project. There's no server-side logic needed - the entire site is generated at build time.

For styling, I'm using Tailwind CSS with a custom colour palette (dark background with warm amber accents) loosely inspired by Dieter Rams. The interactive calculator itself is vanilla JavaScript - no frameworks needed for something this straightforward. I'm also self-hosting the Inter font family to keep things performant.

The build process is handled by a Python script that renders the Jinja2 templates and then the Tailwind CSS CLI minifies the CSS. The site barely needs it given that it's a single-page app, but it keeps it consisent with a bunch of other static sites I run and that makes working on it easier.

The site is deployed to Netlify, which handles the build and hosting automatically whenever I push to GitHub. I've integrated Plausible Analytics for privacy-respecting visitor analytics (no cookies, no tracking pixels).

90sleep works well, but I'm keen to improve the search ranking and have a few feature ideas in the pipeline. If you use it and have suggestions, feel free to reach out!