What Are Annotations?
Annotations are metadata markers that hint at the intended usage pattern of a field:- Do not change the logical data model
- Do not force a specific backend implementation
- Enable future routing and optimization
- Are validated at compile time
Available Annotations
@cache
Marks data as ephemeral or frequently accessed:Indicates data that is ephemeral, frequently read, or needs fast access.Use Cases:Current Behavior (v1.0):
- Session tokens
- Rate limiting counters
- Temporary data
- View counts
- Cache keys
- Fields are stored in the primary backend (PostgreSQL)
- Annotation is preserved for future routing
- May route to Redis or similar cache backends
- May use different TTL policies
- May implement automatic expiration
@olap
Marks data optimized for analytical queries:Indicates data used for analytical queries, aggregations, and reporting.Use Cases:Current Behavior (v1.0):
- Metrics and aggregates
- Historical data
- Data warehouse fields
- BI reporting
- Time-series data
- Fields are stored in the primary backend (PostgreSQL)
- Annotation is preserved for future routing
- May route to DuckDB or columnar stores
- May use different indexing strategies
- May enable specialized aggregation paths
@vector
Marks vector embeddings for similarity search:Indicates vector embeddings used for similarity search and ML operations.Requirements:Current Behavior (v1.0):
- Must be used with
vector(N)type - Dimension count required
- Text embeddings
- Image embeddings
- Similarity search
- Semantic search
- Recommendation systems
- Requires PostgreSQL with pgvector extension
- Stored as
VECTOR(N)column type - Can use vector similarity queries
- May route to specialized vector databases (Pinecone, Weaviate)
- May use optimized similarity algorithms
- May enable hybrid search
Annotation Syntax
Annotations appear after the field type and constraints:Validation Rules
Annotations are validated at compile time:Type Compatibility -
@vector requires vector(N) typeSingle Annotation - Each field can have at most one backend annotation
Valid Annotation - Only recognized annotations are allowed
Complete Example
Here’s a complete schema using all annotations:Current Implementation (v1.0)
In v1.0-alpha, all fields are stored in PostgreSQL regardless of annotation:- ✅ Parsed and validated
- ✅ Stored in the schema vault
- ✅ Preserved for future use
- ⏳ Not yet routed to specialized backends
Future Backend Routing
In future versions, annotations will enable automatic routing:- Automatic backend selection
- Fallback strategies
- Cross-backend queries
- Consistency guarantees
Use Case Patterns
Session Management
Analytics Dashboard
Semantic Search
E-commerce Product
Best Practices
Design Philosophy
Annotations follow these principles:- Declarative - Express intent, not implementation
- Optional - Fields work without annotations
- Non-breaking - Adding/removing annotations doesn’t break the schema
- Future-proof - Enable optimization without rewriting schemas
Annotation Reference
| Annotation | Required Type | Current Backend | Future Backends |
|---|---|---|---|
@cache | Any | PostgreSQL | Redis, Memcached |
@olap | Any | PostgreSQL | DuckDB, ClickHouse |
@vector | vector(N) | PostgreSQL + pgvector | Pinecone, Weaviate |