Plant Care
Houseplant care API that turns soil moisture and watering history into care advice via computed columns
One app.py with 1 table, 3 computed columns, 4 HTTP routes. Needs pixeltable[serve]>=0.7.14. Updated 2026-09-26.
app.py
"""Plant Care API built with Pixeltable.pxt schema update app.py plantspxt service run app.py plants"""import pixeltable as pxtimport pixeltable.functions as pxtffrom pixeltable.serving import FastAPIRouterfrom udfs import care_blurb, water_advice# ---- tables ----TableModel = pxt.model_base()class Plants(TableModel, name='plants'):id = pxt.Column(value=pxtf.uuid.uuid7(), primary_key=True)species: pxt.Stringlocation: pxt.Stringmoisture: pxt.String | Nonedays_since_water: pxt.Int | Nonenotes: pxt.String | Nonewater_label = water_advice(moisture, days_since_water)species_upper = pxtf.string.upper(species)notes_blurb = care_blurb(species, location)# ---- queries ----@pxt.querydef thirsty():"""Plants whose computed advice is 'water today'."""return Plants.where(Plants.water_label == 'water today').select(Plants.id, Plants.notes_blurb, Plants.days_since_water).order_by(Plants.days_since_water, asc=False)# ---- routes ----plants_api = FastAPIRouter(name='plants_api')plants_api.add_insert_route(Plants, path='/plants',inputs=[Plants.species, Plants.location, Plants.moisture, Plants.days_since_water, Plants.notes],outputs=[Plants.id, Plants.water_label, Plants.species_upper, Plants.notes_blurb],)plants_api.add_update_route(Plants, path='/plants/update', inputs=[Plants.moisture, Plants.days_since_water],outputs=[Plants.id, Plants.water_label])plants_api.add_compute_route(Plants, path='/water-label', inputs=[Plants.moisture, Plants.days_since_water],outputs=[Plants.water_label])plants_api.add_query_route(path='/plants/thirsty', query=thirsty, method='get')
What app.py declares
Each row links to its line.
- runs on insert
- stored
- index
- route
serves plants_api
- POST/plantsinsert, plantstakes species, location, moisture, days_since_water, notes; returns id, water_label, species_upper, notes_blurbL40
- POST/plants/updateupdate, plantstakes moisture, days_since_water; returns id, water_labelL45
- POST/water-labelcompute, plantstakes moisture, days_since_water; returns water_labelL47
- GET/plants/thirstyquery, thirstyL49
Run it
Needs uv. The routes then answer on port 8000.
terminal
git clone https://github.com/pierrebrunelle/pixeltable-plant-carecd pixeltable-plant-careuv syncuv run pxt schema update app.py plantsuv run python seed.py plantsuv run pxt service run app.py plants --port 8000
Related apps
- Forge Heat CyclesForge heat-cycle registry API: B-tree indexes, chained risk UDFs, and parallel shop-floor writersShares: UDFs
- Climbing Route ToposClimbing-route topo registry API: photo uploads with thumbnails, grayscale copies, grade bands and index-backed crag lookupsShares: UDFs
- Warehouse Pick ListsWarehouse pick-list REST API: units, pick zones, waves and tote labels as incremental computed columns over Json order linesShares: UDFs