Teaching farmers with sustainable practices through missions, community, rewards, quizzes, and AI assistance.
Overview • Features • Architecture • Getting Started • Env Vars • Troubleshooting • Roadmap
Our Platform motivates farmers to adopt sustainable, climate‑smart practices through structured missions, quizzes, community interaction, and an AI agronomy assistant. The current build is an MVP optimized for rapid iteration, accessibility, and extensibility.
Area | Description |
---|---|
Missions | Start / progress / complete sustainable practice challenges; local persistence and recommendations. |
Dashboard | Track points, streak potential, progress, and reward metrics. |
Rewards | View and (future) redeem reward items; mock persistence. |
Community | Placeholder hub for future threaded discussions. |
Blog | Create, list, view, and locally persist posts with tags & filters. |
Quiz | Timed multi‑question quiz with levels, badges, sounds, share & leaderboard views. |
Leaderboard | Local (device) ranking of quiz scores including level & badges summary. |
AI Chat | Gemini‑powered plain‑text assistant (no markdown parsing) via /api/chat . |
Feedback | Local feedback capture (localStorage ) for feature / bug tracking. |
Weather & Calculator | Crop profit calculator + city weather lookup. |
Auth | Google OAuth (NextAuth) + demo sign-in placeholder. |
Logical layers:
- UI (Next.js App Router + Tailwind CSS + Radix primitives + custom design system)
- Auth (NextAuth.js session + OAuth provider)
- AI (Gemini API wrapper route
app/api/chat/route.ts
) - Domain modules (missions, rewards, quiz, blog, support)
- State & Utilities (Zustand + helpers in
lib/
& custom hooks) - Static Assets & Styling (
public/
,styles/
)
app/
api/
chat/route.ts # Gemini proxy
blog/ # Blog pages
calculator/ # Crop profit calculator
community/ # Community hub (placeholder)
dashboard/ # User dashboard
leaderboard/ # Quiz leaderboard
missions/ # Missions listing
quiz/ # Quiz flows + subpages
rewards/ # Rewards center
support/ # Full AI chat page
signin/ # Auth
components/
ai-chat-widget.tsx
feedback-form.tsx
mission-card.tsx
rewards-dashboard.tsx
ui/ # Reusable primitives
hooks/
lib/
public/
styles/
- User input (widget or
/support
). - POST to
/api/chat
with{ message }
. - Route calls Gemini with safety prompt.
- Response returned as plain text.
- UI appends message (no markdown rendering to reduce injection surface).
All state is local (memory or localStorage
). Future plan: Postgres + Prisma or Supabase with server actions.
Stored under keys: feedbackItems
, quizScores
in localStorage
.
- Clone:
git clone https://github.com/mdsahilnoob/agriculture.git
&cd agriculture
- Copy
.env.example
→.env.local
- Fill in the required environment variables
- Install dependencies:
npm install
(default)- or
pnpm install
(if you use pnpm)
- Start dev server:
npm run dev
- Visit
http://localhost:3000
npm run dev # Start development server
npm run build # Build for production
npm start # Run production build
npm run lint # Lint codebase
Create .env.local
(not committed). Reference template in .env.example
.
Required:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GEMINI_API_KEY=
NEXTAUTH_SECRET=
NEXTAUTH_URL=http://localhost:3000
OPENWEATHER_API_KEY=
Optional (Email auth):
EMAIL_SERVER=
EMAIL_FROM=
Generate a secure secret (cross‑platform suggestion):
Node: node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
Gemini key: https://makersuite.google.com/app/apikey
Issue | Cause | Fix |
---|---|---|
AI Chat 400 / invalid key | Missing / bad GEMINI_API_KEY |
Add valid key & restart server |
Google OAuth callback error | Redirect URI mismatch | Add http://localhost:3000/api/auth/callback/google to console |
Email provider not showing | Missing both email vars | Set EMAIL_SERVER , EMAIL_FROM |
PowerShell script restrictions | Execution policy blocks pnpm | Use CMD or run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned |
Full reload instead of Fast Refresh | Large structural change or error | Check terminal warnings & fix component boundaries |
No secrets are committed. AI route limits output formatting to reduce prompt injection risk. Add rate limiting & server validation once persistence is introduced.
Phase | Goal | Highlights |
---|---|---|
1 | MVP Polish | Auth, static missions, AI chat, quiz & rewards baseline |
2 | Persistence Layer | Postgres + Prisma / Supabase, mission & quiz storage |
3 | Community Expansion | Threads, replies, moderation, rich media |
4 | Advanced AI | Multi‑turn memory, context enrichment, agronomy advisories |
5 | PWA & Offline | Install prompt, offline mission progress, cache strategy |
6 | Marketplace | Partner reward catalog, redemption workflows |
7 | Analytics & Impact | Track sustainable practice adoption metrics |
- Fork & branch
- Install dependencies & configure
.env.local
npm run dev
- Follow component + accessibility conventions
- PR with context + screenshots / before–after if UI
ESLint stricter config, unit tests (Vitest / Jest), accessibility audit, story-based component docs, i18n scaffolding.
Currently unlicensed (default: all rights reserved). Add an OSS license (MIT / Apache-2.0) if external contributions are desired.
Thanks for supporting sustainable agriculture! 🌱