DEV Community

Arnav Patel
Arnav Patel

Posted on AI-assisted

Compline: The Radical Laziness of Sleep — Building an Offline Gothic Sanctuary with Gemma 2, a Real-Time 3D Astrolabe, and Vinyl Crackle

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

This is my submission for the Hacktoberfest Open-Source AI Challenge, Week 3: Slow and Steady. 🦥

I'm Arnav, from Bengaluru. For Week 1's "Touch Grass" challenge, I built WildTrail to get people outdoors. For Week 2's "Side Hustle", I built GhostLedger for sovereign freelancer tax intelligence.

For Week 3, the prompt honors International Sloth Day:

"Build something with open-weight models or open-source AI that rewards laziness: a tool for relaxation, an automation for a task you dread, or anything that makes life easier."

One of the challenge's suggested sparks caught my eye immediately:

"A wind-down companion that generates a calming bedtime story or ambient soundscape, running entirely offline."

So I decided to lean fully into radical laziness and built Compline: a candlelit gothic wind-down companion that transforms your nightstand into an ancient, tranquil monastic scriptorium.


🦥 The Lazy Payoff

Falling asleep in the modern world is an exhausting, high-friction chore:

  1. Decision fatigue: You scroll endless Netflix menus, podcast libraries, or algorithmic YouTube feeds just trying to pick something relaxing.
  2. Blue light bombardment: Bright modern interfaces, push notifications, and recommendation carousels stimulate your brain when you should be slowing down.
  3. SaaS extortion: Sleep apps want $14.99/month, demand account signups, gate basic rainfall audio behind paywalls, and send your bedroom telemetry to cloud servers.

Sloths have it figured out: move at your own pace, conserve your energy, and let the universe come to you.

With Compline, going to sleep requires zero cognitive effort:

  • You open the app in pitch darkness. Tap once. A match strikes, a candle flame flickers to life, and warm amber light floods the sanctuary.
  • The Abbey Phonograph drops its physical needle onto a spinning vinyl platter, filling your room with authentic analog crackle and choral vespers.
  • Google's open-weight Gemma 2 running locally (or our built-in offline hypnagogic generator) streams an unhurried medieval tale word-by-word with illuminated drop-caps and drying golden ink.
  • A 3D celestial astrolabe queries your device's geolocation to orient the 89 classical constellations and 7 wandering planets to match the exact night sky directly above your roof.
  • You don't search. You don't swipe. You don't configure. You just close your eyes.

🏛️ What I Built: The Gothic Nightstand Experience

flowchart TD
    subgraph Client ["Gothic Nightstand Sanctuary (Zero Dependencies)"]
        Candle["🕯️ Cinematic Candle Ritual (Match-Strike / Blackout)"]
        Astrolabe["🧭 3D Celestial Astrolabe (Real Sky LST Alignment)"]
        Phono["📻 Abbey Phonograph (The Needle & The Groove)"]
        Scribe["📜 Scriptorium Tome (Illuminated Ink Stream)"]
        Tarot["⚙️ Wheel of Fate & Gothic Slumber Tarot"]
        Grimoire["📖 Scriptorium Grimoire (Local Bookmark Storage)"]
    end

    subgraph AudioEngine ["Web Audio Procedural Engine"]
        Needle["📍 Needle Drop & Arm Physics"]
        Crackle["🪵 Vintage Surface Crackle (Pink Noise + Lowpass)"]
        Tracks["💿 Opus I: Nocturne / Opus II: Vespers"]
    end

    subgraph AI ["Open-Source AI & Hypnagogic Core"]
        Gemma["🧠 Google Gemma 2 (Local Ollama gemma2:2b / 9b)"]
        Offline["🕯️ Offline Hypnagogic Decrescendo Generator"]
    end

    Candle --> Astrolabe
    Phono --> AudioEngine
    Scribe --> AI

1. 🌌 3D Celestial Astrolabe & "Tonight's Real Sky" Alignment

The nightstand sky isn't a generic looping starry wallpaper. It is an interactive 3D celestial sphere rendering 89 classical constellations (Ursa Major, Cygnus, Orion, Cassiopeia, Lyra, Taurus...), armillary coordinate rings, and the 7 classical wandering planets.

Tapping the dedicated [🌌 Tonight's Real Sky] header button queries your browser's Geolocation API, calculates the exact Greenwich Sidereal Time (GST) and Local Sidereal Time (LST) for your longitude, and rotates the entire celestial sphere so that the stars above your bed match what is overhead in reality.

2. 📻 The Abbey Phonograph (The Needle & The Groove)

A tactile analog player built entirely on the native Web Audio API:

  • Physical Needle Drops: Interactive tone-arm mechanics with authentic physical needle-drop thuds and lift-off crackles.
  • Vintage Surface Noise: A procedural audio synthesis pipeline (pink noise passed through highpass and biquad filters) that recreates warm vinyl record crackle.
  • The Sacred Repertoire: Integrated with atmospheric nocturnal arrangements:
    • Opus I: Abbey Nocturne — Solitary nocturnal piano & cello.
    • Opus II: Gothic Vespers — Sanctuary bells & ethereal Gregorian choral harmonies.

3. 📜 Scriptorium Story Generator & Hypnagogic Decrescendo

Bedtime stories should never have cliffhangers, sudden shocks, or escalating conflict. Compline connects to local Gemma 2 (via Ollama at http://localhost:11434) using structured relaxation prompts designed around hypnagogic decrescendo:

  • Focuses entirely on rich, sensory descriptions (moss-covered stone arches, distant rainfall, flickering beeswax, cedar incense).
  • Streams word-by-word with animated glowing quill cursors, illuminated rubricated drop-caps, and a simulated wet ink drying effect.
  • If Ollama is offline or you're in airplane mode, a procedural Markovian offline scriptorium generates endless non-repeating bedtime tales without needing any internet connection.

4. ⚙️ Wheel of Fate & Gothic Slumber Tarot

An ornate brass-and-stained-glass mechanical wheel with procedural ratchet audio. Giving it a gentle spin draws from an 8-card Gothic Slumber Tarot deck (The Hermit of the Bell Tower, The Alchemist's Crucible, The Scribe of Midnight...) to seed the night's meditation.

5. 📖 Scriptorium Grimoire

Sleepers can bookmark chapters directly to their personal Grimoire, stored privately in the browser's local storage with zero cloud accounts.


🧠 Why Open Innovation & Gemma 2 Matter Here

In the DEV community discussion on running local LLMs, developer Kennedy Raju noted that side projects rarely need an external API key when open-weight models have gotten this good. And as highlighted in recent local AI benchmarks, running smaller models locally achieves real-time streaming speeds with zero network overhead.

Compline only works as a true sleep companion because of open-weight models:

  1. Sacred Bedroom Privacy: Bedtime thoughts, sleep schedules, and relaxation habits are deeply intimate. With Gemma 2 running locally, no prompts, reading history, or timestamps ever leave your room.
  2. Airplane Mode Safe: You can put your laptop or phone in full Airplane Mode to avoid late-night notifications, and Compline continues to write new stories, play vinyl audio, and chart the cosmos.
  3. Zero Marginal Cost: Cloud AI APIs charge per token. A bedtime app running streaming models all night on proprietary cloud APIs would bleed developer money or force obnoxious $15/month subscriptions onto tired users. Gemma 2 is 100% free to run.

🛠️ What Went Wrong (The Engineering Hurdles)

Just like my previous challenge submissions, I made a commitment to test every detail and inspect real network and runtime behavior. That uncovered three tricky technical challenges:

1. The Vercel Edge Node Cache Ghost Trap

After deploying a critical UI fix, I visited the live Vercel URL and noticed the changes weren't appearing. Opening terminal and inspecting HTTP response headers with curl -sI https://complineapp.vercel.app/ revealed the culprit:

HTTP/2 200 
age: 558
cache-control: public, max-age=0, must-revalidate
x-vercel-cache: HIT
Enter fullscreen mode Exit fullscreen mode

Even with max-age=0, Vercel edge nodes (like bom1 in India) cache static assets at the CDN layer unless explicitly told otherwise. The fix was updating vercel.json to enforce edge invalidation across all routes:

{
  \"headers\": [
    {\n      \"source\": \"/(.*)\",\n      \"headers\": [\n        {\n          \"key\": \"Cache-Control\",\n          \"value\": \"no-cache, no-store, must-revalidate, max-age=0, s-maxage=0\"\n        }\n      ]\n    }\n  ]\n}
Enter fullscreen mode Exit fullscreen mode

Setting s-maxage=0 forced edge cache misses (age: 0, x-vercel-cache: MISS) and instant propagation on every new commit!

2. The Celestial Sidereal Time Math

Translating GPS coordinates into an accurate 3D celestial sphere required real celestial mechanics. Standard clock time doesn't match star time because the Earth rotates once relative to the stars in 23 hours, 56 minutes, and 4 seconds (one sidereal day).

To compute the celestial rotation angle, I implemented Greenwich Mean Sidereal Time (GMST) and Local Sidereal Time (LST):

// Calculate Julian Date from UTC
const jd = 2440587.5 + (date.getTime() / 86400000);
const d = jd - 2451545.0; // Days from J2000.0

// Greenwich Mean Sidereal Time in degrees
let gmst = (280.46061837 + 360.98564736629 * d) % 360;
if (gmst < 0) gmst += 360;

// Local Sidereal Time
let lst = (gmst + longitude) % 360;
if (lst < 0) lst += 360;

// Rotate the celestial sphere canvas
const lstHours = lst / 15;
stellarSky.rotationAngle = -(lstHours / 24) * Math.PI * 2;
Enter fullscreen mode Exit fullscreen mode

Now, when you look at Cygnus or Ursa Major in Compline, they are in the exact same orientation as the real night sky outside your window.

3. Killing the Over-Engineered Feature (The Rose Window Prism)

During development, I got excited and spent hours building a volumetric stained-glass god-ray lighting engine (\"Rose Window Prism\"). It rendered animated caustic light shafts and chromatic dust motes across the screen.

When I actually tested it at bedtime, it felt completely wrong:

  • It was visually busy and distracted from the calm scriptorium text.
  • It caused unnecessary GPU strain on mobile devices.
  • It violated the fundamental sloth principle of the challenge: simplicity, calm, and conservation of energy.

So I ruthlessly deleted all 400+ lines of it. Recognizing when to delete code is just as important as knowing what to write. Stripping away the excess left the sanctuary feeling peaceful, quiet, and effortless.


🔍 Behind the Scenes: The Full Agent Session

To give the Hacktoberfest judges a transparent look into how Compline was planned, built, tested, and polished, here is the complete recorded agent session:

Compline: Building an Offline Gothic Sleep Sanctuary with Gemma 2 & 3D Astrolabe
You

Let us build Compline: a classical gothic wind-down sanctuary for Hacktoberfest Week 3. It needs to reward radical laziness with offline sleep induction, local Gemma 2 storytelling, ambient phonograph acoustics, and an interactive 3D astrolabe.

Agent

Architecture designed and implemented:
- Candle Awakening Ritual with match strike illumination and tap to blackout mode
- Abbey Phonograph with physical needle drops, vintage vinyl crackle, and Gregorian choral vespers
- Scriptorium Story Generator powered by local Gemma 2 via Ollama or built in offline hypnagogic generator
- 3D Celestial Astrolabe with 89 classical constellations and 7 wandering planets
- Wheel of Fate with 8 card Gothic Slumber Tarot deck
- Local Grimoire with private bookmarking

You

Can we align the 3D astrolabe to tonight real sky overhead using geolocation?

Agent

Implemented Tonight Real Sky celestial alignment:
- Obtains observer latitude and longitude via browser Geolocation API
- Computes Julian Date from UTC timestamp
- Calculates Greenwich Mean Sidereal Time and Local Sidereal Time
- Rotates the 3D celestial sphere coordinate system to match the exact stars visible overhead

You

Make the astrolabe simple to use and aesthetic.

Agent

Redesigned the astrolabe into a compact Gothic Reliquary:
- Dedicated Tonights Real Sky alignment header button
- Compact 2x2 layer toggle grid for Constellations, Planets, Coordinate Rings, and Deep Sky figures
- Zodiac tokens for quick navigation
- Constellation search selector

You

Investigate why the deployed Vercel site is serving cached HTML and fix it.

Agent

Diagnosed Vercel edge CDN caching behavior. Configured s-maxage=0, max-age=0, must-revalidate in vercel.json across all routes to guarantee instant edge cache invalidation on new commits.

You

Remove the rose window prism feature, it distracts from the calm experience.

Agent

Removed the volumetric lighting shader, deleted prism scripts and canvas elements, and restored the clean tranquil monastic scriptorium. Committed and verified deployment.

You

Update the README and remove unnecessary clutter.

Agent

Streamlined README from 109 lines to 55 lines, added direct live demo badge, and focused on core sleep sanctuary features and offline privacy.

You

Write the post for DEV Week 3 challenge and show me the post.

Agent

Authored and staged the official DEV submission post for Week 3 Slow and Steady, claiming the Featured Best Use of Gemma category, and staged as an unpublished draft on DEV.


🏆 Prize Categories Entered

  • Overall Winner: A complete, beautifully crafted wind-down sanctuary engineered specifically for radical laziness, low cognitive load, and effortless sleep.
  • Featured Category: Best Use of Gemma ($200): Leverages Google's Gemma 2 open-weight model via Ollama for private, low-tension bedtime storytelling with zero cloud telemetry.

🚀 Try Compline

To run it locally with zero external dependencies (pure Python 3 standard library):

git clone https://github.com/XiaoArnav/complineapp.git
cd complineapp
python3 app/server.py
Enter fullscreen mode Exit fullscreen mode

Then visit http://localhost:7777.

Connect local Gemma 2 anytime with ollama run gemma2:2b.

May your nights be restful and peaceful. Channel your inner sloth. 🦥✨

Top comments (0)