OriginChain docs
examples · atomic multi-shape

Atomic multi-shape writes — copy-paste JSON.

← All examples

OriginChain writes a row, its embedding, its full-text postings, and its graph edges in a single API call. One WAL frame. One fsync. All-or-nothing. The five recipes below show the request body, the response shape, and the multi-system stack you avoid by writing once.

Every shape lands inside the same WAL frame as the base row. If the frame fsyncs, every shape is visible to readers. If the frame fails, none of it lands. Cross-system reconciliation jobs become unnecessary because the shapes never diverge in the first place.

Product catalog

Product catalog — row + embedding + FTS + supplier edge

One product write places the row, a 768d image-text embedding, the search-indexed body, and the supplier-relation edge. One WAL frame, one fsync, all-or-nothing.

Without OriginChain: Postgres for the row, Pinecone for the vector, Elasticsearch for full-text, Neo4j for the supplier edge. Four systems, four bearers, four failure modes, no atomicity across them.

Request
curl -X POST "$ENGINE/v1/tenants/$T/rows/shop.products" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "id":           "sku-9281",
  "name":         "Trailblazer 2",
  "description":  "All-terrain running shoe with carbon-plate forefoot.",
  "price":        129.0,
  "category":     "running-shoes",
  "embedding":    [0.0124, -0.0883, 0.0451, 0.0192, 0.0772, -0.0341, 0.0118, -0.0204],
  "fts": {
    "description": "Trailblazer 2 all-terrain running shoe carbon plate forefoot"
  },
  "edges": [
    { "rel": "supplied_by", "dst": "supplier.acme-shoes" }
  ]
}
JSON
Response
{
  "inserted": 1,
  "indexed_vectors": 1,
  "indexed_fts_fields": 1,
  "edges_written": 1,
  "lsn": 41827811,
  "elapsed_ms": 6
}

Knowledge base

Knowledge-base article — row + embedding + FTS

Publish an article and make it findable by both BM25 keyword search and vector similarity in a single call. The article becomes searchable the moment the WAL fsyncs.

Without OriginChain: write to Postgres, then push to Pinecone for the embedding, then index in Elasticsearch. Three writes, three caches, three eventual-consistency windows.

Request
curl -X POST "$ENGINE/v1/tenants/$T/rows/kb.articles" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "id":         "kb-2026-001",
  "title":      "How OriginChain handles atomic multi-shape writes",
  "body":       "OriginChain writes the row, vector, full-text postings, and graph edges in a single WAL frame. One fsync, all-or-nothing.",
  "author":     "engineering",
  "published":  true,
  "embedding":  [0.0211, -0.0612, 0.0341, 0.0128, 0.0822, -0.0241, 0.0091, -0.0182],
  "fts": {
    "title": "How OriginChain handles atomic multi-shape writes",
    "body":  "OriginChain writes the row, vector, full-text postings, and graph edges in a single WAL frame."
  }
}
JSON
Response
{
  "inserted": 1,
  "indexed_vectors": 1,
  "indexed_fts_fields": 2,
  "lsn": 41827822,
  "elapsed_ms": 5
}

Social

Social user — row + embedding + follow edges

Create a profile, embed it for similar-user lookup, and seed the follow graph in one request. Reverse adjacency answers "who follows me?" in a single prefix scan.

Without OriginChain: Postgres for the profile, Pinecone for the user-similarity vector, Neo4j for the follow graph. Three systems for one signup.

Request
curl -X POST "$ENGINE/v1/tenants/$T/rows/social.users" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "id":          "alice",
  "display":     "Alice Kapoor",
  "bio":         "Mechanical engineer. Trail runner. Reading sci-fi.",
  "joined_at":   "2026-05-02T09:14:11Z",
  "embedding":   [0.0182, -0.0712, 0.0419, 0.0151, 0.0808, -0.0301, 0.0107, -0.0211],
  "edges": [
    { "rel": "follows", "dst": "bob"   },
    { "rel": "follows", "dst": "carol" },
    { "rel": "follows", "dst": "dan"   }
  ]
}
JSON
Response
{
  "inserted": 1,
  "indexed_vectors": 1,
  "edges_written": 3,
  "lsn": 41827833,
  "elapsed_ms": 6
}

Audit

Audit event — row + relation + FTS

Append-only audit log with a relation tying the event to its actor and a full-text index over the message for incident investigation.

Without OriginChain: Postgres for the event, a separate audit-events service for the actor lookup, Elasticsearch for log search. Three writes per event in the hot path.

Request
curl -X POST "$ENGINE/v1/tenants/$T/rows/audit.events" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "id":         "evt-2026-05-02-00001",
  "occurred_at":"2026-05-02T10:14:11Z",
  "actor":      "user.alice",
  "action":     "schema.update",
  "subject":    "shop.products",
  "message":    "Added column 'carbon_plate' to shop.products",
  "fts": {
    "message": "Added column carbon plate to shop products"
  },
  "edges": [
    { "rel": "performed_by", "dst": "user.alice" },
    { "rel": "targets",      "dst": "shop.products" }
  ]
}
JSON
Response
{
  "inserted": 1,
  "indexed_fts_fields": 1,
  "edges_written": 2,
  "lsn": 41827844,
  "elapsed_ms": 4
}

Agent memory

Agent memory — row + embedding + relation

An LLM agent commits a memory: the structured row for replay, the embedding for similarity recall, the relation for thread membership. One call, one fsync.

Without OriginChain: an app-managed table, a managed vector index, and a separate thread-link table — kept consistent in application code with no transactional guarantee across the three.

Request
curl -X POST "$ENGINE/v1/tenants/$T/rows/agent.memories" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d @- <<'JSON'
{
  "id":         "mem-77f2-001",
  "thread_id":  "thr-77f2",
  "role":       "assistant",
  "content":    "Customer prefers contact between 09:00 and 11:00 IST.",
  "created_at": "2026-05-02T11:02:18Z",
  "embedding":  [0.0144, -0.0681, 0.0398, 0.0117, 0.0812, -0.0271, 0.0099, -0.0192],
  "edges": [
    { "rel": "in_thread", "dst": "thread.thr-77f2" }
  ]
}
JSON
Response
{
  "inserted": 1,
  "indexed_vectors": 1,
  "edges_written": 1,
  "lsn": 41827855,
  "elapsed_ms": 5
}