Power-up Annotations

Behavioral Extensions & Plugins

Annotations are the "Secret Sauce" of GO-DUCK. By marking an entity with an annotation, you inject sophisticated distributed logic that would otherwise require hundreds of lines of manual code.

@Federated
🌐

Multi-Silo Core

Enables the Precision Harvester 2.0. The entity becomes cross-silo aware, supporting parallel read aggregations and atomic multi-broadcast writes via the Federated Router.

Architectural Impact

Injects Silo-Discovery interceptors & Atomic Mutex locks on write ops.

@Searchable

Elasticsearch Sync

Triggers real-time indexing into Elasticsearch. Every mutation (Create/Update/Delete) is automatically mirrored to the ES engine.

Architectural Impact

Registers GORM AfterSave hooks & scaffolds /api/search/:entity endpoints.

@Audited
📜

Zero-Trust Logging

Enables deep regulatory auditing. Every row change is logged to the central `audit_log` table with Keycloak identity, client IP, and realm roles.

Architectural Impact

Injects AuditContext midddleware & historical row-version snapshotting.

@Version
🔒

Optimistic Locking

Implicitly adds a `version` field. GORM automatically rejects updates (HTTP 409) if the version has changed since the data was fetched.

Architectural Impact

Injects GORM Optimistic Locking plugin & atomic integer increments.

open
🔓

Public API Access

Selectively bypasses the Keycloak JWT stack. This allows you to expose specific entities or granular actions to the public internet without authentication headers.

Supported Method Granularity

read
list
create
delete

Architectural Impact: Scaffolds routes into the /api/open/* group, bypassing the OIDC Validator middleware chain.

@Delete
🗑️

Entity Deletion

Triggers full entity cleanup. Upon import, the generator purges all generated source code (models, controllers, repositories) and generates a database DROP TABLE migration.

Architectural Impact

Removes snapshots from .go-duck/, wipes Go files, and scaffolds drop SQL statements.

@ArchiveStatus
📦

Archival Ready

Triggers the injection of an archived boolean flag. This is functionally equivalent to writing archived <Entity> or archived * globally at the end of the file.

Architectural Impact

Automatically embeds a boolean archived column across PostgreSQL, MongoDB, and UI layers.

The Complete Power-Up Stack

// Entities can combine any number of power-ups
@Searchable @Audited @Federated
entity Transaction {
    string(100) ref required unique
    bigdecimal amount
    datetime txDate
    @Version int(32) v
}
                

Combining all three creates a globally synchronized, audited, and searchable entity with zero-trust integrity.