<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Omar Afifi</title>
    <description>The latest articles on DEV Community by Omar Afifi (@omarafifi).</description>
    <link>https://dev.to/omarafifi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3954903%2F1b239da9-6bec-4707-b255-626d891d9dd7.png</url>
      <title>DEV Community: Omar Afifi</title>
      <link>https://dev.to/omarafifi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omarafifi"/>
    <language>en</language>
    <item>
      <title>SunSync: How I Used TabPFN, Google Gemma, and ElevenLabs to Help Developers Touch Grass</title>
      <dc:creator>Omar Afifi</dc:creator>
      <pubDate>Sun, 11 Oct 2026 20:33:46 +0000</pubDate>
      <link>https://dev.to/omarafifi/sunsync-how-i-used-tabpfn-google-gemma-and-elevenlabs-to-help-developers-touch-grass-4i37</link>
      <guid>https://dev.to/omarafifi/sunsync-how-i-used-tabpfn-google-gemma-and-elevenlabs-to-help-developers-touch-grass-4i37</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week1-2026-10-05"&gt;Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;Most software developers spend their working days indoors under artificial lighting, locked to an IDE, staring at screens for hours on end.&lt;/p&gt;

&lt;p&gt;By mid-afternoon, the consequences are familiar across the tech community: eye strain, brain fog, fading focus, and a disrupted circadian rhythm that makes quality sleep an uphill battle. For years, I treated this as simply the unavoidable occupational hazard of writing code.&lt;/p&gt;

&lt;p&gt;The real issue isn't a lack of discipline or coffee—it's that standard indoor work environments fight against basic human biology.&lt;/p&gt;

&lt;p&gt;The human body relies on natural daylight to set its internal circadian clock. But standard office windows filter out the specific daylight wavelengths needed to feel alert. Even sitting right next to a window, indoor lighting is rarely brighter than 400–500 lux—compared to 10,000+ lux outdoors. To the body, sitting inside all day feels like constant twilight, draining energy and throwing off sleep.&lt;/p&gt;

&lt;p&gt;And the tech industry's standard answer to developer burnout? &lt;strong&gt;Another screen.&lt;/strong&gt; Wellness apps that demand more typing, habit trackers with endless push notifications, and weather apps that treat sunlight purely as a sunburn hazard.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;&lt;a href="https://sunsync.omar-afifi.com/" rel="noopener noreferrer"&gt;SunSync&lt;/a&gt;&lt;/strong&gt; as a direct alternative.&lt;/p&gt;

&lt;p&gt;SunSync is a lightweight open-source daylight timing tool built with a single goal: &lt;strong&gt;evaluate local sunlight in under 30 seconds, give you a quick 15-second eyes-free voice brief, lock into a 20-minute outdoor breathing timer, and get you away from your desk into the fresh air.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works in Practice
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Zero-Shot Tabular ML on CPU (Prior Labs TabPFN):&lt;/strong&gt; Instead of naive heuristics, a foundation tabular transformer (&lt;code&gt;TabPFNRegressor&lt;/code&gt;) fits 12 daylight hours in a single forward pass without gradient descent, evaluating solar angles, cloud cover, and irradiance to compute your best 20-minute sunlight window (e.g., &lt;code&gt;13:15 - 13:35&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eyes-Free Spoken Directive (Google Gemma + ElevenLabs):&lt;/strong&gt; A 15-second spoken briefing delivers the key window and UV safety tips using ElevenLabs' low-latency &lt;code&gt;eleven_flash_v2_5&lt;/code&gt; model and the natural, calm Charlie voice—turning raw telemetry into a human send-off so you don't have to keep reading a screen.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production Grounding for Safe Health Guidance:&lt;/strong&gt; Gemma crafts natural, encouraging dialogue, while a deterministic validation layer guarantees that safety-critical numbers (the computed window start and UV index) remain strictly grounded to the underlying physics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Outdoor Breathing Lock:&lt;/strong&gt; When you tap &lt;em&gt;"I'm going outside"&lt;/em&gt;, the UI locks into a 20-minute circular breathing timer so you can put your phone away. You focus on the horizon (never staring directly at the sun) and return to your desk refreshed and ready to code.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The app is live, publicly accessible, and deployed on Google Cloud Run with interactive OpenAPI documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;Live Web Application:&lt;/strong&gt; &lt;a href="https://sunsync.omar-afifi.com" rel="noopener noreferrer"&gt;https://sunsync.omar-afifi.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📡 &lt;strong&gt;Interactive OpenAPI Specification:&lt;/strong&gt; &lt;a href="https://sunsync.omar-afifi.com/docs" rel="noopener noreferrer"&gt;https://sunsync.omar-afifi.com/docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync" rel="noopener noreferrer"&gt;https://github.com/OmarAfifi-CSE/sunsync&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Mobile-First Interface Tour (Zero Mockups)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table width="100%"&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th width="25%"&gt;☀️ 01 · Hero Protocol&lt;/th&gt;
      &lt;th width="25%"&gt;⏱️ 02 · 20-Min Sun Window&lt;/th&gt;
      &lt;th width="25%"&gt;🎙️ 03 · Gemma Spoken Brief&lt;/th&gt;
      &lt;th width="25%"&gt;🌿 04 · Touch Grass Protocol&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td width="25%"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FOmarAfifi-CSE%2Fsunsync%2Fmain%2Fdocs%2Fscreenshots%2Fmobile-hero.jpg" width="800" alt="SunSync Mobile Hero Dashboard" height="1759"&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FOmarAfifi-CSE%2Fsunsync%2Fmain%2Fdocs%2Fscreenshots%2Fmobile-glance-window.jpg" width="800" alt="SunSync Mobile 20-Minute Solar Window" height="1759"&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FOmarAfifi-CSE%2Fsunsync%2Fmain%2Fdocs%2Fscreenshots%2Fmobile-gemma-voice-brief.jpg" width="800" alt="SunSync Mobile Gemma Spoken Brief" height="1759"&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FOmarAfifi-CSE%2Fsunsync%2Fmain%2Fdocs%2Fscreenshots%2Fmobile-touch-grass-protocol.jpg" width="800" alt="SunSync Mobile Touch Grass Protocol" height="1759"&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width="25%"&gt;
        &lt;em&gt;Glance card: today's window, live countdown, recharge score — the 10-second answer.&lt;/em&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;em&gt;Decision card (&lt;b&gt;GO NOW / Wait / Done&lt;/b&gt;) + UV safety bands + daylight curve to 6 PM.&lt;/em&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;em&gt;Fact-verified Gemma directive with source badge (✦ Gemma live / ⚡ edge instant) + Charlie voice playback.&lt;/em&gt;
      &lt;/td&gt;
      &lt;td width="25%"&gt;
        &lt;em&gt;The outdoor commitment card: 20-minute breathing timer + auto-playing voice send-off, phone face-down.&lt;/em&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Every screenshot above is a raw capture from my live production deployment on Google Cloud Run - zero synthetic device frames, zero mockups.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What to Look for When Testing
&lt;/h3&gt;

&lt;p&gt;The app dynamically adapts to whatever time of day you test it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test Your Location or City Presets:&lt;/strong&gt; Tap &lt;strong&gt;Use my location&lt;/strong&gt; or switch between presets (Cairo, London, New York, Tokyo). SunSync calculates the solar window relative to that location's local solar clock, not your computer's clock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Real-Time States:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upcoming Window (&lt;code&gt;Wait&lt;/code&gt;):&lt;/strong&gt; If it's daytime before the computed peak, you'll see a live countdown ticking down to the recharge window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Active Window (&lt;code&gt;GO NOW&lt;/code&gt;):&lt;/strong&gt; If you test during the peak window, the status badge flips to &lt;code&gt;GO NOW&lt;/code&gt; with live UV guidance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Past Window (&lt;code&gt;Done today&lt;/code&gt;):&lt;/strong&gt; If the sun has set or the peak has already passed in that city, the card displays &lt;code&gt;Done today&lt;/code&gt; and advises morning light tomorrow—it will never tell someone to go recharge under a dark night sky.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Listen to Charlie (Voice Briefing):&lt;/strong&gt; Tap &lt;strong&gt;Listen · 15s brief&lt;/strong&gt; on any location to hear the lifelike ElevenLabs voice briefing with real-time UV safety tips.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The entire codebase is open-source, fully tested, and available on GitHub:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💻 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync" rel="noopener noreferrer"&gt;https://github.com/OmarAfifi-CSE/sunsync&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The project is structured around lean, modular Python services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src/circadian_ml.py&lt;/code&gt;: Prior Labs TabPFN zero-shot Bayesian tabular regression on live CPU.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/gemma_service.py&lt;/code&gt;: Google Gemma integration paired with deterministic factual grounding (&lt;code&gt;validate_directive()&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/audio_service.py&lt;/code&gt;: ElevenLabs low-latency voice synthesis via &lt;code&gt;eleven_flash_v2_5&lt;/code&gt; (Charlie voice).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/data_service.py&lt;/code&gt;: Ingests real-time Open-Meteo weather data (solar irradiance, UV index, cloud cover, and sun angles) to feed into TabPFN.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/app.py&lt;/code&gt;: FastAPI application instrumented with distributed Sentry tracing spans. &lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. System Architecture &amp;amp; Dual-Lane Decoupling
&lt;/h3&gt;

&lt;p&gt;I enforced a strict architectural principle: &lt;strong&gt;The user's first paint must never wait on generative AI.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                ┌─────────────────────────────┐
                │  Live Open-Meteo Telemetry  │
                │(Hourly UV, Solar Irradiance)│
                └──────────────┬──────────────┘
                               │
                               ▼
                ┌─────────────────────────────┐
                │   Feature Vector Assembly   │
                │  (12-Hour Daylight Context) │
                └──────────────┬──────────────┘
                               │
                               ▼
[Sentry Spans]  ┌─────────────────────────────┐
(Distributed) ─►│  Prior Labs TabPFN ML Core  │
(Latency Trace) │ (Zero-Shot Bayesian CPU ML) │
                └──────────────┬──────────────┘
                               │
                               ▼
                ┌─────────────────────────────┐ ◄── [Grounding Layer]
                │ Google Gemma Directive Core │     (Factual Verify:
                │ (Natural Spoken Directive)  │      Window &amp;amp; UV)
                └──────────────┬──────────────┘
                               │
                               ▼
[Google Cloud]  ┌─────────────────────────────┐
(Cloud Run)   ─►│ ElevenLabs Audio Synthesis │
(Public Host)   │ (Lifelike Charlie Briefing) │
                └─────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I decoupled the execution into two asynchronous paths:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Fast Lane (&lt;code&gt;/evaluate&lt;/code&gt;):&lt;/strong&gt; Computes solar geometry, atmospheric vector transforms, and TabPFN scoring. Returns the deterministic solar window and recharge score immediately with an instant analytical draft.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Slow Upgrade Lane (&lt;code&gt;/directive&lt;/code&gt; &amp;amp; &lt;code&gt;/synthesize-audio&lt;/code&gt;):&lt;/strong&gt; Asynchronously generates the personalized Google Gemma voice directive and ElevenLabs audio stream, upgrading the UI quote in place without blocking interaction.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Prior Labs TabPFN: Foundation Tabular ML on CPU
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;src/circadian_ml.py&lt;/code&gt;, I run the &lt;strong&gt;real&lt;/strong&gt; &lt;code&gt;TabPFNRegressor&lt;/code&gt; on live CPU. My training context is exactly &lt;strong&gt;12 rows&lt;/strong&gt;—the daylight operational hours of a single day (7 AM to 6 PM).&lt;/p&gt;

&lt;p&gt;Classical ML algorithms like XGBoost or RandomForest fail here: they demand hundreds of rows, hyperparameter tuning, and cross-validation splits that don't exist in single-day telemetry. TabPFN is a prior-fitted transformer trained on millions of synthetic tabular tasks that performs Bayesian posterior inference in a single forward pass without gradient descent:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric / Verification Check&lt;/th&gt;
&lt;th&gt;Production Measured Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Peak window reproducibility across consecutive runs&lt;/td&gt;
&lt;td&gt;✅ Identical time window every run (deterministic)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Score variance across repeated runs&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.00&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Window stability under seeded ±5% sensor noise&lt;/td&gt;
&lt;td&gt;✅ Resilient &amp;amp; stable (score Δ 2.6)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Warm inference execution on multi-core CPU&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1.1–1.5 s&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Container cold initialization (one-time weight loading)&lt;/td&gt;
&lt;td&gt;~15–17 s (isolated to container cold boot; never blocks warm traffic)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# From src/circadian_ml.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tabpfn&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TabPFNRegressor&lt;/span&gt;

&lt;span class="c1"&gt;# 12 daylight rows. No gradient descent: forward pass stores tabular context
&lt;/span&gt;&lt;span class="n"&gt;regressor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TabPFNRegressor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;cpu&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n_estimators&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;regressor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train_atmospheric&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_melanopic_target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;predicted_eml&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regressor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X_train_atmospheric&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With only 12 hourly data points per day, traditional ML models fall apart. TabPFN is built specifically for this: delivering accurate Bayesian predictions on small tabular data in under a second without overfitting or requiring hours of hyperparameter tuning.&lt;/p&gt;

&lt;p&gt;To deploy SunSync cleanly in production, I packaged the application into an optimized container running on &lt;strong&gt;Google Cloud Run&lt;/strong&gt; with 4 vCPUs and 4 GB RAM in &lt;code&gt;europe-west1&lt;/code&gt;. Within the container runtime, I tuned PyTorch's intra-op parallelism (&lt;code&gt;torch.set_num_threads(min(4, os.cpu_count()))&lt;/code&gt;) and configured &lt;code&gt;TabPFNRegressor(n_estimators=4)&lt;/code&gt;. This unlocks multi-core execution on the tabular transformer while preventing thread thrashing, keeping memory rock-solid and delivering consistent sub-1.5s inference on warm instances.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Sentry Distributed Agent Tracing: Real Production Telemetry Bands
&lt;/h3&gt;

&lt;p&gt;I instrumented the entire pipeline with distributed Sentry tracing spans (&lt;code&gt;ai.telemetry.ingest&lt;/code&gt;, &lt;code&gt;ai.model.tabpfn&lt;/code&gt;, and &lt;code&gt;ai.llm.gemma&lt;/code&gt;) to monitor live production performance, diagnose latency variances, and ensure pipeline health.&lt;/p&gt;

&lt;p&gt;Rather than publishing synthetic local benchmarks, Sentry reveals the authentic behavior across live cloud conditions on Google Cloud Run:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Span Name&lt;/th&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Warm Production Range&lt;/th&gt;
&lt;th&gt;Production Lifecycle Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ai.telemetry.ingest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open-Meteo REST Fetch &amp;amp; Serialization&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70–300 ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Live upstream solar telemetry fetch (varies with DNS &amp;amp; regional latency)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ai.model.tabpfn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TabPFN Tabular Feature Fitting &amp;amp; Scoring&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1.1–1.5 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;In-memory zero-shot Bayesian regression on 4 vCPUs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ai.llm.gemma&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Google Gemma Narrative Generation&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1.4–2.2 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Non-blocking slow-lane synthesis via OpenRouter/Google AI Studio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Fast-Lane User Delivery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;&lt;code&gt;/evaluate&lt;/code&gt; Deterministic Delivery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~1.5–2.5 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Immediate deterministic UI paint; zero blocking on LLM or audio generation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  What Sentry Revealed: Observability in Action
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cold Starts vs. Warm Multi-Core Execution:&lt;/strong&gt; In a serverless container environment like Google Cloud Run, initial container spin-up requires importing PyTorch and loading TabPFN's transformer checkpoint into memory (~15–17s on cold boot). Sentry tracing immediately surfaced this difference: once the container is warm, multi-core CPU execution consistently executes in &lt;strong&gt;~1.1–1.5s&lt;/strong&gt;. Sentry isolated container lifecycle overhead from algorithmic compute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upstream Data Hygiene:&lt;/strong&gt; Distributed tracing caught intermittent floating-point NaNs returned by upstream weather sensors, allowing me to inject a deterministic sanitization layer (&lt;code&gt;_sanitize_float&lt;/code&gt;) before data reaches TabPFN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dual-Lane User Protection:&lt;/strong&gt; By tracing span durations, I verified the value of decoupling &lt;code&gt;/evaluate&lt;/code&gt; (the fast lane) from &lt;code&gt;/directive&lt;/code&gt; and &lt;code&gt;/synthesize-audio&lt;/code&gt; (the slow lane). The user's screen renders the photobiology dashboard in ~2 seconds, while Gemma and ElevenLabs upgrade the briefing asynchronously in the background.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  4. Google Gemma: Fast Generative Directives with Production Grounding
&lt;/h3&gt;

&lt;p&gt;To deliver a personalized, encouraging voice brief that doesn't sound like a boilerplate weather bot, I integrated Google's &lt;strong&gt;Gemma 3 27B&lt;/strong&gt; (&lt;code&gt;google/gemma-3-27b-it&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;Gemma excels at following concise persona instructions while maintaining a natural, empathetic tone. For SunSync's fast-paced user flow, instruction-tuned Gemma delivers punchy 15-second directives in seconds without the latency overhead of extended thinking traces.&lt;/p&gt;

&lt;h4&gt;
  
  
  Grounding &amp;amp; Health Safety Guardrails (&lt;code&gt;src/gemma_service.py&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;Because UV exposure and solar timing directly affect user well-being, production AI requires strict factual grounding. Gemma provides the creative, human variety, while code verifies that safety-critical numbers match reality before reaching the user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# From src/gemma_service.py
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;validate_directive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;window_time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;uv_index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
    Code-decides guardrail: The model narrates, but only verified facts ship.
    A candidate passes iff it repeats the computed window start AND grounds
    the UV reading. Any hallucinated drift is instantly rejected.
    &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;window_time&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Hallucinated or shifted time -&amp;gt; rejected
&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;uv_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uv_index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="nf"&gt;except &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="n"&gt;text_lower&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;uv_token&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;uv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;text_lower&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;  &lt;span class="c1"&gt;# Dropped or fabricated UV safety reading -&amp;gt; rejected
&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This dual-layer architecture guarantees total reliability: Gemma crafts natural, motivating copy, while the verification layer ensures that the solar window and UV safety readings remain 100% faithful to the underlying telemetry. The UI displays an authentic badge indicating the exact origin (&lt;code&gt;✦ Gemma live&lt;/code&gt; vs &lt;code&gt;⚡ edge instant&lt;/code&gt;).&lt;/p&gt;




&lt;h3&gt;
  
  
  5. ElevenLabs Voice Architecture: Screen-Free Audio Presence
&lt;/h3&gt;

&lt;p&gt;Standard browser text-to-speech engines sound robotic, monotone, and clinical—developers tune them out immediately. To build an app that genuinely motivates someone to step away from their desk, the voice needed to feel calm, natural, and human.&lt;/p&gt;

&lt;p&gt;I integrated ElevenLabs using the &lt;code&gt;eleven_flash_v2_5&lt;/code&gt; model and the official Charlie voice (&lt;code&gt;IKne3meq5aSn9XLyUdCD&lt;/code&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Low-Latency Voice:&lt;/strong&gt; &lt;code&gt;eleven_flash_v2_5&lt;/code&gt; synthesizes the spoken brief in seconds while the UI stays fully interactive, and a browser-voice fallback guarantees the guide plays even if the API is unreachable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Calm, Human Pacing:&lt;/strong&gt; Charlie delivers a natural, reassuring presence when reading the computed UV warnings and window times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eyes-Free Outdoor Send-Off:&lt;/strong&gt; When you tap &lt;em&gt;"I'm going outside"&lt;/em&gt;, Charlie plays a warm send-off audio message so you can pocket your phone immediately and head out without looking back at the screen.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  6. The Field Test: Taking SunSync Outside for 20 Minutes (Bonus Challenge)
&lt;/h3&gt;

&lt;p&gt;The Hacktoberfest Week 1 challenge brief includes an explicit bonus criteria: taking the build outside, testing it in the real world, and reporting the experience.&lt;/p&gt;

&lt;p&gt;During development, when SunSync computed my local 20-minute peak recharge window (&lt;code&gt;14:15 - 14:35&lt;/code&gt;), I followed my own protocol:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I opened the live production URL on my phone, tapped &lt;strong&gt;Listen · 15s brief&lt;/strong&gt;, heard Charlie read out the computed window and UV safety tips, and tapped the green commitment button (&lt;em&gt;"I'm going outside"&lt;/em&gt;).&lt;/li&gt;
&lt;li&gt;The UI locked into the 20-minute circular breathing ring. I turned the phone face-down, slipped it into my pocket, and walked out under the open sky.&lt;/li&gt;
&lt;li&gt;Instead of checking notifications, I just looked out toward the horizon and took a walk (without staring directly at the sun, of course).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How it actually went:&lt;/strong&gt;&lt;br&gt;
You notice the difference within a few minutes. Staring at an IDE two feet away for hours puts constant strain on your eyes. Looking out at the horizon under natural outdoor daylight lets your eyes relax and gives your nervous system a genuine reset. By the time the 20-minute timer wrapped up and I walked back to my desk, the usual 3:00 PM afternoon slump was gone—no extra coffee required.&lt;/p&gt;




&lt;h3&gt;
  
  
  7. Handling Timezones &amp;amp; Diurnal States: Real API Outputs
&lt;/h3&gt;

&lt;p&gt;Because SunSync runs live against the target location's solar clock, the decision engine and Gemma's spoken brief adapt dynamically to the time of day. Below are unedited API responses captured from the production service demonstrating how the system handles different diurnal states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;When the Day's Peak Has Already Passed (e.g., Evening in Cairo):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Coordinates:&lt;/em&gt; &lt;code&gt;30.04° N, 31.24° E&lt;/code&gt; · Computed Window: &lt;code&gt;14:15 - 14:35&lt;/code&gt; · Score: &lt;code&gt;100/100&lt;/code&gt; · UV: &lt;code&gt;5.35&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Gemma Spoken Brief:&lt;/em&gt; &lt;em&gt;"Quick one: Just noting your daylight break peak — it was 14:15 - 14:35 with a UV of 5.35 — missed it, but let's aim for softer morning light tomorrow!"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Behavior:&lt;/em&gt; Recognizes the peak has passed, the UI displays &lt;code&gt;Done today&lt;/code&gt;, and advises softer morning light tomorrow without false "go outside now" prompts in the dark.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;When the Day's Peak Is Upcoming (e.g., Morning in New York):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Coordinates:&lt;/em&gt; &lt;code&gt;40.71° N, -74.01° W&lt;/code&gt; · Computed Window: &lt;code&gt;14:15 - 14:35&lt;/code&gt; · Score: &lt;code&gt;100/100&lt;/code&gt; · UV: &lt;code&gt;0.95&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Gemma Spoken Brief:&lt;/em&gt; &lt;em&gt;"Hey you: Your daylight break with a UV index of 0.95 opens later today between 14:15 - 14:35, so be ready to step outside then!"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Behavior:&lt;/em&gt; Confirms future tense ("opens later today"), ticking down a live countdown rather than prompting the user prematurely.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;When Testing Across Far Timezones (e.g., Midnight in Tokyo):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Coordinates:&lt;/em&gt; &lt;code&gt;35.68° N, 139.65° E&lt;/code&gt; · Computed Window: &lt;code&gt;12:15 - 12:35&lt;/code&gt; · Score: &lt;code&gt;100/100&lt;/code&gt; · UV: &lt;code&gt;5.2&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Gemma Spoken Brief:&lt;/em&gt; &lt;em&gt;"Fresh air alert: Your daylight break with a UV value of 5.2 opens between 12:15 - 12:35 today, so prepare to step outside then!"&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Behavior:&lt;/em&gt; Evaluates Tokyo-local time (UTC+9) rather than the tester's client time, correctly scheduling the upcoming daylight window.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Closed wellness algorithms treat human biology as a proprietary subscription black box. Building SunSync on an open-source architecture made critical capabilities possible that closed proprietary APIs simply cannot deliver:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Circadian Health Belongs to Everyone, Not Subscription SaaS:&lt;/strong&gt; Human biology is not an enterprise product. By building SunSync with open-source models, open data, and containerized infrastructure, the entire pipeline costs &lt;strong&gt;~$0.00 to run&lt;/strong&gt; at this scale. Anyone can fork the repository, deploy the included &lt;code&gt;Dockerfile&lt;/code&gt; on Google Cloud Run's free tier, and use it indefinitely without paying a $15/month wellness tax.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local CPU Independence via TabPFN:&lt;/strong&gt; Closed AI APIs demand continuous internet connectivity, recurring credit card billing, and API key management. TabPFN running zero-shot on local CPU proves that high-performance scientific modeling doesn't require gigawatt GPU clusters. Serving TabPFN directly on the application CPU keeps tabular predictions fast, self-contained, and completely free of remote ML endpoint costs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict Data Privacy:&lt;/strong&gt; Commercial wellness applications harvest location history to monetize behavioral profiles. SunSync queries Open-Meteo for atmospheric weather only. My LLM prompts receive pure numerical arrays (irradiance, UV, angles)—&lt;strong&gt;personal coordinates are never passed to any AI model&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transparent, Reproducible Logic:&lt;/strong&gt; Proprietary health apps hide behind vague, closed algorithms. By keeping SunSync open source, every developer can inspect the exact solar calculations, daylight thresholds, and automated test suites.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Featured Categories
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Best Use of TabPFN (Prior Labs)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How SunSync Uses It:&lt;/strong&gt; Evaluates real 12-row tabular atmospheric telemetry vectors on live CPU using &lt;code&gt;TabPFNRegressor(n_estimators=4)&lt;/code&gt; with zero GPU dependencies. TabPFN predicts Equivalent Melanopic Lux (EML) in a single forward pass without gradient descent, achieving a &lt;strong&gt;0.00 score variance&lt;/strong&gt; across repeated runs. Foundation weights are pre-baked into Docker image layers, and warm multi-core CPU execution consistently evaluates in &lt;strong&gt;~1.1–1.5s&lt;/strong&gt; on Google Cloud Run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence in Repo:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync/blob/main/src/circadian_ml.py" rel="noopener noreferrer"&gt;&lt;code&gt;src/circadian_ml.py&lt;/code&gt;&lt;/a&gt; · Determinism &amp;amp; stability benchmarks · &lt;code&gt;tests/test_circadian_ml.py&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Best Use of Gemma (Google)
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How SunSync Uses It:&lt;/strong&gt; Uses Google's state-of-the-art open model (&lt;code&gt;google/gemma-3-27b-it&lt;/code&gt; via OpenRouter with Google AI Studio fallback) to synthesize the 15-second spoken outdoor directive. Gemma turns raw telemetry into an encouraging, natural audio brief, protected by a production grounding layer (&lt;code&gt;validate_directive()&lt;/code&gt;) that ensures computed window times and UV safety ratings remain strictly accurate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence in Repo:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync/blob/main/src/gemma_service.py" rel="noopener noreferrer"&gt;&lt;code&gt;src/gemma_service.py&lt;/code&gt;&lt;/a&gt; · &lt;code&gt;tests/test_gemma_service.py&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Partner Categories
&lt;/h3&gt;

&lt;h4&gt;
  
  
  3. Best Use of Sentry Agent Tracing
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How SunSync Uses It:&lt;/strong&gt; Shows the entire pipeline's performance via distributed tracing spans (&lt;code&gt;ai.telemetry.ingest&lt;/code&gt;, &lt;code&gt;ai.model.tabpfn&lt;/code&gt;, and &lt;code&gt;ai.llm.gemma&lt;/code&gt;). Sentry traces directly revealed upstream network latency, informed the progressive dual-lane decoupling, and surfaced upstream floating-point NaNs that led to the &lt;code&gt;_sanitize_float&lt;/code&gt; safety layer. Token metrics (&lt;code&gt;llm.estimated_prompt_tokens: 48&lt;/code&gt;) are attached to every span.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence in Repo:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync/blob/main/src/app.py" rel="noopener noreferrer"&gt;&lt;code&gt;src/app.py&lt;/code&gt;&lt;/a&gt; 42–52 &amp;amp; 212–220 · Latency waterfall table in write-up · Expandable Sentry telemetry HUD in UI&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Best Use of ElevenLabs
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How SunSync Uses It:&lt;/strong&gt; Powers SunSync's eyes-free audio interface using the &lt;code&gt;eleven_flash_v2_5&lt;/code&gt; model and the official Charlie voice (&lt;code&gt;IKne3meq5aSn9XLyUdCD&lt;/code&gt;). Delivers lifelike voice briefings and outdoor send-offs so developers can pocket their phones without looking at screens. ElevenLabs transforms what would otherwise be a robotic notification into a calm, human ritual that encourages stepping away from the desk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence in Repo:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/sunsync/blob/main/src/audio_service.py" rel="noopener noreferrer"&gt;&lt;code&gt;src/audio_service.py&lt;/code&gt;&lt;/a&gt; · &lt;a href="https://github.com/OmarAfifi-CSE/sunsync/blob/main/src/static/app.js" rel="noopener noreferrer"&gt;&lt;code&gt;src/static/app.js&lt;/code&gt;&lt;/a&gt; &lt;em&gt;(voice pipeline: synthesizeAudioElement, speakViaBrowser fallback, playDetoxGuide)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Closing: Step Away from the Screen
&lt;/h3&gt;

&lt;p&gt;For years, I treated developer fatigue as a software problem to be solved with more software, more productivity tools, and more screen time.&lt;/p&gt;

&lt;p&gt;Building SunSync reinforced the opposite truth: the most valuable thing an AI tool can do is provide a fast, mathematically grounded answer, get completely out of the way, and encourage a return to the physical world.&lt;/p&gt;

&lt;p&gt;Human knowledge has real limits, and so does biological endurance. A developer simply isn't built to spend 14 hours a day under office lights staring at glowing screens.&lt;/p&gt;

&lt;p&gt;Now, close this tab. &lt;/p&gt;

&lt;p&gt;Lock your screen. &lt;/p&gt;

&lt;p&gt;Step outside, and go touch some grass. 🌿&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>mlhacks</category>
      <category>ai</category>
    </item>
    <item>
      <title>Building an Agent That Can't Afford to Be Wrong: Quran Sanity Agent</title>
      <dc:creator>Omar Afifi</dc:creator>
      <pubDate>Sun, 04 Oct 2026 06:59:52 +0000</pubDate>
      <link>https://dev.to/omarafifi/building-an-agent-that-cant-afford-to-be-wrong-quran-sanity-agent-1pai</link>
      <guid>https://dev.to/omarafifi/building-an-agent-that-cant-afford-to-be-wrong-quran-sanity-agent-1pai</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/sanity-2026-09-16"&gt;Sanity Challenge, Path One: Ship an Agent That Queries Real Content&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;When I first opened the Sanity Challenge announcement, one sentence in the Path One brief immediately grabbed my attention:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Build anything that needs an answer it can't afford to get wrong."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That one line defined this entire project. &lt;/p&gt;

&lt;p&gt;If you ask an AI chatbot for movie recommendations or a recipe, a small hallucination is harmless. But if you ask it about the Quran, religious scripture, or classical commentary, &lt;strong&gt;getting things wrong is not an option.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yet that is exactly what standard LLMs do every day:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They drop words from verses or invent Arabic grammar on the fly.&lt;/li&gt;
&lt;li&gt;When two classical scholars disagree, the model either invents a fake consensus or blends both opinions into a confusing, contradictory mess.&lt;/li&gt;
&lt;li&gt;It cites famous books and scholars with total confidence, even when the quote never existed in that book.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traditional RAG (Retrieval-Augmented Generation) doesn't fix this either, because dumping raw chunks into a prompt still leaves the model free to summarize, blur, and paraphrase whatever it wants.&lt;/p&gt;

&lt;p&gt;I wanted to see what happens when you treat the problem differently: &lt;strong&gt;what if the AI literally cannot generate Quranic text?&lt;/strong&gt; What if the agent only has access to verified, structured records in Sanity, and conflicting historical opinions are modeled cleanly as data rather than smoothed over?&lt;/p&gt;

&lt;p&gt;That is what &lt;strong&gt;Quran Sanity Agent&lt;/strong&gt; is built to do.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Quran Sanity Agent&lt;/strong&gt; is a bilingual (Arabic &amp;amp; English) web research workspace where every single verse, translation, and scholarly commentary is anchored to an immutable record in Sanity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7exqwu402ek1oy2051a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7exqwu402ek1oy2051a.png" alt="Quran Sanity Agent Interface" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works in Practice
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verses Are Read, Never Generated:&lt;/strong&gt; The LLM is never asked to recite or recall Quranic text from memory. Every Ayah displayed in the interface is pulled directly from a verified Sanity document matching the authoritative Tanzil Uthmani 1.1 reference standard.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scholarly Differences as Structured Data:&lt;/strong&gt; In classical Islamic exegesis (Tafsir), scholars have debated linguistic nuances and legal rulings for over a thousand years. Instead of hiding these differences, the application structures them into two distinct categories:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Contradictory (&lt;em&gt;Ikhtilaf Tadadd&lt;/em&gt;):&lt;/strong&gt; True conflicting positions (e.g., whether the opening &lt;em&gt;Basmalah&lt;/em&gt; is counted as a verse of Al-Fatihah).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complementary (&lt;em&gt;Ikhtilaf Tanawwu'&lt;/em&gt;):&lt;/strong&gt; Multi-faceted meanings that coexist (e.g., whether &lt;em&gt;Al-Asr&lt;/em&gt; refers to time itself or the afternoon prayer).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Evidence Drawer:&lt;/strong&gt; Every verse and commentary card has an interactive citation badge. Clicking it opens a side drawer showing the exact Sanity Document ID, the physical book locator (chapter, volume, and primary URL), and the raw JSON payload straight from the Content Lake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honest Evidence Gaps:&lt;/strong&gt; If you ask a question outside the curated dataset (like modern cryptocurrency rulings), the agent doesn't try to guess or produce an ungrounded opinion. It explicitly reports an &lt;strong&gt;Evidence Gap&lt;/strong&gt;, showing what records it searched and clarifying that no authoritative source is available.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The app is live, publicly accessible, and backed by a hosted Sanity Studio:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;Live Web Application:&lt;/strong&gt; &lt;a href="https://quran-sanity.omar-afifi.com" rel="noopener noreferrer"&gt;https://quran-sanity.omar-afifi.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🏛️ &lt;strong&gt;Hosted Sanity Studio:&lt;/strong&gt; &lt;a href="https://quran-evidence-studio.sanity.studio/" rel="noopener noreferrer"&gt;https://quran-evidence-studio.sanity.studio/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/OmarAfifi-CSE/quran-sanity-agent" rel="noopener noreferrer"&gt;https://github.com/OmarAfifi-CSE/quran-sanity-agent&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Zero-Trust Transparency: The Live Evidence Drawer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbur676jvqlalkovb7lcg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbur676jvqlalkovb7lcg.png" alt="Evidence Drawer with Raw Sanity Content Lake JSON" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Inspect real-time Sanity Document IDs, physical book locators, and raw JSON payloads straight from the Content Lake.&lt;/em&gt;&lt;/p&gt;


&lt;h3&gt;
  
  
  Queries You Can Test Right Now
&lt;/h3&gt;

&lt;p&gt;Here are four questions you can paste into the live app to see the structured pipeline in action:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Exact Verse Integrity:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Query: &lt;code&gt;2:255&lt;/code&gt; (or switch the UI to Arabic and type &lt;code&gt;البقرة ٢٥٥&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What to look for:&lt;/em&gt; Instant retrieval of Ayat al-Kursi with verified Uthmani script and Saheeh International translation. Click the citation badge to view &lt;code&gt;ayah-2-255&lt;/code&gt; in the Evidence Drawer.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Contradictory Divergence:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Query: &lt;code&gt;Compare interpretations of Al-Fatiha Basmalah&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What to look for:&lt;/em&gt; Surfaces the opposing classical positions between Ibn Kathir / Al-Qurtubi vs. Fakhr al-Din al-Razi side-by-side, without the model taking a side or muddying the waters.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Complementary Divergence:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Query: &lt;code&gt;Compare interpretations of Al-Asr&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What to look for:&lt;/em&gt; Shows how Al-Tabari, Ibn Kathir, and Al-Qurtubi each highlight complementary dimensions of the word (time, human deeds, afternoon prayer).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semantic Retrieval via Sanity Context MCP:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Query: &lt;code&gt;What does the Quran say about justice even against oneself?&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;What to look for:&lt;/em&gt; The agent queries the Sanity Context MCP endpoint, ranks Ayah 4:135 at the top, and provides grounded notes quoting the primary text verbatim.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;The entire codebase is open-source and available on GitHub:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/OmarAfifi-CSE/quran-sanity-agent" rel="noopener noreferrer"&gt;github.com/OmarAfifi-CSE/quran-sanity-agent&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project is structured as a TypeScript monorepo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;web/&lt;/code&gt;:&lt;/strong&gt; Next.js 15 (App Router) interface with full Arabic RTL support and the Sanity Context MCP integration.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;studio/&lt;/code&gt;:&lt;/strong&gt; Sanity Studio v3 with custom Desk Structure and dedicated Islamic hermeneutic schemas.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;scripts/&lt;/code&gt;:&lt;/strong&gt; Verification tools ensuring zero character drift against reference text standards.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  How I Used Sanity
&lt;/h2&gt;

&lt;p&gt;This project is built around the idea that &lt;strong&gt;an agent is only as reliable as the structure behind its content.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Here is how Sanity handles every layer of the architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────────────────────────────────────────┐
│                   SANITY CONTENT LAKE                    │
│   • 114 Surahs (Surah number, names, revelation type)    │
│   • 6,236 Ayahs (Uthmani text, translation, keywords)    │
│   • 6 Tafsir Authorities (Scholar, death year, school)   │
│   • 12 Audited Interpretive Claims with primary excerpts │
└────────────┬─────────────────────────────┬───────────────┘
             │                             │
    Exact Lookups (GROQ)          Semantic Queries (MCP)
             │                             │
             ▼                             ▼
┌──────────────────────────┐  ┌─────────────────────────────┐
│ Deterministic Lake Fetch │  │ Sanity Context MCP Endpoint │
│  • Sub-50ms response     │  │  • 21,398 library chunks    │
│  • Direct schema joins   │  │  • Vector embeddings rank   │
└────────────┬─────────────┘  └────────────┬────────────────┘
             │                             │
             └──────────────┬──────────────┘
                            ▼
┌──────────────────────────────────────────────────────────┐
│                 NEXT.JS AGENT WORKSPACE                  │
│   • Verifies all candidate IDs against Content Lake      │
│   • Rejects AI notes that lack verbatim source quotes    │
│   • Renders bilingual cards &amp;amp; Evidence Drawer            │
└──────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  1. The Content Model (&lt;code&gt;studio/schemaTypes/&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Instead of generic blog or article schemas, Sanity Studio manages structured Quranic and classical commentary data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;surah&lt;/code&gt;:&lt;/strong&gt; Core chapter metadata (number, Arabic name, English name, revelation type, verse count).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ayah&lt;/code&gt;:&lt;/strong&gt; Individual verse records containing Tanzil Uthmani text, verified English translations, and references to parent chapters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tafsirSource&lt;/code&gt;:&lt;/strong&gt; Classical authorities (e.g. Al-Tabari d. 310 AH, Al-Qurtubi d. 671 AH, Ibn Kathir d. 774 AH) with their specific methodology (&lt;code&gt;athari&lt;/code&gt;, &lt;code&gt;juridical&lt;/code&gt;, &lt;code&gt;rational&lt;/code&gt;, &lt;code&gt;linguistic&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;interpretiveClaim&lt;/code&gt;:&lt;/strong&gt; An atomic claim linking an &lt;code&gt;ayah&lt;/code&gt; to a &lt;code&gt;tafsirSource&lt;/code&gt;. It stores the primary excerpt (&lt;code&gt;primaryExcerpt&lt;/code&gt;), the physical book locator (&lt;code&gt;sourceLocator&lt;/code&gt;), the divergence classification (&lt;code&gt;contradictory&lt;/code&gt;, &lt;code&gt;complementary&lt;/code&gt;, &lt;code&gt;consensus&lt;/code&gt;), and editorial status.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sourceEdition&lt;/code&gt; &amp;amp; &lt;code&gt;libraryChunk&lt;/code&gt;:&lt;/strong&gt; Ingestion schemas representing 21,398 chunks across classical commentaries for semantic retrieval.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The Editorial Review Gate
&lt;/h3&gt;

&lt;p&gt;One of the most practical things about Sanity Studio is how easily you can customize the &lt;strong&gt;Desk Structure&lt;/strong&gt; to enforce editorial discipline.&lt;/p&gt;

&lt;p&gt;In &lt;a&gt;&lt;code&gt;studio/deskStructure.ts&lt;/code&gt;&lt;/a&gt;, I added a custom &lt;strong&gt;"Needs source review"&lt;/strong&gt; filter:&lt;br&gt;
If an editor enters a new claim but forgets the primary book excerpt, the exact source URL, or the reviewer sign-off, Sanity immediately catches it and moves it into this review queue.&lt;/p&gt;

&lt;p&gt;More importantly, the Next.js agent's GROQ queries strictly filter for &lt;code&gt;reviewStatus in ["source_checked", "reviewed"]&lt;/code&gt;. If a claim hasn't passed the editorial gate, the AI agent is physically unable to see it or use it in an answer.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Sanity Context MCP &amp;amp; Semantic Retrieval
&lt;/h3&gt;

&lt;p&gt;While exact verse numbers (e.g. &lt;code&gt;2:255&lt;/code&gt;) are resolved instantly via deterministic GROQ queries, thematic questions (e.g. &lt;em&gt;"What does the Quran say about justice?"&lt;/em&gt;) require semantic understanding.&lt;/p&gt;

&lt;p&gt;To handle this, I pointed &lt;strong&gt;Sanity Context&lt;/strong&gt; at the imported library of &lt;strong&gt;21,398 chunks&lt;/strong&gt; and enabled Content Lake embeddings:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When a user asks a conceptual question, the agent queries the remote &lt;strong&gt;Sanity Context MCP endpoint&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The MCP server ranks relevant chunks based on semantic similarity and returns their document IDs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Grounding Rule:&lt;/strong&gt; The agent never relies solely on the LLM's summary. It uses those document IDs to re-fetch the raw records directly from the Content Lake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verbatim Quotation Enforcement:&lt;/strong&gt; If the model generates an explanatory note, the application validates that the note quotes words directly from the retrieved source text. If it fails this check, the UI falls back to displaying the raw verified excerpt.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Sanity Project Details
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sanity Project ID:&lt;/strong&gt; &lt;code&gt;qkca243t&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dataset:&lt;/strong&gt; &lt;code&gt;production&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosted Studio:&lt;/strong&gt; &lt;a href="https://quran-evidence-studio.sanity.studio/" rel="noopener noreferrer"&gt;https://quran-evidence-studio.sanity.studio/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sanity Context MCP Endpoint:&lt;/strong&gt; &lt;code&gt;https://api.sanity.io/v1/context/organizations/o831wcpb9/mcp/quran-evidence-mcp&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Content Lake Stats:&lt;/strong&gt; 6,369 primary documents (114 Surahs, 6,236 Ayahs, 6 Tafsir Sources, 12 Curated Interpretive Claims) and 21,398 indexed library chunks.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What Building This Taught Me
&lt;/h2&gt;

&lt;p&gt;Building this project made one thing very clear:&lt;/p&gt;

&lt;p&gt;The solution to AI hallucination in high-stakes domains isn't "better prompts" or larger models. It's &lt;strong&gt;structured content.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you treat texts as unstructured strings dumped into a vector database, the AI is always one step away from fabricating an answer. But when you model your domain properly—distinguishing chapters from verses, authorities from editions, and consensus from disagreement—the AI stops guessing and starts acting as an interface to verified knowledge.&lt;/p&gt;

&lt;p&gt;Sanity was uniquely suited for this: having schemas, the Content Lake, GROQ, and the Context MCP in one unified ecosystem meant I could build a zero-hallucination agent that remains completely transparent with every answer it gives.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Check out the live project at &lt;a href="https://quran-sanity.omar-afifi.com" rel="noopener noreferrer"&gt;quran-sanity.omar-afifi.com&lt;/a&gt; and explore the code on &lt;a href="https://github.com/OmarAfifi-CSE/quran-sanity-agent" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>sanitychallenge</category>
      <category>sanity</category>
      <category>ai</category>
    </item>
    <item>
      <title>My Phone Broke, and Gemini Fixed It</title>
      <dc:creator>Omar Afifi</dc:creator>
      <pubDate>Wed, 09 Sep 2026 22:26:48 +0000</pubDate>
      <link>https://dev.to/omarafifi/my-phone-broke-and-gemini-fixed-it-329l</link>
      <guid>https://dev.to/omarafifi/my-phone-broke-and-gemini-fixed-it-329l</guid>
      <description>&lt;h2&gt;
  
  
  📱 Picture This: An All-Nighter Turns Into a Morning Nightmare
&lt;/h2&gt;

&lt;p&gt;It is early morning. You’ve just pulled an all-nighter tinkering with an Android project over ADB. The sun is already creeping through the window, tests finally pass, and you unplug the USB cable from your OnePlus to finally go to bed.&lt;/p&gt;

&lt;p&gt;You unlock your screen, swipe down to open Settings, and freeze.&lt;/p&gt;

&lt;p&gt;Right across your menus is a block of bright-red monospace text:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyu387sfmchubhw4o4si.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyyu387sfmchubhw4o4si.jpg" alt="The mysterious red debug overlay on OxygenOS" width="431" height="948"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;isOverScrolling: false
X: FlingVX: 0.0, ClickVX: 0.0
Y: FlingVY: 15435.0, ClickVY: 0.0
AbortVX:0.0, AbortVY:15435.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You stare at it, then touch the screen again. The numbers immediately jump, recalculating in real time with every movement of your thumb. You swipe fast, and &lt;code&gt;FlingVY&lt;/code&gt; shoots into the tens of thousands. &lt;/p&gt;

&lt;p&gt;Then you notice something even worse: the phone is lagging badly. &lt;/p&gt;

&lt;p&gt;When you swipe from the screen edge to go back, the gesture stutters. Pulling out the OnePlus Smart Sidebar hesitates and drops frames. The smooth 120Hz display suddenly feels like a cheap phone struggling to keep up.&lt;/p&gt;




&lt;h2&gt;
  
  
  🥶 Zero Results: When Google Goes Completely Silent
&lt;/h2&gt;

&lt;p&gt;Your developer reflexes kick in immediately. You jump straight into &lt;strong&gt;Developer Options&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Pointer Location?&lt;/em&gt; Off.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Show Layout Bounds?&lt;/em&gt; Off.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Show Taps?&lt;/em&gt; Off.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Strict Mode?&lt;/em&gt; Off.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything is disabled. &lt;/p&gt;

&lt;p&gt;Fine. You hold down the power button and reboot. The phone restarts, you unlock it, open Settings, scroll down—and the red numbers are still right there.&lt;/p&gt;

&lt;p&gt;That's when you start to panic. You open your browser and start searching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;"red text on android screen"&lt;/code&gt;: &lt;em&gt;Generic guides telling you to turn off Developer Options.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"OnePlus red text on screen"&lt;/code&gt;: &lt;em&gt;Threads asking about the red "1" on the lock screen clock (funny, but not helping).&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"OnePlus red text error"&lt;/code&gt;: &lt;em&gt;Nothing remotely relevant.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"isOverScrolling: false" OnePlus&lt;/code&gt;: &lt;em&gt;No results found.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;"AbortVX"&lt;/code&gt; / &lt;code&gt;"ClickVX"&lt;/code&gt;: &lt;em&gt;Absolute zero.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Zero results. Not a single thread on XDA Forums, not a mention on Reddit, and nothing on the OnePlus Community.&lt;/p&gt;

&lt;p&gt;If you've worked with Android long enough, you know what this silence means: when an issue has zero documentation in AOSP and zero community threads, you're usually looking at a full factory reset.&lt;/p&gt;




&lt;h2&gt;
  
  
  😴 "That’s Future Me’s Problem"
&lt;/h2&gt;

&lt;p&gt;At that point, the morning sun was already up. I had stayed up all night, I was running on zero sleep, completely exhausted, and my brain felt like an OutOfMemory error. I stared at the red numbers on my screen and made the most mature engineering decision possible:&lt;/p&gt;

&lt;p&gt;I decided to go to sleep.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"You know what? This is future me's problem."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I put the phone face-down on the nightstand, closed my eyes, and hoped it would just magically disappear by the time I woke up.&lt;/p&gt;

&lt;p&gt;Fast forward to later that afternoon: I woke up, tapped the screen, and nope—the red velocity numbers were still right there, tracking every single swipe while I was still half-asleep.&lt;/p&gt;

&lt;p&gt;Now awake and ready to deal with it, I decided it was time to bring in serious backup.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤖 Handing the Terminal to Gemini
&lt;/h2&gt;

&lt;p&gt;I plugged the USB cable back into my laptop. I opened my Antigravity IDE where I had been pair-programming with &lt;strong&gt;Gemini&lt;/strong&gt;, and typed out of pure frustration:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Hey, you ran some ADB commands on my phone earlier for some app testing and now there's this weird red text on my screen and the edges are lagging. I plugged it in—fix it."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If this were a standard chatbot, you already know what its first response would be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Go to Settings &amp;gt; Developer Options and disable 'Pointer Location', 'Show Layout Bounds', or 'Strict Mode'. If those are already off, try backing up your data and performing a factory reset."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Every standard LLM defaults to that exact script because it assumes you're dealing with standard Android toggles. And when you tell it they're already off, it hits a complete dead end.&lt;/p&gt;

&lt;p&gt;Instead, Gemini took the wheel. What happened on my terminal over the next few minutes was impressive: rather than giving boilerplate advice, Gemini started systematically diagnosing the operating system from the inside out.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎨 Step 1: The Canvas Deduction
&lt;/h2&gt;

&lt;p&gt;Gemini didn't guess. It queried the device's runtime settings via ADB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell settings get system pointer_location
adb shell settings get system show_touches
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both came back &lt;code&gt;0&lt;/code&gt;. Standard Android touch telemetry was definitively off.&lt;/p&gt;

&lt;p&gt;Then Gemini dumped the entire live UI hierarchy of the Settings app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell uiautomator dump /sdcard/window_dump.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It grepped the XML tree for &lt;code&gt;isOverScrolling&lt;/code&gt;. The result? &lt;strong&gt;Empty.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That silence told Gemini everything:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"This text does not exist as a TextView or a system overlay window. It is being painted directly onto the hardware Canvas buffer during draw passes by an internal UI component."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because the text appeared during scrolling in OnePlus system menus, Gemini formed an immediate hypothesis: the code belonged to OnePlus/OPPO’s proprietary UI toolkit—&lt;strong&gt;COUI&lt;/strong&gt; (ColorOS UI).&lt;/p&gt;




&lt;h2&gt;
  
  
  🔬 Step 2: Disassembling the Phone on the Fly
&lt;/h2&gt;

&lt;p&gt;Because these OEM classes are completely proprietary and unreleased, Gemini couldn't look up documentation. It had to read the machine code directly from the phone.&lt;/p&gt;

&lt;p&gt;To inspect the COUI framework without needing root access, Gemini pulled a built-in pre-installed app that uses the same UI components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb pull /product/app/Calculator2/Calculator2.apk ./calc.apk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, right inside my terminal, Gemini wrote and executed Python scripts to parse the raw binary DEX (Dalvik Executable) structures of the APK.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Hunting the String Table
&lt;/h3&gt;

&lt;p&gt;Gemini parsed the DEX string pool inside &lt;code&gt;calc.apk&lt;/code&gt; and found the exact IDs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String &lt;code&gt;#2600&lt;/code&gt; = &lt;code&gt;'AbortVX:'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;String &lt;code&gt;#37919&lt;/code&gt; = &lt;code&gt;'isOverScrolling: '&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Pinpointing the Method
&lt;/h3&gt;

&lt;p&gt;It mapped those string IDs across every class definition in the binary. In seconds, Gemini had the exact location:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Class:&lt;/strong&gt; &lt;code&gt;androidx.recyclerview.widget.COUIRecyclerView&lt;/code&gt; (OnePlus’s internal extension of the Jetpack RecyclerView)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Method:&lt;/strong&gt; &lt;code&gt;dispatchDraw(Canvas canvas)&lt;/code&gt; at bytecode offset &lt;code&gt;0x1fbea0&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Reading the Dalvik Bytecode
&lt;/h3&gt;

&lt;p&gt;Gemini disassembled the opcodes at that offset. The bytecode showed exactly what was going on under the hood:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0x1fbea0: invoke-virtual View-&amp;gt;dispatchDraw
0x1fbea6: sget COUIRecyclerView-&amp;gt;COUI_DEBUG:Z   // Check static boolean flag
0x1fbeaa: if-eqz -&amp;gt; 0x1fc03c                   // If false, skip entirely!
0x1fbeae: iget COUIRecyclerView-&amp;gt;mDebugPaint   // Get Paint object
0x1fbec4: invoke-virtual Paint-&amp;gt;setColor       // Set paint color to RED
0x1fbed4: const-string 'isOverScrolling: '     // Format velocity strings
0x1fbf2a: const-string 'X: FlingVX: '
0x1fbf86: const-string 'Y: FlingVY: '
0x1fbfe4: const-string 'AbortVX:'
0x1fc036: invoke-virtual Canvas-&amp;gt;drawText      // Draw directly on screen!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There it was: an undocumented, internal scroll-physics debugger built by OEM engineers to measure fling velocities during ROM development.&lt;/p&gt;




&lt;h2&gt;
  
  
  💥 Step 3: The Domino Effect — Finding Patient Zero
&lt;/h2&gt;

&lt;p&gt;Gemini now knew &lt;em&gt;what&lt;/em&gt; was painting the screen, but why had &lt;code&gt;COUI_DEBUG&lt;/code&gt; suddenly turned &lt;code&gt;true&lt;/code&gt; across my entire phone?&lt;/p&gt;

&lt;p&gt;Gemini inspected the class initializer &lt;code&gt;&amp;lt;clinit&amp;gt;&lt;/code&gt; of &lt;code&gt;COUIRecyclerView&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0x1fb9bc: const-string 'COUIRecyclerView'
0x1fb9c2: invoke-static COUILog-&amp;gt;isLoggable("COUIRecyclerView", Log.DEBUG)
0x1fb9d6: sput COUIRecyclerView-&amp;gt;COUI_DEBUG:Z
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;COUILog.isLoggable()&lt;/code&gt; simply calls Android's built-in &lt;code&gt;android.util.Log.isLoggable(tag, level)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In Android, &lt;code&gt;Log.isLoggable()&lt;/code&gt; first checks for a tag-specific system property (&lt;code&gt;log.tag.&amp;lt;TAG&amp;gt;&lt;/code&gt;). If that doesn't exist, it checks the global fallback property:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  🎯 The Culprit: &lt;code&gt;persist.log.tag&lt;/code&gt;
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Gemini queried the phone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell getprop persist.log.tag
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The terminal printed one character:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;V
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connecting the Dots
&lt;/h3&gt;

&lt;p&gt;Hours earlier, while debugging an audio service over ADB, a command had set &lt;code&gt;persist.log.tag&lt;/code&gt; to &lt;code&gt;V&lt;/code&gt; (Verbose) to inspect background audio logs. &lt;/p&gt;

&lt;p&gt;That one command triggered an unexpected chain reaction:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Why it survived reboots:&lt;/strong&gt; Properties starting with &lt;code&gt;persist.&lt;/code&gt; are saved directly to flash storage (&lt;code&gt;/data/property&lt;/code&gt;). A reboot does not wipe them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why the red text appeared:&lt;/strong&gt; Every time any app initialized a scrollable list, &lt;code&gt;COUIRecyclerView&lt;/code&gt; checked if debug logging was enabled. Because &lt;code&gt;persist.log.tag&lt;/code&gt; was set globally to &lt;code&gt;V&lt;/code&gt;, Android replied that everything was in verbose mode. &lt;code&gt;COUI_DEBUG&lt;/code&gt; became &lt;code&gt;true&lt;/code&gt;, and the red velocity overlay activated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why the edges were lagging:&lt;/strong&gt; With global verbose logging enabled across the entire OS, every single touch event, swipe coordinate, and edge gesture flooded the system log daemon with hundreds of log lines per second. The CPU was overwhelmed with logging I/O, dropping frames and causing noticeable edge touch lag.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  ⚡ The Cure: Total Relief in Five Seconds
&lt;/h2&gt;

&lt;p&gt;Once Gemini identified the exact root cause, the fix was quick and clean:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Resetting the Global Flag
&lt;/h3&gt;

&lt;p&gt;Gemini reset the dangerous persistent global log property to empty:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell setprop persist.log.tag &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Preventing It from Happening Again
&lt;/h3&gt;

&lt;p&gt;To make sure &lt;code&gt;COUIRecyclerView&lt;/code&gt; could never wake up its debug drawing again—even if global verbose logging were accidentally enabled in a future project—Gemini injected a permanent tag-level suppression rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell setprop persist.log.tag.COUIRecyclerView SUPPRESS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Killing the Active Process for Instant Testing
&lt;/h3&gt;

&lt;p&gt;Gemini killed the Settings process to immediately test the fix on the current window:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb shell am force-stop com.android.settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gemini triggered an automated swipe gesture through ADB, captured a live screenshot, and verified that the red text had vanished from Settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. The Final Device Reboot: Flushing In-Memory State
&lt;/h3&gt;

&lt;p&gt;While Settings was fixed immediately, Gemini pointed out a crucial Android runtime mechanic:&lt;/p&gt;

&lt;p&gt;In the Dalvik/ART virtual machine, static initializers (&lt;code&gt;&amp;lt;clinit&amp;gt;&lt;/code&gt;) run &lt;strong&gt;only once&lt;/strong&gt; when a class is first loaded into a process. That meant any app or system service already running in RAM (like the Launcher, SystemUI, or Contacts) still held &lt;code&gt;COUI_DEBUG = true&lt;/code&gt; cached in memory.&lt;/p&gt;

&lt;p&gt;To guarantee that every background process, system daemon, and service reloaded cleanly from scratch with the new suppressed properties, we performed a fresh device reboot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;adb reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the phone rebooted, I picked it up, unlocked it, and scrolled through every corner of the system:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The red text was 100% gone across all apps.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The edges were instantly responsive.&lt;/strong&gt; Edge gestures, the Smart Sidebar, and the silky 120Hz display were completely restored.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zero personal data touched, zero system partitions modified.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;All temporary extraction scripts were cleanly wiped from both the phone and PC.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎓 Final Thoughts: An Engineering Student Left Speechless
&lt;/h2&gt;

&lt;p&gt;As a Computer &amp;amp; Systems Engineering student, I usually take AI hype with a grain of salt. I understand how systems work under the hood, and I know how complex and messy OEM Android frameworks get when low-level state gets corrupted.&lt;/p&gt;

&lt;p&gt;If I had posted this on a forum or asked a standard chatbot, the advice would have been the same generic response: back up your data and factory reset.&lt;/p&gt;

&lt;p&gt;Watching Gemini handle this live in my terminal was genuinely impressive. It didn't guess, and it didn't give generic tips. It followed a solid systems debugging process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It systematically eliminated UI layers until only hardware Canvas rendering was left.&lt;/li&gt;
&lt;li&gt;It pulled compiled OEM packages directly from the phone without needing root access.&lt;/li&gt;
&lt;li&gt;It wrote Python scripts on the spot to parse binary DEX string pools and find the right class offsets.&lt;/li&gt;
&lt;li&gt;It analyzed the raw Dalvik bytecode and isolated the exact &lt;code&gt;sget&lt;/code&gt; instruction controlling the overlay.&lt;/li&gt;
&lt;li&gt;It traced an undocumented UI flag back to a persistent Linux system property that had survived reboots.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Watching an AI autonomously reverse-engineer compiled bytecode on a live device—and solve an undocumented framework issue in minutes without touching a single byte of my personal data—was amazing to see.&lt;/p&gt;

&lt;p&gt;This isn't just about autocompleting syntax or generating boilerplate code anymore. This is a real glimpse into the future of systems engineering—and as an engineering student, it completely blew me away.&lt;/p&gt;

</description>
      <category>android</category>
      <category>gemini</category>
      <category>googleai</category>
      <category>debugging</category>
    </item>
    <item>
      <title>The Ghost in the View Transitions API: A Bizarre Debugging Saga with Google AI 👻</title>
      <dc:creator>Omar Afifi</dc:creator>
      <pubDate>Fri, 07 Aug 2026 17:35:35 +0000</pubDate>
      <link>https://dev.to/omarafifi/the-ghost-in-the-view-transitions-api-a-bizarre-debugging-saga-with-google-ai-5aph</link>
      <guid>https://dev.to/omarafifi/the-ghost-in-the-view-transitions-api-a-bizarre-debugging-saga-with-google-ai-5aph</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/bugsmash"&gt;DEV's Summer Bug Smash: Clear the Lineup&lt;/a&gt; powered by &lt;a href="https://sentry.io/" rel="noopener noreferrer"&gt;Sentry&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎨 Project Overview
&lt;/h2&gt;

&lt;p&gt;While working on a major upgrade for my personal portfolio (Check it out here: &lt;a href="https://omar-afifi.com/" rel="noopener noreferrer"&gt;Live Portfolio Link&lt;/a&gt; | &lt;a href="https://github.com/omarafifi-cse/omarafifi-cse.github.io" rel="noopener noreferrer"&gt;GitHub Repo&lt;/a&gt;), I built a feature called the &lt;strong&gt;Theme Showcase&lt;/strong&gt;. When a user first loads the homepage, a slick &lt;code&gt;View Transitions API&lt;/code&gt; animation sweeps across the screen, temporarily switching the site to one of my custom showcase themes (like "Obsidian" or "Midnight"), before gracefully sweeping back to their chosen default theme. It was a 1.7-second "Wow Effect" designed to show off the site's dynamic color system.&lt;/p&gt;

&lt;h2&gt;
  
  
  🐛 Bug Fix
&lt;/h2&gt;

&lt;p&gt;Soon after deploying, I noticed a terrifying, chaotic bug. Sometimes, I would open the website and quickly switch to another tab to check an email, or minimize the browser window completely. When I switched back... &lt;/p&gt;

&lt;p&gt;Instead of my beautiful default theme, the website was permanently stuck on one of the other showcase themes! The animation had frozen mid-way, leaving the site in an awkward intermediate state. While the website was still fully functional and I could manually fix it by selecting my original theme from the dropdown menu, it was a terrible first impression for a professional portfolio. It was as if a ghost had possessed the CSS.&lt;/p&gt;

&lt;p&gt;My first instinct? Smash the refresh button. Refreshing would actually fix the glitch and play the animation perfectly—but &lt;em&gt;only&lt;/em&gt; if I stayed patiently on the tab and watched it finish! If I refreshed and immediately switched tabs again, the ghost would return.&lt;/p&gt;

&lt;h2&gt;
  
  
  💻 Code
&lt;/h2&gt;

&lt;p&gt;Here is the exact code change we made to exorcise the ghost. &lt;em&gt;(You can view the full fix in this &lt;a href="https://github.com/OmarAfifi-CSE/omarafifi-cse.github.io/commit/e5563dd648562f10317cd382b7876efad9285517" rel="noopener noreferrer"&gt;GitHub Commit&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Buggy Code (Before):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startViewTransition&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// If the browser aborts the transition here, the Promise rejects and execution halts forever!&lt;/span&gt;
&lt;span class="nx"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onfinish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Bulletproof Code (After):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isCancelled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Gracefully handle tab switching&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleVisibility&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;isCancelled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;originalTheme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Instantly restore&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibilitychange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleVisibility&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibilitychange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleVisibility&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Bulletproof the View Transition Promise&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startViewTransition&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isCancelled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="nx"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isCancelled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onfinish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;oncancel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// THE MAGIC FIX: If the browser aborts the transition (background tab), resolve immediately!&lt;/span&gt;
      &lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Fallback if startViewTransition throws synchronously&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isCancelled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🛠️ My Improvements
&lt;/h2&gt;

&lt;p&gt;My technical approach to resolving this was two-fold:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State Management on Visibility Change:&lt;/strong&gt; I added a &lt;code&gt;visibilitychange&lt;/code&gt; event listener. If the user navigates away, we instantly cancel the sequence and forcefully restore the original theme to prevent intermediate states.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling for the View Transitions API:&lt;/strong&gt; The core issue was that browsers forcefully abort the &lt;code&gt;startViewTransition&lt;/code&gt; when a tab is hidden to save battery. This caused the &lt;code&gt;transition.ready&lt;/code&gt; Promise to reject. Because there was no &lt;code&gt;.catch()&lt;/code&gt; block, the unhandled rejection caused the entire async sequence to hang permanently. By wrapping the transition in a &lt;code&gt;try/catch&lt;/code&gt; and adding a &lt;code&gt;.catch(() =&amp;gt; resolve())&lt;/code&gt; handler, we guarantee that the execution flow always continues gracefully, even if the browser interrupts it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  🤖 Best Use of Google AI
&lt;/h2&gt;

&lt;p&gt;I couldn't figure out why this bug was only happening &lt;em&gt;sometimes&lt;/em&gt;, and no errors were showing up in the console. So, I turned to my trusty pair programmer: &lt;strong&gt;Google AI integrated within the Antigravity IDE&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;What's really cool about my workflow is that I chat with my AI agent completely casually in Arabic. It feels incredibly natural, like brainstorming with a senior engineer sitting right next to me. But debugging with AI isn't always a "one-shot" magic trick. It’s an iterative journey. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Note: I interact with my AI agent natively in Arabic! For this post, I have translated our debugging conversation. I've kept the original Arabic screenshots on hand just in case the judges want to see them!)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1: The Misdiagnosis
&lt;/h3&gt;

&lt;p&gt;At first, I explained the symptoms loosely to the AI: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; &lt;em&gt;"I have another issue. Sometimes the theme changes to dark suddenly and weird things happen. I don't know what it is."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI analyzed the code and thought the &lt;em&gt;animation feature itself&lt;/em&gt; was the bug (assuming it was just annoying the user). So, it enthusiastically offered a "fix" by completely disabling the showcase animation function! &lt;/p&gt;

&lt;p&gt;I had to intervene and correct its assumption: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; &lt;em&gt;"Bro, no, you misunderstood! The animation at the beginning is natural and fine. What's NOT natural is leaving the website open, going to another tab, and coming back to find it permanently stuck on a new theme."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Phase 2: The Deep Dive
&lt;/h3&gt;

&lt;p&gt;Once I steered the AI in the right direction, it immediately dug into the mechanics of tab-switching. It realized that modern browsers aggressively pause &lt;code&gt;requestAnimationFrame&lt;/code&gt; when a tab goes to the background. &lt;/p&gt;

&lt;p&gt;The AI wrote the &lt;code&gt;visibilitychange&lt;/code&gt; listener, but then we ran into another issue when I was testing it locally with my dev server.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; &lt;em&gt;"Why does it open on a different theme every time I hit save in my editor? I have to manually refresh to get my original theme back."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The AI assumed I was just being impatient with the 1.7-second animation delay during live-reloads:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI:&lt;/strong&gt; &lt;em&gt;"When you save, the dev server refreshes the page. The animation starts, switches to the showcase theme, and then returns. You are just manually refreshing before the 1.7 seconds finish, trapping yourself in a loop! Just wait 1.7 seconds."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Phase 3: The "Aha!" Moment
&lt;/h3&gt;

&lt;p&gt;I knew I wasn't just being impatient. The UI was &lt;em&gt;literally getting stuck&lt;/em&gt;. I pushed the AI to look deeper: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; &lt;em&gt;"Bro, I'm not rushing. I open it, find it on a new theme, and it is completely STUCK on it. This causes problems if the user goes to another tab. Focus well, think carefully, and take your time."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s when the AI hit the absolute jackpot. &lt;/p&gt;

&lt;p&gt;It didn't just hand me a snippet of code; it provided a masterclass on browser mechanics. It analyzed the &lt;code&gt;View Transitions API&lt;/code&gt; behavior and uncovered the true root cause: to save battery and resources, modern browsers aggressively throttle or abort animations when a tab is hidden. This aggressive optimization was causing the &lt;code&gt;transition.ready&lt;/code&gt; promise to reject silently, which hung the entire async sequence because it lacked a &lt;code&gt;.catch()&lt;/code&gt; block.&lt;/p&gt;

&lt;p&gt;I initially asked the AI if we could just "force" the browser to play the animation in the background anyway. Instead of blindly agreeing, the AI pushed back and explained the engineering philosophy behind this: it’s a hard performance constraint built into modern browsers. You can't fight the browser's resource management. Instead, it taught me the "Best Practice": monitor the tab's state (which led to the &lt;code&gt;visibilitychange&lt;/code&gt; listener), gracefully catch any forced abortions (the &lt;code&gt;.catch()&lt;/code&gt; fix), instantly restore the original UI, and respect the browser's rules.&lt;/p&gt;

&lt;p&gt;Thanks to Google AI in the Antigravity IDE, I didn't just fix a bug—I learned exactly &lt;em&gt;why&lt;/em&gt; the browser was behaving that way under the hood. It transformed a frustrating debugging session into a profound learning experience about advanced JavaScript APIs and browser rendering mechanics. This is exactly what the future of pair programming looks like!&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>bugsmash</category>
      <category>webdev</category>
      <category>googleai</category>
    </item>
    <item>
      <title>Reviving Daphq: How I Built an Open-Source, Bare-Metal File Transfer Engine Solo with GitHub Copilot</title>
      <dc:creator>Omar Afifi</dc:creator>
      <pubDate>Wed, 27 May 2026 21:12:32 +0000</pubDate>
      <link>https://dev.to/omarafifi/reviving-daphq-how-i-built-an-open-source-bare-metal-file-transfer-engine-solo-with-github-copilot-5cd8</link>
      <guid>https://dev.to/omarafifi/reviving-daphq-how-i-built-an-open-source-bare-metal-file-transfer-engine-solo-with-github-copilot-5cd8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/github-2026-05-21"&gt;GitHub Finish-Up-A-Thon Challenge&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Daphq&lt;/strong&gt; is a robust, open-source, cross-platform file transfer application engineered entirely from scratch to deliver hardware-saturating speeds over local area networks (LAN), Wi-Fi, and Mobile Hotspots. &lt;/p&gt;

&lt;p&gt;As a solo developer, I built Daphq to solve a personal frustration: the bloated overhead, privacy concerns, and artificial speed limits of conventional HTTP-based or cloud-reliant file-sharing tools. Daphq bypasses the standard Web/REST layer completely, establishing direct, bare-metal &lt;strong&gt;TCP Sockets&lt;/strong&gt; (&lt;code&gt;Socket&lt;/code&gt; &amp;amp; &lt;code&gt;ServerSocket&lt;/code&gt;) with &lt;code&gt;SocketOption.tcpNoDelay&lt;/code&gt; enabled to eliminate protocol latency and push network hardware to its absolute physical limits.&lt;/p&gt;

&lt;p&gt;Built using &lt;strong&gt;Flutter (Dart)&lt;/strong&gt; for seamless cross-platform performance (currently native on Android and Windows), Daphq features a highly decoupled architecture using the &lt;strong&gt;BLoC/Cubit&lt;/strong&gt; pattern, multi-gigabyte memory protection guards, and background network synchronization, and intelligent user guidance. &lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The entire project is completely open-source and free to review, fork, or run locally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;Official Product Website:&lt;/strong&gt; &lt;a href="http://omar-afifi.com/daphq/" rel="noopener noreferrer"&gt;omar-afifi.com/daphq/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;💻 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/omarafifi-cse/daphq" rel="noopener noreferrer"&gt;github.com/omarafifi-cse/daphq&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Screenshots in Action
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Android UI Layout&lt;/th&gt;
&lt;th&gt;Windows Desktop Experience&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuhthhu31i9z3r5zp4c2v.png" alt="Android Interface" width="800" height="1666"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6s9qm7a2y59mo7hxic2o.png" alt="Windows Interface" width="799" height="510"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Clean, robust mobile layout with active background service tracking.&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;Fluid, modern, and highly responsive desktop experience.&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The Comeback Story
&lt;/h2&gt;

&lt;p&gt;Daphq was born under high pressure, but after shipping the bare bones of version &lt;strong&gt;v1.0.0&lt;/strong&gt;, it was essentially abandoned in my local repository directory. The project had immense raw speed potential, but it was plagued by architectural gaps, clunky user workflows, and high-stress bugs that made it unviable for everyday users. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;GitHub Finish-Up-A-Thon Challenge&lt;/strong&gt; was the exact catalyst I needed to dust off the codebase and transform it from a fragile command-like utility into a highly polished, resilient consumer application (&lt;code&gt;v2.3.0&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  The Deep Evolution: v1.0.0 vs. v2.3.0
&lt;/h3&gt;

&lt;p&gt;Here is exactly how the architecture and UX matured over the course of this challenge:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Discovery, Connectivity &amp;amp; Resilience:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Before (v1.0.0):&lt;/em&gt; Zero automation. Users manually typed cryptic IPv4 addresses, and any connection drop required a full app restart.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;After (v2.3.0):&lt;/em&gt; A custom &lt;strong&gt;UDP Auto-Discovery Service&lt;/strong&gt; with an integrated watchdog. Backed by a rewritten, &lt;strong&gt;Bulletproof Receiver Engine&lt;/strong&gt;, the app instantly bounces back if a connection drops or cancels abruptly—never getting stuck on "Connecting...".&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User Interface, Fluidity &amp;amp; Storage:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Before (v1.0.0):&lt;/em&gt; Rigid layouts, storage bloat from cached files, and main-thread hangs (UI freezing) when selecting large directories.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;After (v2.3.0):&lt;/em&gt; A unified dashboard anchored by an &lt;strong&gt;"Orbital Radar"&lt;/strong&gt; and Non-Blocking Async UI. Sharing 1,000+ files is now buttery smooth with zero lagging. Plus, it features &lt;strong&gt;Persistent Folders&lt;/strong&gt; to permanently remember your download path and &lt;strong&gt;Smart Auto-Cleaning&lt;/strong&gt; to wipe cache bloat automatically.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart User Guidance:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Before (v1.0.0):&lt;/em&gt; Users suffered from slow transfers due to ISP router bottlenecks without knowing why.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;After (v2.3.0):&lt;/em&gt; Integrated a real-time speed monitor that triggers a &lt;strong&gt;Smart Hotspot Guide&lt;/strong&gt; if speeds drop below 2.0 MB/s, guiding users to utilize 5GHz direct hotspots for up to 10x faster speeds.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Safety &amp;amp; Disk I/O Flow Control:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Before (v1.0.0):&lt;/em&gt; High risk of Out-Of-Memory (OOM) crashes when streaming multi-gigabyte files due to unthrottled asynchronous disk reads.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;After (v2.3.0):&lt;/em&gt; Implemented zero-copy byte slicing (&lt;code&gt;Uint8List.sublistView&lt;/code&gt;) and &lt;strong&gt;Natural Socket Backpressure&lt;/strong&gt; (&lt;code&gt;await socket.flush()&lt;/code&gt;). Daphq now self-throttles to match real-time network speeds, saving physical RAM.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deep System-Wide Integrations:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Before (v1.0.0):&lt;/em&gt; Isolated sandboxed app.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;After (v2.3.0):&lt;/em&gt; Deployed deep OS hooks, including native Android Share Menu entry and background execution. On Android, &lt;strong&gt;Instant Wake-up&lt;/strong&gt; intelligently turns on the screen for incoming requests. On Windows, the &lt;strong&gt;Context Menu Shell Extension&lt;/strong&gt; was completely rebuilt to be unbreakable, eliminating all File Explorer hangs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  My Experience with GitHub Copilot
&lt;/h2&gt;

&lt;p&gt;As a solo developer, you are the software architect, the UI designer, the QA technician, and the DevOps engineer all at once. Time is your greatest bottleneck. Throughout this sprint, GitHub Copilot didn’t just autocomplete lines of boilerplate—it acted as an incredibly knowledgeable senior engineering peer, unlocking complex architectural problems.&lt;/p&gt;

&lt;p&gt;Here are three distinct breakthroughs where GitHub Copilot completely changed the trajectory of the project:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Solving the Math of the Orbital Radar UI
&lt;/h3&gt;

&lt;p&gt;I wanted the home dashboard to feel alive with an evenly distributed, deterministic "Orbital Radar" circle showing available peer devices. Distributing dynamic widgets symmetrically on a circular plane without them overlapping can quickly become a headache.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copilot's Intervention:&lt;/strong&gt; By providing Copilot with my layout boundaries and device state arrays, it instantly mapped out the exact trigonometric distribution math using &lt;code&gt;cos&lt;/code&gt; and &lt;code&gt;sin&lt;/code&gt; over a mapped index. Furthermore, it proactively recommended assigning unique &lt;code&gt;ValueKey&lt;/code&gt;s to the dynamically generated widgets, preventing unnecessary re-paints and maximizing rendering performance on low-end hardware.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Eliminating the Windows FFI Mutex Deadlock
&lt;/h3&gt;

&lt;p&gt;A critical, highly frustrating platform bug on Windows caused Daphq to accidentally trigger background execution loops whenever a user performed completely unrelated right-click shell actions elsewhere in the OS. Worse, exiting the app caused a stubborn Dart VM deadlock.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copilot's Intervention:&lt;/strong&gt; I explained the process conflict to Copilot. It guided me through structuring a clean, platform-specific local session mutex check. When it came to bypassing the Dart VM shutdown hang, Copilot instantly generated the safe native Windows FFI code block to execute a clean &lt;code&gt;ExitProcess&lt;/code&gt; command, killing the deadlocks instantly and safely.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Engineering Flow-Safe Dynamic Streaming Buffer
&lt;/h3&gt;

&lt;p&gt;To stop aggressive disk-read bursts from triggering Out-Of-Memory exceptions, I needed a way to throttle file streams smoothly based on network capacity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copilot's Intervention:&lt;/strong&gt; Copilot analyzed my asynchronous data-sync loop and suggested transitioning away from arbitrary chunk delay timers. It helped refactor the code to explicitly await &lt;code&gt;socket.flush()&lt;/code&gt; based on monitored &lt;code&gt;bytesBuffered&lt;/code&gt; thresholds. The result was an automated backpressure loop that scales throughput up or down safely based on real-time network conditions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Standard path for larger files: stream in chunks&lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fileToRead&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;openRead&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_isCancelled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s"&gt;"Transfer Cancelled"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;bytesBuffered&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytesBuffered&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AppConstants&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;socketFlushThresholdBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Awaited flush: provides backpressure so the disk read loop&lt;/span&gt;
        &lt;span class="c1"&gt;// runs at network speed, not disk speed. Without this, a fast&lt;/span&gt;
        &lt;span class="c1"&gt;// UFS device would read the entire file in &amp;lt;500ms before any&lt;/span&gt;
        &lt;span class="c1"&gt;// onUpdate fires, causing the snapshot/stutter UI bug.&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;flush&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;bytesBuffered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_isCancelled&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s"&gt;"Transfer Cancelled"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;SocketException&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"reset by peer"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s"&gt;"Receiver disconnected during transfer."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;rethrow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// ... UI update logic &lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Verdict
&lt;/h2&gt;

&lt;p&gt;Building Daphq independently meant encountering dozens of architectural edge cases. Having GitHub Copilot available to instantly generate platform-specific guards, analyze multi-threaded socket behavior, and handle tedious Win32 registry bindings allowed me to focus on what mattered most: delivering a breathtakingly fast file transfer engine. &lt;/p&gt;

&lt;p&gt;Daphq went from an unpolished repository artifact to a production-grade open-source engine capable of hitting &lt;strong&gt;80-90 MB/s (~93% bandwidth saturation)&lt;/strong&gt; over a standard local Wi-Fi 5 connection. I couldn't be prouder of how this challenge ended.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>githubchallenge</category>
      <category>flutter</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
