How sayan365/plant-identifier works
Project Type and Purpose
• This is a full-stack, server-rendered web application built with React and Next.js.
• Purpose: Let users upload/capture plant photos and fetch species info from an external Plant Identification API.
Main Architectural Components
a. Client (Web Browser)
– React pages (app/page.js) and components (PlantCard.js, SearchBar.js)
– Tailwind CSS for styling (globals.css, tailwind.config.js)
b. Next.js Server
– Page rendering (SSR/SSG) via layout.js & page.js
– API Routes (app/api/identify/route.js & app/api/test/route.js)
– Static assets served from public/
c. External Service
– Plant Identification API (third-party HTTP service)
d. Infrastructure & Build
– next.config.js, tsconfig.json, postcss.config.js
– Environment variable (NEXT_PUBLIC_API_KEY)
Relationships & Data Flows
1. User visits the site → HTTP GET to Next.js server → Server sends pre-rendered HTML + JS bundle
2. User uploads/captures image in UI → Frontend issues POST to /api/identify
3. Next.js API handler (route.js)
• Receives image payload
• Reads NEXT_PUBLIC_API_KEY from env
• Forwards request to external Plant Identification API
4. External API returns JSON plant data → Next.js API handler transforms it → Responds to client
5. Frontend updates React state → Renders PlantCard with species details
Architectural Patterns & Design Principles
• File-based routing: pages and API routes co-located under app/
• Component-based UI: reusable PlantCard & SearchBar
• Serverless functions: Next.js API routes act as lightweight backends
• Environment isolation: .env.local for secrets
• Utility-first styling: Tailwind CSS