Glossary Backend Module

Glossary Backend Module

Go backend module handling glossary CRUD operations, SQLite persistence via Ent ORM, reciprocal relationship management, FTS5 search indexing, and background term scanning.

Responsibilities

Public API Surface

Export Kind Description
GlossaryHandler struct HTTP handler with route dispatcher
Store (glossary methods) methods SQLite repository CRUD implementation
TermScanHandler struct Background job handler for term scanning

Internal Structure

The module is organized across three source files in different Go packages, unified by the module's shared purpose:

Route registration happens in backend/internal/http/server.go, where GlossaryHandler.Glossary is mounted on the /api/projects/{slug}/glossary path prefix. Handler construction and callback wiring occur in backend/cmd/server/main.go (lines 159-206).

Dependencies

Dependency Internal / External Purpose
data-models/GlossaryEntry internal Ent ORM schema for glossary entries (37 fields)
data-models/Glossary internal Parent entity schema (1:1 with Project)
repository.ProjectStore internal Interface for store operations (CRUD, listing)
search.SearchProvider internal FTS5 indexing (optional, may be nil)
jobs.JobSubmitter internal Background job submission (optional, may be nil)
prosemirror package internal Mark manipulation for term scanning
scope package internal Content scope filtering (ItemAppliesToContent)

Dataflow Diagrams

Security

No authentication or authorization is enforced at the glossary level -- all operations are scoped to the local per-project SQLite database file. The per-project isolation means one project's glossary cannot access another's data.

Input validation:

The image_url field accepts arbitrary URLs. If this is ever rendered as <img src>, it could be an XSS vector. Currently it is only stored, not rendered in the UI.

Performance