DEV Community

Cover image for Touch Grass with Canopy: The Sovereign Offline-First AI Backcountry Guardian & 3D Topo Explorer
shruti rai
shruti rai

Posted on Originally published at github.com

Touch Grass with Canopy: The Sovereign Offline-First AI Backcountry Guardian & 3D Topo Explorer

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

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


What I Built

Modern outdoor technology suffers from a deep irony: apps designed to help us explore nature often end up trapping us on our screens. Hikers find themselves craning their necks down at battery-hungry maps, refreshing disconnected cloud services, and obsessing over GPS dots instead of immersing themselves in the wilderness. Worse, when hikers venture into remote backcountry areas where cellular signal drops to zero, proprietary cloud apps freeze completely.

Canopy (Touch Grass / Backcountry Guardian) is an open-source, 100% sovereign, offline-first backcountry AI companion engineered to help hikers, mountaineers, and nature enthusiasts safely disconnect from digital distractions and "Touch Grass".

Canopy 3D Terrain & Live Dashboard

Engineered to Get You Off the Screen

Canopy is intentionally built to minimize screen time rather than maximize digital engagement:

  • Pocket Mode & Audio Whispers: Slide your phone into your jacket or backpack. Canopy runs background environmental monitoring and speaks subtle spatial audio chimes only when safety-critical events occur (e.g., approaching a turnaround deadline or sudden barometric drops).
  • Minimalist OLED Field Mode: In bright alpine sunlight or extreme battery-saving states, Canopy switches to a pure-black, high-contrast OLED interface displaying only essential telemetry: altitude, pressure delta, temperature, and hard turnaround countdowns.
  • Screen vs. Outdoor Ratio: Actively measures your trail time versus screen-on time, encouraging a 150Ă— ratio of being present in nature.

Minimalist OLED Field Mode

Key Wilderness Capabilities

  1. Interactive 3D Digital Twin Himalayan Topography (WebGL/Three.js): Procedural 3D alpine terrains for legendary routes (Hampta Pass, Kedarnath Summit Ridge, Triund, Chandrashila Peak) with real-time raycasted elevation inspectors, slope hazard gradients, snowpack coverage, and waypoint flythroughs.
  2. On-Device Spectral Bioacoustics: Real-time Web Audio FFT spectrogram analyzing high-altitude avian calls (Alpine Chough, Himalayan Monal, Snow Partridge, Hermit Thrush) with zero cloud roundtrips.
  3. Microclimate Physics Engine: Local barometric lapse rate and radiative frost prediction modeling temperature drop per 1,000 m of ascent without requiring internet weather forecasts.
  4. Physical Sensor Bridge (Web Serial API): Connects directly over USB/Bluetooth to hardware microcontrollers (such as Arduino UNO Q with BME280) for real-time barometric and temperature ingestion.
  5. Deterministic Safety Engine: A strict guardrail layer that prevents dangerous AI hallucinations—enforcing non-negotiable turnaround curfews, hypothermia warnings, and strictly refusing prescription drug recommendations.

3D Himalayan Topographic Digital Twin


Demo

Safety Advisor Guidance


Code

🌿 Canopy — Backcountry Guardian

Offline-First Open-Weight AI Backcountry Safety & Terrain Intelligence System

Built for the Touch Grass Open-Source AI Challenge

"Build something with open-source/open-weight AI at its core that gets people off the screen and into the world."

Open-Weight AI Inference Runtime Deterministic Safety License: Apache 2.0 / MIT Challenge Alignment


🏔️ 1. Project Overview & Philosophy

Outdoor safety cannot depend on cellular signal or cloud APIs. The moment an alpine trekker crosses 3,500 meters or enters an exposed couloir, cloud connectivity drops to zero. If safety intelligence lives exclusively on remote servers, it fails precisely when human lives depend on it most.

Canopy (Backcountry Guardian) is an offline-first backcountry safety, microclimate, and terrain intelligence system built with open-weight AI at its core.

The Touch Grass Architecture

Canopy is architected to get users off screens and into the natural world:

REAL-WORLD SENSORS & ENVIRONMENT
             ↓
CANOPY TELEMETRY CONTEXT ENGINE
             ↓
OPEN-WEIGHT LOCAL AI (SmolLM2 / Gemma 2) + NEURAL FALLBACK
…

The complete project is open source under the MIT License. It contains zero cloud AI API keys, zero remote tracking scripts, and zero paid subscription gates.

# Clone and launch in 3 steps
git clone https://github.com/shrutirai29/hacktober.git
cd hacktober/t2
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

How I Built It

The 3-Tier Sovereign AI Fallback Pipeline

In deep mountain valleys, cellular data does not exist. Canopy solves this with a strictly local, 3-tier sovereign AI architecture:

User Query + Trail Telemetry
           ↓
[Tier 1: WebGPU WebLLM (SmolLM2-135M / Qwen2.5-0.5B)]
     ├─► Success: Instant client-side inference (100% on-device)
     └─► Failure/No WebGPU:
           ↓
     [Tier 2: Localhost Daemon (Ollama / Gemma 2 / Qwen)]
          ├─► Success: Local rugged field tablet / basecamp laptop
          └─► Failure/Unavailable:
                ↓
          [Tier 3: Micro-MLP & Deterministic Safety Engine]
               └─► Guarantees offline, non-crashing safety advice
Enter fullscreen mode Exit fullscreen mode
  1. Tier 1 — In-Browser WebGPU WebLLM (@mlc-ai/web-llm): Runs lightweight open-weight models (SmolLM2-135M-Instruct or Qwen2.5-0.5B-Instruct) compiled to WebAssembly and executed on the client's GPU via WebGPU. Model weights are cached locally in browser CacheStorage.
  2. Tier 2 — Localhost Daemon (Ollama): Connects via local HTTP loopback (http://localhost:11434) to execute open-weight models like gemma2:2b or qwen2.5:0.5b for field workstations.
  3. Tier 3 — Deterministic Safety Engine & Micro-MLP: A browser-native fallback that parses telemetry matrices and delivers instantaneous rule-based safety directives even on low-power devices without WebGPU.

Physical Sensor Telemetry Bridge

Safety-First: The Deterministic Guardrail Layer

LLMs are creative, but backcountry safety requires deterministic boundaries. Canopy implements an uncompromised safety layer:

  • Curfew Enforcer: If the clock passes the turnaround time (e.g., 1:30 PM on Hampta Pass), any model output encouraging further ascent is intercepted and overridden with a mandatory TURN BACK IMMEDIATELY directive.
  • Medical Sanitization Protocol: Strictly strips and blocks prescription drug dosages (e.g., Diamox/Acetazolamide milligrams) and forces conservative hydration, rest, and immediate descent protocols.
  • Telemetry Fabrication Rejection: If requested to evaluate an unmonitored metric or non-existent sensor, the system refuses to hallucinate data.

Rigorous Red-Team & Unit Verification

Every capability claimed is backed by automated tests:

  • 16 Unit Regression Tests (npm test): Validates the WebLLM self-test contract (CANOPY_WEBLLM_OK), adversarial prompt injection neutralization, medical sanitization, and audio FFT edge cases.
  • 15 Red-Team Audit Tests (npm run test:audit): Validates the 3-tier fallback chain, 0 cloud API key leak audit across all source files, Vite dev server startup, and extreme environmental inputs (-50°C to +50°C, 0 m to 10,000 m).

Developer Diagnostics Suite


Why Does Open Innovation Matter?

Open innovation is not just an ideological preference for Canopy—it is the only architecture that makes wilderness survival AI possible.

  1. Closed Cloud APIs Fail in the Wild: If an AI assistant requires an internet connection to reach a cloud server, it is completely useless the second you step off the trailhead. Open-weight models (SmolLM, Gemma, Qwen) allow weights to live directly on personal devices, providing true computational sovereignty.
  2. Safety Must Be Inspectable: When software provides advice on alpine hypothermia, avalanche hazards, or mountain sickness, proprietary black-box APIs are unacceptable. Open-source development enables open-weight inspection, deterministic guardrail wrapping, and transparent peer auditing.
  3. Privacy and Zero Telemetry Tracking: The outdoors is where people go for tranquility and privacy. Canopy uses open-source software to ensure that no biometric data, GPS coordinates, or voice audio ever leave your local machine.

My Agent Session

During development, the entire iterative engineering loop—implementing the WebGPU WebLLM provider, Three.js Himalayan topographic math, deterministic red-team suites, and automated validation tests—was completed with pair-programming assistance. Full audit logs and automated test reports are open and verifiable in the repository under /scripts.


Prize Categories

  • Main Challenge: Open-Source AI Challenge Week 1: Touch Grass
  • Best Use of Open-Weight Models: SmolLM2 / Gemma 2 via WebGPU and local Ollama inference
  • Edge & On-Device AI: 100% in-browser WebGPU WebLLM execution with zero network dependency
  • Responsible & Safe AI: Open-weight LLMs wrapped in deterministic safety and medical guardrails

Top comments (0)