feat: Step 6 - Write-through cache API
Implement the core write-through cache pattern for node creation. This is the architectural foundation of the application. Changes: - Add @google/generative-ai dependency for embeddings - Create lib/db.ts: SurrealDB connection helper with JWT auth - Create lib/ai.ts: AI embedding generation using text-embedding-004 - Create app/api/nodes/route.ts: POST endpoint implementing write-through cache Write-through cache flow: 1. Authenticate user via SurrealDB JWT 2. Publish node to ATproto PDS (source of truth) 3. Generate 768-dimensional embedding via Google AI 4. Cache node + embedding + links in SurrealDB Updated schema to use 768-dimensional embeddings (text-embedding-004) instead of 1536 dimensions. Security: - Row-level permissions enforced via SurrealDB JWT - All secrets server-side only - ATproto OAuth tokens from secure cookies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -68,9 +68,9 @@ DEFINE FIELD coords_3d ON TABLE node TYPE array<number>
|
||||
|
||||
-- Define the vector search index.
|
||||
-- We use MTREE (or HNSW) for high-performance k-NN search.
|
||||
-- The dimension (1536) MUST match the output of the
|
||||
-- 'gemini-embedding-001' model.
|
||||
DEFINE INDEX node_embedding_idx ON TABLE node FIELDS embedding MTREE DIMENSION 1536;
|
||||
-- The dimension (768) MUST match the output of the
|
||||
-- 'text-embedding-004' model.
|
||||
DEFINE INDEX node_embedding_idx ON TABLE node FIELDS embedding MTREE DIMENSION 768;
|
||||
|
||||
-- --------------------------------------------------
|
||||
-- Relation: links_to
|
||||
|
||||
Reference in New Issue
Block a user