Backend (FastAPI): - REST API: auth, plants, beds, plantings - CRUD layer with CRUDBase - Pydantic v2 schemas for all entities - Alembic migration: complete schema + all enums - Seed data: 28 global plants + 15 compatibilities Frontend (Vue 3 + PrimeVue): - Axios client with JWT interceptor + auto-refresh - Pinia stores: auth, beds, plants - Views: Login, Beds, BedDetail, PlantLibrary - Components: AppLayout, BedForm, PlantingForm, PlantForm Docker: - docker-compose.yml (production) - docker-compose.dev.yml (development with hot-reload) - Nginx config with SPA fallback + API proxy - Multi-stage frontend Dockerfile - .env.example, .gitignore Version: 1.0.0-alpha
63 lines
1.3 KiB
Python
63 lines
1.3 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
from pydantic import BaseModel, computed_field
|
|
|
|
from app.models.bed import LocationType, SoilType
|
|
from app.schemas.plant import PlantRead
|
|
|
|
|
|
class BedBase(BaseModel):
|
|
name: str
|
|
width_m: Decimal
|
|
length_m: Decimal
|
|
location: LocationType
|
|
soil_type: SoilType = SoilType.NORMAL
|
|
notes: str | None = None
|
|
|
|
|
|
class BedCreate(BedBase):
|
|
pass
|
|
|
|
|
|
class BedUpdate(BaseModel):
|
|
name: str | None = None
|
|
width_m: Decimal | None = None
|
|
length_m: Decimal | None = None
|
|
location: LocationType | None = None
|
|
soil_type: SoilType | None = None
|
|
notes: str | None = None
|
|
is_active: bool | None = None
|
|
|
|
|
|
class BedRead(BedBase):
|
|
model_config = {"from_attributes": True}
|
|
|
|
id: uuid.UUID
|
|
tenant_id: uuid.UUID
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
@computed_field
|
|
@property
|
|
def area_m2(self) -> Decimal:
|
|
return self.width_m * self.length_m
|
|
|
|
|
|
class PlantingInBed(BaseModel):
|
|
model_config = {"from_attributes": True}
|
|
|
|
id: uuid.UUID
|
|
plant: PlantRead
|
|
area_m2: Decimal | None
|
|
count: int | None
|
|
planted_date: datetime | None = None
|
|
removed_date: datetime | None = None
|
|
notes: str | None = None
|
|
|
|
|
|
class BedDetailRead(BedRead):
|
|
plantings: list[PlantingInBed] = []
|