1.8 KiB
Scriberr Backend Rules
-
internal/apiis an HTTP adapter only: authenticate, validate, call one service method, map the response. -
Production API code must not import
internal/database, calldatabase.DB, construct repositories, or run GORM queries. -
Long-running work never runs inside handlers; transcription, import extraction, summaries, chat generation, recording finalization, and future automation go through durable services or workers.
-
State transitions have one owner. Queue and transcription status changes must use repository/service methods like enqueue, claim, renew, progress, complete, fail, cancel, and recover.
-
Repositories own persistence shape. Services ask for domain operations; GORM structs, raw rows, SQL details, and schema compatibility stay behind
internal/repositoryandinternal/models. -
ASR, LLMs, media extraction, storage, auth tokens, and webhooks stay behind narrow interfaces so tests can fake them and adapters can change.
-
File paths are internal. Handlers and public responses must not expose or construct local paths; use file, recording, media import, or transcript storage services.
-
Every user-owned operation is scoped by
user_id, including files, transcriptions, profiles, summaries, chat, recordings, API keys, queue stats, and automation. -
Events are small notifications, not source of truth. Persist durable state first, publish after, and make clients able to recover by re-fetching REST resources.
-
Configuration is loaded once, validated at startup, and injected. Runtime code must not read environment variables directly or silently create missing dependencies.
-
internal/appis the only backend composition root.cmd/serverowns process concerns only, and non-bootstrap packages must not importinternal/apiorinternal/database.