vibes-plug-backend · git:20261026.e77f2b7 · 2026-10-26 · sha256 ef972a3d76832162
vibes-plug-backend git:20261026.e77f2b7A
Immutable. This exact content never changes and is served at /api/v1/blob/ef972a3d76832162.
---
alwaysApply: false
description: "Vibes-Plug Backend & Systems Engineering — Node 24, Bun 1.2, Hono, Fastify, Prisma 6, Drizzle, PostgreSQL DDL with RLS, and RFC 9457 errors"
globs: "**/*.{sql,prisma,go,rs,py,route.ts,controller.ts,model.ts,service.ts,entity.ts}"
---
# Vibes-Plug Backend & Systems Engineering (2026 Edition)
When editing backend APIs, server routes, database schemas, or microservices, Cursor AI MUST enforce these standards:
## 1. Schema & Database Invariants
- **PostgreSQL DDL**: Every table MUST have `id UUID PRIMARY KEY DEFAULT gen_random_uuid()`, `created_at TIMESTAMPTZ NOT NULL DEFAULT now()`, `updated_at TIMESTAMPTZ NOT NULL DEFAULT now()`.
- **Foreign Keys**: Every foreign key MUST have an explicit index (`CREATE INDEX idx_... ON ...(...)`).
- **Multi-Tenant Security**: Every tenant-partitioned table MUST enable Row Level Security (`ALTER TABLE ... ENABLE ROW LEVEL SECURITY;`) with an explicit tenant isolation policy (`CREATE POLICY tenant_isolation ...`).
- **Safe Migrations**: Never use destructive `DROP TABLE` or `DROP COLUMN` in production migrations without multi-step deprecation.
## 2. API Contract & Error Resilience
- **Error Standard**: Return RFC 9457 Problem Details (`{ type, title, status, detail, instance }`) on all HTTP 4xx/5xx responses.
- **Validation**: Strict runtime validation at every boundary using `Zod` or `TypeSpec`.
- **Zero Silent Errors**: Catch blocks that swallow errors (`catch (e) {}`) are strictly banned. Always log structured context via `Pino` or `Sentry`.
- **Idempotency**: All mutation endpoints (POST/PUT/PATCH) handling financial transactions or billing MUST enforce idempotency keys (`Idempotency-Key` header with atomic database locking).