PlantGuard

PlantGuard AI 🌿

An offline-first plant & leaf health journal with secure Google Gemini AI analysis. Photograph a leaf, get high-accuracy plant health assessments powered by Google Gemini API via a lightweight Node.js Express backend, review cautious observations with actionable care guidance, and manage your daily plant-care streak β€” with full offline journal capabilities when away from signal.

Features

Getting started

1. Configure Backend (.env)

cd server
cp .env.example .env
# Edit server/.env and provide your GEMINI_API_KEY from Google AI Studio
# Default model: gemini-3.8-flash (or gemini-2.0-flash)
npm install
npm run dev      # Starts Express backend on http://localhost:3001

2. Configure & Start Frontend

In a separate terminal from project root:

npm install
cp .env.example .env    # Optional (defaults connect to http://localhost:3001/api)
npm run dev             # Starts Vite frontend on http://localhost:5173

Open http://localhost:5173, complete onboarding, and start journaling or scanning leaves!

The service worker is only active in production builds. To test PWA/offline behaviour: npm run build && npm run preview β†’ http://localhost:4173

Scripts

Command Purpose
npm run dev Development Vite frontend server (http://localhost:5173)
npm run build Type-check + production build into dist/
npm run preview Serve the production build locally
npm run lint / npm run typecheck ESLint / TypeScript checking for frontend
npm test Unit + component tests (Vitest)
npm run check Run full lint + typecheck + test + build pipeline
npm run server:dev Start Express backend in watch mode (http://localhost:3001)
npm run server:build Compile Express backend TypeScript to server/dist/
npm run server:start Run compiled Express backend in production mode
npm run server:typecheck Type-check server code (tsc --noEmit)
npm run server:test Run server unit & API route tests (Vitest)
npm run test:e2e Playwright E2E tests
npm run icons Regenerate PWA icons

Details: docs/TESTING.md.

Configuration

The AI Architecture

Read docs/AI_MODEL.md and docs/AI_PROMPTS.md.

Installing the app

Offline behaviour

Works offline after the first visit: every screen, your data, care tracking, export/import, and AI analysis if the model download finished. Needs internet: first visit, model download, map tiles, app updates. Browsers can evict storage under pressure; the app re-checks and tells you. See docs/OFFLINE_PWA.md.

Maps

OpenStreetMap tiles by default (attribution always shown; subject to the OSMF tile usage policy). Location is only requested when you press a location button. No offline basemap. See docs/MAPS_AND_GEOLOCATION.md.

Deployment

Static hosting β€” Cloudflare Pages recommended (build npm run build, output dist); GitHub Pages supported with VITE_BASE_PATH. See docs/DEPLOYMENT.md.

Documentation

docs/README.md indexes everything: requirements, architecture (with diagram), AI model and prompts, database schema, offline/PWA, maps, environment, security & privacy, UI/UX, testing, deployment, troubleshooting, roadmap and ADRs.

Licence

MIT (see LICENSE); third-party models, components and fixtures keep their own licences.

Final verification and production hosting

See docs/IMPLEMENTATION_REPORT.md for measured results and incomplete requirements. The shared data model is documented in ASSESSMENT_SCHEMA.md and DATABASE_SCHEMA.md. Plant timelines retain assessment history and compare deterministic symptom sets.

Netlify is supported: root netlify.toml builds with npm run build and publishes dist with an SPA rewrite. All environment values are optional public build-time settings, listed in .env.example. No secrets or AI keys are needed. Production guide includes every supported variable, Netlify steps, Cloudflare Pages fallback and post-deploy checks.