mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 01:41:08 +02:00
Add new Planta project for plant care management with: Backend (NestJS): - Plant CRUD with species, location, and care requirements - Watering tracking and scheduling - Photo management with S3 storage - AI-powered plant analysis using Google Gemini Vision API - Drizzle ORM with PostgreSQL schema Web (SvelteKit): - Dashboard with plant overview - Plant detail pages with care history - Add/edit plant forms - Auth integration with login/register routes - API client layer for all endpoints Infrastructure: - Database setup in setup-databases.sh - MinIO bucket for plant photos - Environment variables for port 3022 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5.2 KiB
5.2 KiB
Planta Project Guide
Project Structure
apps/planta/
├── apps/
│ ├── backend/ # NestJS API server (@planta/backend)
│ └── web/ # SvelteKit web application (@planta/web)
├── packages/
│ └── shared/ # Shared types, utils (@planta/shared)
└── package.json
Commands
Root Level (from monorepo root)
pnpm planta:dev # Run all planta apps
pnpm dev:planta:web # Start web app
pnpm dev:planta:backend # Start backend server
pnpm dev:planta:app # Start web + backend together
pnpm dev:planta:full # Start auth + backend + web with DB setup
Backend (apps/planta/apps/backend)
pnpm dev # Start with hot reload
pnpm build # Build for production
pnpm start:prod # Start production server
pnpm db:push # Push schema to database
pnpm db:studio # Open Drizzle Studio
Web App (apps/planta/apps/web)
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build
Technology Stack
- Web: SvelteKit 2.x, Svelte 5 (runes mode), Tailwind CSS
- Backend: NestJS 10, Drizzle ORM, PostgreSQL
- AI: Google Gemini Vision for plant analysis
- Storage: MinIO (local) / Hetzner S3 (prod)
- Auth: Mana Core Auth (JWT)
- Types: TypeScript 5.x
Architecture
Core Flow
- User uploads plant photo
- Photo stored in S3/MinIO
- Gemini Vision analyzes the image
- Plant profile created with care recommendations
- Watering schedule tracked
Backend API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/plants |
GET | Get user's plants |
/api/plants |
POST | Create new plant |
/api/plants/:id |
GET | Get plant details |
/api/plants/:id |
PUT | Update plant |
/api/plants/:id |
DELETE | Delete plant |
/api/photos/upload |
POST | Upload plant photo |
/api/photos/:id |
DELETE | Delete photo |
/api/analysis/identify |
POST | Analyze photo with AI |
/api/analysis/:photoId |
GET | Get analysis results |
/api/watering/upcoming |
GET | Plants needing water |
/api/watering/:plantId/water |
POST | Log watering event |
Database Schema
plants - User's plants
id(UUID) - Primary keyuser_id(TEXT) - User referencename(TEXT) - Plant nicknamescientific_name(TEXT) - From AI analysiscommon_name(TEXT) - Common namelight_requirements(TEXT) - low/medium/bright/directwatering_frequency_days(INT) - Days between wateringhumidity(TEXT) - low/medium/highcare_notes(TEXT) - Care tipshealth_status(TEXT) - healthy/needs_attention/sick
plant_photos - Plant photos
id(UUID) - Primary keyplant_id(UUID) - FK to plantsstorage_path(TEXT) - S3 pathpublic_url(TEXT) - Public URLis_primary(BOOLEAN) - Primary photo flagis_analyzed(BOOLEAN) - Analysis flag
plant_analyses - AI analysis results
id(UUID) - Primary keyphoto_id(UUID) - FK to plant_photosidentified_species(TEXT) - Detected speciesconfidence(INT) - 0-100 confidencehealth_assessment(TEXT) - Health statuswatering_advice(TEXT) - Watering recommendationgeneral_tips(JSONB) - Care tips array
watering_schedules - Watering tracking
id(UUID) - Primary keyplant_id(UUID) - FK to plantsfrequency_days(INT) - Intervallast_watered_at(TIMESTAMP) - Last wateringnext_watering_at(TIMESTAMP) - Next watering
Environment Variables
Backend (.env)
NODE_ENV=development
PORT=3022
DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/planta
MANA_CORE_AUTH_URL=http://localhost:3001
GOOGLE_GEMINI_API_KEY=xxx
CORS_ORIGINS=http://localhost:5173,http://localhost:5191
S3_ENDPOINT=http://localhost:9000
S3_BUCKET=planta-storage
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
Web (.env)
PUBLIC_BACKEND_URL=http://localhost:3022
PUBLIC_MANA_CORE_AUTH_URL=http://localhost:3001
Shared Package
@planta/shared
- Types:
Plant,PlantPhoto,PlantAnalysis,WateringSchedule - Utils: Date helpers, care level formatters
Code Style Guidelines
- TypeScript: Strict typing with interfaces
- Web: Svelte 5 runes mode (
$state,$derived,$effect) - Styling: Tailwind CSS
- Formatting: Prettier with project config
Important Notes
- Authentication: Uses Mana Core Auth (JWT in Authorization header)
- Database: PostgreSQL with Drizzle ORM
- Port: Backend runs on port 3022 by default
- Storage: Photos stored in MinIO (local) / Hetzner S3 (prod)
- AI: Google Gemini Vision for plant identification