DEV Community

Cover image for SUNDEBT: I Made My Phone Charge Me Rent in Sunlight
Samridhi Gupta
Samridhi Gupta

Posted on

SUNDEBT: I Made My Phone Charge Me Rent in Sunlight

Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass Submission 🌿

SUNDEBT ☀️ — Earn Your Screen Time

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass.

What I Built

I open my phone to check one notification, and somehow, thirty minutes disappear.

I didn't want to build another app that shames me for scrolling or simply locks me out. I wanted to flip the idea:

What if I had to earn my screen time by spending time outside?

That question became SUNDEBT — Earn Your Screen Time.

SUNDEBT turns outdoor time and movement into a currency for screen time. Spend time outside, earn Sun Minutes, pay off your Sun Debt, and unlock screen time through the Scroll Gate. Along the way, Sol, a companion powered by a local AI model, suggests small outdoor missions to get you moving.

The idea is simple: put your phone down, get moving, earn your minutes, and make screen time something you work toward.

☀️ How It Works

  • ☀️ Sun Sessions: Start an outdoor session, put your phone down, and spend time outside. The intended experience uses available sensor signals to assess sunlight and movement.
  • 👟 Steps as Currency: Estimated steps contribute to your Sun Minutes, turning movement into currency you can use toward screen time.
  • ✨ Sun Minutes: Your earned minutes pay off Sun Debt first. Any remaining balance becomes spendable screen time.
  • 🤖 Sol: A companion powered by a local AI model that suggests short outdoor missions.
  • 🌱 Sol's Growth: Earn XP as you progress. The longer-term vision is a personalized digital forest that grows with your outdoor habits.
  • 🚪 Scroll Gate: Adds a pause before selected web links, encouraging you to choose intentionally instead of scrolling on reflex.

SUNDEBT includes a 90-minute daily earning cap and a step-based bonus. Your wallet and session history stay in your browser, with no accounts or database.

I built this for the Touch Grass challenge because I wanted to explore a different relationship with technology—not one based on guilt or punishment, but on making real-world experiences rewarding.

🎬 Try SUNDEBT

🌐 Live frontend: https://sundebt.vercel.app/

💻 Source code: https://github.com/justsamridhi/SUNDEBT

📖 README and setup guide: https://github.com/justsamridhi/SUNDEBT/blob/main/README.md

🔧 Merged Ollama configuration fix: https://github.com/justsamridhi/SUNDEBT/pull/1

🎥 10-second demo: Watch on Google Drive

📱 A Look Inside

SUNDEBT dashboard showing the Sun Minutes wallet, Sol companion, and outdoor mission

SUNDEBT outdoor mission screen with a suggested walk and Start Session button

SUNDEBT session debrief showing earned minutes, estimated steps, and session history

SUNDEBT diagnostic screen showing available browser sensor checks

🛠️ How I Built It

SUNDEBT combines a mobile-first progressive web app with a local AI-guidance pipeline and durable session workflows.

Tech stack

  • Frontend: React, TypeScript, Vite, PWA
  • Backend: Express, TypeScript
  • Agent framework: Mastra
  • Local inference: Ollama with llama3.2:3b
  • Workflow orchestration: Temporal

Architecture

The AI-guidance path connects the PWA to the backend, where a Temporal workflow coordinates the session and Sol's AI activity.

React PWA
   |
   v
Express API
   |
   v
Temporal Sun Session Workflow
   |
   v
Sol Activity -> Mastra Agent -> Ollama
   |
   +-- Invalid output or failure
                |
                v
      Deterministic mission fallback
Enter fullscreen mode Exit fullscreen mode

🤖 Sol: Local AI That Fails Gracefully

I wanted Sol to be helpful without making the entire application dependent on an AI response.

Sol uses a Mastra agent backed by Llama 3.2 3B through Ollama. The model receives limited context, including Sun Minutes, Sun Debt, recent session durations, and time of day. Its output is parsed and validated before a mission is displayed.

A safety filter rejects unsafe guidance, including medical claims and risky location suggestions. If the output is empty, malformed, invalid, unsafe, or the model is unavailable, SUNDEBT falls back to a deterministic mission.

The goal wasn't just to make AI work. It was to make the experience useful when AI doesn't.

🐛 The Bug That Taught Me the Most

For a while, Sol kept showing the offline mission.

The app appeared to work because the fallback was reliable, but it also hid whether the AI path was actually succeeding.

My local RTX 3050 has 4 GB of VRAM, and Mastra's structured-output approach caused memory problems. I switched to plain-text generation and wrote a tolerant JSON parser that strips code fences, extracts the JSON object, and validates the result.

Then I discovered a timeout mismatch.

I added logging for fallback reasons such as empty output, timeout, parsing, schema validation, safety rejection, and provider failure. My observations showed:

  • Cold model call: approximately 7.2 seconds
  • Warm model call: approximately 1 second
  • One observed call: 10 seconds
  • Original Temporal Activity timeout: 8 seconds

A valid response could arrive too late and be discarded.

I increased the Activity timeout to 40 seconds, aligned API and frontend waits, added a startup warm-up request, and introduced a visible “Sol is thinking…” state.

That debugging process changed how I thought about reliability.

A fallback can keep an application alive, but observability tells you whether the primary system is actually working.

⏳ Why Temporal?

A Sun Session isn't a single API request. It involves a Sun Check, phone-down phase, outdoor timer, interruptions, resumes, and completion.

Temporal models this progression through a sunSessionWorkflow, event signals, and workflow state. Sol runs as an Activity, while reward logic handles the daily cap, step bonus, debt-first repayment, and XP.

Backend tests cover duplicate event IDs and repeated completion to help prevent the same event from awarding the same reward twice.

The wallet remains browser-local. Temporal stores workflow state and event history—not a cross-device account or wallet.

🌱 The Vision for Sol's Digital Forest

Sol currently has a progression system based on XP. The larger idea is to make that progress visible through a personalized digital forest.

Imagine earning sunlight and movement minutes to help your digital world grow. Returning to social media during an outdoor session could put that progress at risk, making the choice to stay outside more meaningful.

The forest and tree-dying mechanic are future ideas, not features currently implemented. They represent the direction I'd like to explore next: making time away from the screen feel as rewarding as time spent on it.

✅ Verification

I ran the following checks locally:

  • Backend typecheck: Passed
  • Backend tests: 19 passed, 0 failed
  • Backend TypeScript build: Run without errors shown in the shared terminal output
  • Frontend production build: Passed

The tests cover Sol output validation, safety rejection, fallback and retry behaviour, event deduplication, and reward calculations.

🌍 Why Open Innovation Matters

Open innovation gave me the freedom to experiment, inspect failures, and change the implementation instead of treating AI as a black box.

With Ollama and an open-weight model, I could explore local inference within my hardware limits. Mastra provided the agent layer, while Temporal helped model a multi-stage session that needs predictable behaviour.

These tools didn't remove the difficult engineering. They gave me the means to investigate it, learn from it, and build something more resilient.

That's what makes open innovation valuable to me: the ability to understand a system, adapt it, and share what I learn.

🧑‍💻 My GitHub Copilot Workflow

I used GitHub Copilot's VS Code agent/chat workflow for repository inspection, scoped code changes, debugging, tests, and README updates.

I used narrow prompts and explicit file scopes, asked the agent to preserve existing behaviour, and avoided automatic commits or pushes. Copilot assisted with Sol's integration and fallback path, output validation, logging, Temporal workflow reliability, reward handling, tests, and documentation.

One limitation was that Copilot's command environment couldn't find PowerShell, so it couldn't execute the requested local checks. I ran the typecheck, backend tests, and production builds in my own VS Code terminal and reviewed the resulting changes myself.

I also caught and corrected configuration drift between the model used by the code and the README/environment example.

The process reinforced an important principle: AI-assisted development still needs human review, deliberate debugging, and independent verification.

🏆 Prize Categories

Best Use of Temporal

A multi-stage session workflow with event handling, Activity timeouts, and idempotent reward logic.

Repository: https://github.com/justsamridhi/SUNDEBT

Best Use of Mastra

A local-model agent with validated output and deterministic fallback handling.

Repository: https://github.com/justsamridhi/SUNDEBT

Best Use of GitHub Copilot

Scoped agent-based development, debugging, tests, and documentation, with local verification of the resulting changes.

Merged configuration fix: https://github.com/justsamridhi/SUNDEBT/pull/1

🚀 What's Next?

I'd like to explore a native Android version with stronger, platform-supported app blocking, more reliable outdoor-session signals, and the digital forest concept.

The frontend is deployed on Vercel. The full AI and durable-workflow path requires the backend, Temporal service and worker, and Ollama running locally. If those services or the model are unavailable, the app can continue with deterministic offline guidance and its browser-local wallet.

The current web app cannot guarantee that a phone remains locked, conclusively prove outdoor presence, measure Vitamin D, or block every installed app. Browser and device support also determine which sensor readings are available.

SUNDEBT is an experiment in making a small change feel rewarding.

The phone can wait. Go see what's outside.

Contributor: Aditya Modani — @modapk06

Top comments (0)