AI Garden Buddy
Less scrolling. More growing.
AI Garden Buddy is a local-first gardening assistant that uses AI to help people start gardening. It recommends suitable plants, generates a personalized seven-day gardening plan, and suggests one small outdoor task to complete each day.
Built for the Hacktoberfest Open-Source AI Challenge — Week 1: Touch Grass.
Live Demo
Live Application: https://hacktoberfest-tawny.vercel.app/
GitHub Repository: https://github.com/yogesh968/hacktoberfest
Note: AI plan generation requires the FastAPI backend and Ollama. The deployed frontend needs a reachable backend to generate plans for online users.
Features
- Personalized Plant Recommendations: Suggests plants based on city, garden type, sunlight, and gardening experience.
- Seven-Day Gardening Plan: Generates a practical daily schedule based on available time.
- Daily Outdoor Tasks: Provides actionable gardening activities with instructions and estimated completion times.
- Progress Tracking: Allows users to mark tasks as complete and record reflections in their browser.
- Safety Notes: Highlights considerations such as plant toxicity, heat exposure, heavy pots, and tools.
- Uncertainty Notes: Explains limitations, including the lack of live weather and frost-date information.
- Local AI Inference: Runs a Gemma model locally through Ollama.
- Structured Output Validation: Uses JSON Schema and Pydantic to validate AI-generated plans.
- Reliable Error Handling: Reports model failures instead of presenting fabricated AI-generated plans.
Tech Stack
Frontend
- React 18
- Vite 6
- Tailwind CSS v4
- lucide-react
- Fontsource
Backend
- Python
- FastAPI
- Pydantic v2
- Uvicorn
- httpx
- pydantic-settings
AI and Testing
- Google Gemma
- Ollama
- JSON Schema
- pytest
- ESLint
How It Works
- The user enters their city, garden type, sunlight conditions, experience level, and available daily time.
- The React frontend sends the information to the FastAPI backend.
- The backend sends a prompt and JSON Schema to a Gemma model through Ollama.
- Pydantic validates the generated response.
- The frontend displays the gardening plan, plant recommendations, safety notes, and daily task.
- The user completes the outdoor task, marks it as done, and records a reflection.
Architecture
React + Vite Frontend | v FastAPI Backend | v Ollama Inference Runtime | v Gemma AI Model | v Validated Gardening Plan | v Outdoor Task and Progress Tracking Getting Started
Prerequisites
- Python 3.10 or later
- Node.js and npm
- Ollama
- Sufficient memory and disk space for your selected AI model
1. Clone the Repository
git clone https://github.com/yogesh968/hacktoberfest.git cd hacktoberfest 2. Download the AI Model
Install Ollama and run:
ollama pull gemma3:4b Alternatively, use the smaller model:
ollama pull gemma3:1b 3. Set Up the Backend
cd backend python -m venv .venv Activate the environment.
Windows PowerShell:
.venv\Scripts\Activate.ps1 macOS/Linux:
source .venv/bin/activate Install dependencies:
pip install -r requirements.txt Copy the example environment file:
# Windows copy .env.example .env # macOS/Linux cp .env.example .env 4. Set Up the Frontend
Open another terminal from the repository root:
cd frontend npm install Copy the frontend environment file:
# Windows copy .env.example .env # macOS/Linux cp .env.example .env For local development, configure the backend URL:
VITE_API_BASE_URL=http://localhost:8000 5. Run the Application
Start Ollama if it is not already running:
ollama serve Start the backend from the backend directory:
uvicorn app.main:app --reload --port 8000 Start the frontend from the frontend directory:
npm run dev Open the application:
- Frontend: http://localhost:5173
- Backend API Documentation: http://localhost:8000/docs
Make sure the model configured in the backend has been downloaded.
API Overview
GET /api/health
Checks backend health and model connectivity.
POST /api/garden-plan
Generates a personalized gardening plan.
Example request:
curl -X POST http://localhost:8000/api/garden-plan \ -H "Content-Type: application/json" \ -d '{"city":"Pune","garden_type":"balcony","sunlight":"partial_sun","experience":"beginner","minutes_per_day":15}' Use the exact request fields and accepted values defined by the backend's Pydantic model.
Reliability and Error Handling
The backend uses multiple validation layers to improve reliability:
- Ollama structured outputs constrain the response using JSON Schema.
- Pydantic validates the generated response.
- Additional checks enforce application-specific requirements, including seven days and between two and six plant recommendations.
- Invalid output triggers one retry.
- If validation still fails, the backend returns a clear error.
When AI generation is unavailable, the application can display general gardening advice labelled "Not AI-generated" instead of pretending it came from the model.
Testing
The backend includes 13 automated API tests using pytest.
The tests use a fake HTTP transport instead of Ollama, allowing API behavior and failure scenarios to be tested without running an actual model.
Coverage includes:
- Valid plans
- Malformed model output and retry behavior
- Ollama being unavailable
- Missing models
- Request timeouts
- Invalid form input
Run the backend tests:
python -m pytest -q Run frontend checks from the frontend directory:
npm run lint npm run build Privacy
With the default local configuration:
- User inputs are sent to the local FastAPI backend and Ollama service.
- The backend does not log the city or other form inputs.
- Task completion and reflections are stored in the browser.
- Local AI inference does not require a hosted AI API key.
These privacy statements apply to the local configuration. A remote backend or cloud model may process data outside the user's computer.
Limitations
- The application does not automatically retrieve live weather or frost-date information.
- Plant recommendations may not account for every local growing condition.
- Smaller AI models may occasionally generate invalid or imperfect responses.
- Generation speed depends on the user's hardware.
- Users should verify plant toxicity and local growing advice, especially around children and pets.
Model Licensing
Gemma models have their own licensing terms. Gemma 3 is distributed under Google's Gemma Terms of Use, which differ from an OSI-approved open-source license.
Check the applicable terms for the specific model version you use. The application's code license and the AI model's license are separate.
Contributing
Contributions and suggestions are welcome.
- Fork the repository.
- Create a branch for your changes.
- Implement your changes and add tests where appropriate.
- Run the relevant tests and code-quality checks.
- Submit a pull request describing your changes.
Please do not commit secrets, environment files, or other sensitive information.
Future Improvements
- Integration with verified weather and climate information
- Multilingual gardening assistance
- Plant images with appropriate attribution
- Saved gardening plans and streaks
- Improved regional plant recommendations
- Simplified local setup using Docker Compose
Acknowledgements
Built for the Hacktoberfest Open-Source AI Challenge — Week 1: Touch Grass.
AI Garden Buddy explores how locally run AI can help people move from browsing and learning to taking meaningful action in the real world.
Less scrolling. More growing.
