DEV Community

Yug Patel
Yug Patel

Posted on

BioTrail AI: The Privacy-First Offline Field Botanist

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

published: true
tags: hacktoberfest, ai, opensource, python, webdev
cover_image: https://images.unsplash.com/photo-1511497584788-87676104235f?auto=format&fit=crop&w=1200&q=80
canonical_url:

description: "BioTrail AI is an offline, open-source AI assistant that helps developers step away from screens, complete sensory nature quests, and identify biodiversity without cell service."

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


🌿 The Inspiration: What if AI pushed us away from screens?

As developers, we spend hours staring at monitors, reviewing pull requests, and debugging stacks. "Touch grass" started as an internet meme, but behind the joke lies a genuine need: human beings need regular sensory immersion in the real, physical world to stay healthy and creative.

However, existing nature apps come with two major flaws:

  1. Cloud Lock-in & Cellular Blackouts: When you actually hike into a deep forest ravine or mountain trail, cell signal drops to zero. Cloud-based proprietary AI APIs fail completely.
  2. Privacy & Telemetry: Why should a hiker's exact GPS location, photos of secluded local foraging spots, and personal audio reflections be shipped to advertising-funded big tech servers?

I built BioTrail AI to flip the script: an open-source, local-first field assistant powered by open-weight AI that works entirely offline.


πŸš€ What I Built

BioTrail AI is an open-source companion designed for wild trails and neighborhood parks:

  1. πŸ“· Botanical & Ecological Vision Identification: Point your camera at any wild plant, leaf, mushroom, or bark texture. The local vision pipeline identifies the specimen, classifies its taxonomic family, explains its ecological role, and shares naturalist fun facts.
  2. πŸŽ™οΈ Screenless Audio Nature Journal: Walk with your phone tucked away. Using voice dictation and natural language extraction, the app listens to your spoken reflections and automatically tags sensory landmarks (such as #avifauna, #weather, #flora, #mindfulness).
  3. 🧭 Procedural "Touch Grass" Quests: Rather than passive scrolling, an open-source quest agent serves micro-adventures (e.g., "Locate an angiosperm with serrated leaf margins", "Perform a 10-minute acoustic forest bath", "Inspect an urban pollinator patch").
  4. πŸ† Offline XP & Badges: Gamifies real-world outdoor time. The app tracks your total outdoor minutes, logs species into a personal offline herbarium, and awards badges like Grass Toucher, Trail Pioneer, and Master Botanist.
  5. πŸ“ Markdown Field Guide Export: Generates clean, formatted Markdown logs of your biodiversity expeditions.

🧠 Why Open-Source AI was Integral to This Project

The Hacktoberfest challenge specifically asks why an open-source AI approach was essential. For BioTrail AI, open-source AI was not merely an optionβ€”it was the only viable architecture:

1. Zero-Cellular Resilience on Wilderness Trails

Nature doesn't have 5G towers. When you are deep inside an old-growth forest or national park, calling proprietary cloud APIs like OpenAI or Anthropic is impossible. Open-weight models (running locally via Ollama with quantized weights or through edge rule fallbacks) execute 100% on the device without an internet connection.

2. Radical Location Privacy

Outdoor exploration often involves sharing coordinates, foraging sites, and personal spoken reflections. By keeping all inference local and persisting observations in a private SQLite database (biotrail.db), user data never leaves their hardware.

3. Open Innovation & No Per-Query Toll Booths

Encouraging millions of young explorers and students to explore biology shouldn't incur API bills or rate limits. Open weights mean students and schools can run educational field tools at zero ongoing marginal cost.


πŸ› οΈ Tech Stack & Architecture

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚             Responsive Web Interface                    β”‚
   β”‚  (Tailwind CSS, Phosphor Icons, Web Speech Audio API)   β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚ JSON API
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                 FastAPI Python Server                   β”‚
   β”‚        (Async REST endpoints, Local SQLite DB)          β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚                         β”‚
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚    Open-Source AI Engine     β”‚  β”‚   Offline Herbarium   β”‚
   β”‚ β”œβ”€ Ollama (llama3.2-vision)  β”‚  β”‚   (Local SQLite DB    β”‚
   β”‚ └─ Edge Taxonomy Knowledge   β”‚  β”‚    biotrail.db)       β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode
  • Backend: FastAPI, Python 3.12, Uvicorn, Pydantic, HTTPX
  • AI Models: Ollama Open-Weights (llama3.2-vision, llama3.2) with deterministic edge fallback
  • Frontend: Vanilla JS, Tailwind CSS, Web Speech Recognition API
  • Persistence: Local SQLite database with zero cloud synchronization

πŸ’» Code Spotlight: The Dual-Path Local Inference Engine

BioTrail AI seamlessly probes for a running Ollama daemon. If available, it invokes open-weight multimodal models (llama3.2-vision). If running on a lightweight laptop on a trail without a dedicated GPU, it gracefully delegates to the local edge taxonomy bank:

async def identify_flora_image(base64_img: str, user_notes: str = "") -> Dict[str, Any]:
    is_ollama_up = await check_ollama_available()

    if is_ollama_up:
        try:
            payload = {
                "model": "llama3.2-vision:latest",
                "prompt": "You are an expert field botanist AI. Identify this specimen and return JSON...",
                "images": [base64_img.split(",")[-1]],
                "stream": False,
                "format": "json"
            }
            async with httpx.AsyncClient(timeout=30.0) as client:
                res = await client.post("http://127.0.0.1:11434/api/generate", json=payload)
                if res.status_code == 200:
                    parsed = json.loads(res.json()["response"])
                    parsed["ai_engine"] = "Local Ollama (llama3.2-vision)"
                    return parsed
        except Exception:
            pass

    # Seamless Edge Fallback: zero dependencies, zero network required!
    return fallback_botanical_taxonomy(user_notes)
Enter fullscreen mode Exit fullscreen mode

πŸƒ Running It Yourself

Prerequisites

  • Python 3.10+
  • (Optional) Ollama with llama3.2-vision installed

Quick Setup

# 1. Clone repository
git clone https://github.com/your-username/biotrail-ai.git
cd biotrail-ai

# 2. Install Python packages
cd backend
pip install -r requirements.txt

# 3. Start the server
python main.py
Enter fullscreen mode Exit fullscreen mode

Now open http://localhost:8000 in your browser, strap on your walking shoes, and step outside!


πŸ—ΊοΈ What's Next for BioTrail AI

  • [ ] Native PWA packaging with local WebAssembly Whisper model for offline speech recognition.
  • [ ] Direct GPX route map rendering with heatmaps of high-biodiversity microclimates.
  • [ ] Community mesh sync (peer-to-peer Wi-Fi Direct or Bluetooth sync between hikers on the same trail).

πŸ“¦ Source Code & Repository

Thank you to DEV and the Hacktoberfest organizers for this challenge! Let's close our laptops, breathe some fresh air, and touch grass! 🌱

Top comments (0)