Back-end Architecture

Server actions, databases, and event-driven processing in the Plantfolio monorepo.

@plantfolio/server

The primary backend layer is @plantfolio/server, a shared package of server actions consumed by the dashboard and admin apps. There is no public REST API — all data access flows through server actions.

Key action domains:

  • Assets — Unified asset store (media, uploads)
  • Canvas — Signage template editing
  • FolioPlants — Plant collections within folios
  • Folios — User folios (create, clone, reorder)
  • Identifications — AI plant identification results
  • MediaManager — Attachments, gallery images, cover photos

Databases

Plantfolio uses two PostgreSQL databases. Schemas live in packages/db/postgres/prisma and packages/db/plants/prisma. The @plantfolio/db/prisma export re-exports the postgres client for backward compatibility.

  • Main database — Users, folios, folio plants, identifications, media, canvas, organizations. Prisma 7 schema with migrations.
  • Plants database — Plant catalog, embeddings (pgvector). Used for search and plant lookups.

Separate connection URLs for the main and plants databases; direct connections used for migrations and long-running workers.

Inngest

Event-driven background jobs use Inngest. The Inngest app is hosted in the dashboard. Events are sent from server actions, workers, and API routes.

Example events:

  • Support ticket creation
  • User onboarding completion
  • Plant identification created
  • Sign render requested
  • Folio/FolioPlant changes (from change-stream-worker)

Backend Packages

  • @plantfolio/auth — Clerk integration, getOptionalUser, session handling
  • @plantfolio/db — Prisma clients, migrations (postgres + plants)
  • @plantfolio/server — Server actions
  • @plantfolio/plants — Plant entities, completions, repositories
  • @plantfolio/search — Algolia, plant search
  • @plantfolio/ai — Embeddings, AI utilities
  • @plantfolio/media — Vercel Blob, S3, upload utilities
  • @plantfolio/email — Resend, email templates
  • @plantfolio/events — Inngest client, event schemas
  • @plantfolio/kv — KV storage (e.g. AI context)
  • @plantfolio/payments — Stripe integration
  • @plantfolio/identification — Plant ID API, identification logic

API Patterns

  • Server actions for synchronous mutations and reads (no public REST API)
  • Inngest for async work (emails, search indexing, rendering)
  • Centralized error capture utility for error reporting

← Back to overview