You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,14 +11,245 @@ Hypergraph re-imagines traditional client–server apps as **local-first**, **pe
11
11
12
12
## Table of Contents
13
13
14
+
-[Knowledge Graphs and GRC-20](#knowledge-graphs-and-grc-20)
14
15
-[Spaces](#spaces)
15
16
-[Identities](#identities)
16
17
-[Inboxes](#inboxes)
17
-
-[Knowledge Graph](#knowledge-graph)
18
18
-[Events & CRDTs](#events--crdts)
19
19
-[Security Model](#security-model)
20
20
21
21
---
22
+
## Knowledge Graphs and GRC-20
23
+
24
+
Hypergraph adopts **GRC-20** as its canonical data format. Every mutation you perform through the Hypergraph SDK—whether it's adding a note, uploading a photo, or inviting a collaborator—ultimately becomes a set of GRC-20 values bundled into an edit. Once the edit is posted, it becomes part of the global knowledge graph—instantly connecting your data to a world of interoperable apps, spaces, and users. From that moment the edit is immutable and immediately queryable via Hypergraph's hooks and GraphQL APIs.
25
+
26
+
### 1. The GRC-20 Standard
27
+
The GRC-20 standard defines how knowledge is structured, shared, and connected in a decentralized, composable way—enabling interoperability across web3 applications. It specifies the core building blocks: entities, types, properties, relations, and values. Read the [GRC-20 spec on GitHub](https://github.com/graphprotocol/graph-improvement-proposals/blob/main/grcs/0020-knowledge-graph.md).
28
+
29
+
### 2. Core Data Model Concepts
30
+
31
+
To illustrate the core pieces of a knowledge graph, we'll break down a single sentence:
32
+
33
+
> **"Teresa, a photographer, owns a Fujifilm camera."**
34
+
35
+
#### The Value Model
36
+
In GRC-20, each **entity** is a node in the graph with a list of **values**. Each value attaches a **property** (by ID) and a literal value (plus options). Properties define the data type and constraints for their values. **Relations** are first-class objects that connect entities and can have their own properties and metadata.
Every entity, attribute, and relation has a unique ID (usually a string, e.g. `PERSON_TYPE_ID`). These are generated per your schema or space, and are required for all operations.
69
+
70
+
#### Entities & Types
71
+
**Entity:** A unique thing in the graph (e.g., `Teresa`, `Camera`).
72
+
**Type:** A category for entities (e.g., `Person`, `Device`).
-**Property:** Attaches data to a single entity (e.g., `Camera` → `brand` → `Fujifilm`).
99
+
-**Relation:** Connects two entities (e.g., `Teresa` → `owns` → `Camera`). Relations are themselves entities and can have their own properties (e.g., `date_acquired`).
-**Check** if a relation linking the same entities already exists before calling `Graph.createRelation`.
151
+
152
+
If you call `createRelation` without checking, you'll end up with multiple relation entities of the same type between the same entities. Deduplication is the responsibility of your application or schema governance.
// Publish ops as an edit (see SDK docs for publishing)
159
+
```
160
+
161
+
Let's bring together everything we've learned above—including our example sentence—into a complete GRC-20–compliant TypeScript example that is fully composable with Hypergraph.
162
+
163
+
```ts title="example.ts"
164
+
// Example: "Teresa, a photographer, owns a Fujifilm camera."
165
+
// This script uses the @graphprotocol/grc-20 SDK to:
166
+
// 1. Create a Camera entity with a brand property
167
+
// 2. Create a Teresa entity with a profession property
168
+
// 3. Check for an existing 'owns' relation from Teresa to the Camera
169
+
// 4. If none exists, create the 'owns' relation entity
170
+
// 5. Bundle all operations into a single edit (ops array)
| Value |`Teresa → profession → photographer`| Value |`{ property: PROFESSION_ATTR_ID, value: 'photographer' }`|
241
+
| Edit | batch of all values | Edit |`ops: [...]`|
242
+
243
+
---
244
+
245
+
_All of the above is not just theory—Hypergraph puts it to work for you._**When you call the SDK or its React hooks, Hypergraph turns your mutations into values, bundles them into edits, encrypts them (if the Space is private), and syncs them peer-to-peer or anchors them on-chain if the data is public.** As a developer you think in entities and hooks; behind the scenes Hypergraph speaks pure GRC-20.
246
+
247
+
---
248
+
249
+
All of these building blocks are specified by the GRC-20 standard and created in code with the GRC-20 SDK.
250
+
251
+
### 3. The GRC-20 SDK
252
+
The [`@graphprotocol/grc-20`](https://www.npmjs.com/package/@graphprotocol/grc-20) SDK is a toolkit for building, reading, and writing GRC-20-compliant knowledge graphs. It provides APIs for creating entities, types, properties, and relations, and handles serialization, publishing to IPFS, and onchain anchoring—making it easy to implement the GRC-20 standard in your apps.
22
253
23
254
## Spaces
24
255
@@ -63,17 +294,6 @@ Inboxes can be **public** (anyone can read) or **private** (E2EE). Auth policies
Public data isn't shoved into a siloed SQL DB. Instead, Hypergraph publishes JSON-LD to a decentralized Knowledge Graph (IPFS + Polygon Amoy smart contracts).
69
-
70
-
Benefits:
71
-
72
-
***Composability** — one app's `City` objects can be queried by another app.
73
-
***Network effects** — each new Space or entity enriches the shared graph.
74
-
75
-
A TypeScript codegen tool (see the _TypeSync app_ in `/apps/typesync`) maps your domain models to on-chain schemas so you can query them like regular React hooks.
76
-
77
297
## Events & CRDTs
78
298
79
299
1. A client mutates the Automerge document (`doc.put(…)`).
@@ -97,4 +317,17 @@ When the event log grows large, a peer may emit `sendCompactedUpdate`—a snapsh
**Always check for an existing relation (by `from`, `to`, and `relationType`) before creating a new one.**
324
+
325
+
This prevents duplicate relations, keeps your data model clean, and avoids ambiguity in queries and UI. The GRC-20 SDK will create a new relation entity every time unless you check first.
326
+
:::
327
+
328
+
:::info Terminology Update
329
+
In the latest GRC-20 spec, what were previously called "triples" are now called "values." The "value type" is now called "data type," and data types are defined on the property, not the value. This change makes the model simpler and validation more robust.
330
+
:::
331
+
332
+
**Note:** The data service validates that each value matches the property's data type.
@@ -38,9 +39,13 @@ Every update is encrypted **on the client** using XChaCha20-Poly1305. Only membe
38
39
***Automatic key rotation** when members join/leave.
39
40
***Multi-device**: each device holds its own key pair.
40
41
42
+
## Knowledge Graph SDK
43
+
44
+
Build, link, and publish knowledge as entities and relations using the [`@graphprotocol/grc-20`](https://www.npmjs.com/package/@graphprotocol/grc-20) Knowledge Graph SDK. It makes it easy to organize data into spaces, anchor edits onchain, and work with The Graph's knowledge graph standard.
45
+
41
46
## Graph-based data model
42
47
43
-
Under the hood, Hypergraph stores JSON-LD triples that map nicely to **knowledge graphs**. This makes it trivial to expose public data on-chain or query it with SPARQL later.
48
+
Under the hood, Hypergraph stores JSON-LD values that map nicely to **knowledge graphs**. This makes it trivial to expose public data on-chain or query it with SPARQL later.
0 commit comments