[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2937":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":19,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":15,"starSnapshotCount":15,"syncStatus":14,"lastSyncTime":32,"discoverSource":33},2937,"graph","codemix\u002Fgraph","codemix","A type-safe, realtime, collaborative Graph Database which runs inside a CRDT","https:\u002F\u002Fcodemix.com\u002Fgraph",null,"TypeScript",106,9,2,0,1,4,3,false,"main",true,[23,24,25,26,27,28],"crdt","cypher-query-language","graphdatabase","graphdb","gremlin","yjs","2026-06-12 02:00:45","\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fcodemix.com\u002F\">\n    \u003Cimg src=\".\u002Fcodemix-logo.png\" alt=\"codemix\" width=\"240\" \u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n# @codemix\u002Fgraph\n\nA fully type-safe, TypeScript-first in-memory property graph database with a Cypher-like query language, a **type-safe [TinkerPop](https:\u002F\u002Ftinkerpop.apache.org\u002F) \u002F [Gremlin](https:\u002F\u002Ftinkerpop.apache.org\u002Fdocs\u002Fcurrent\u002Freference\u002F#gremlin)-style traversal API** (`GraphTraversal`), multiple index types, and pluggable storage adapters including a [Yjs](https:\u002F\u002Fyjs.dev\u002F) CRDT-based adapter for collaborative\u002Frealtime\u002Foffline-first use.\n\nThis is the knowledge graph database for the [codemix](https:\u002F\u002Fcodemix.com\u002F) product intelligence platform.\n\n## Packages\n\n| Package                                                  | Description                                                                                 |\n| -------------------------------------------------------- | ------------------------------------------------------------------------------------------- |\n| [`@codemix\u002Fgraph`](.\u002Fpackages\u002Fgraph)                     | Core graph database: Cypher queries + type-safe Gremlin-style traversals (`GraphTraversal`) |\n| [`@codemix\u002Ftext-search`](.\u002Fpackages\u002Ftext-search)         | BM25-based full-text search with English stemming                                           |\n| [`@codemix\u002Fy-graph-storage`](.\u002Fpackages\u002Fy-graph-storage) | [Yjs](https:\u002F\u002Fyjs.dev\u002F) CRDT storage adapter for collaborative\u002Foffline-first use            |\n\n---\n\n## `@codemix\u002Fgraph`\n\nA fully typed, in-memory graph database. Vertices and edges are strongly typed against a user-defined schema. You can query with a subset of [Cypher](https:\u002F\u002Fneo4j.com\u002Fdocs\u002Fcypher-manual\u002Fcurrent\u002F) **or** with a fluent, **type-safe [Apache TinkerPop](https:\u002F\u002Ftinkerpop.apache.org\u002F) \u002F [Gremlin](https:\u002F\u002Ftinkerpop.apache.org\u002Fdocs\u002Fcurrent\u002Freference\u002F#gremlin)-style API** — see [`GraphTraversal`](.\u002Fpackages\u002Fgraph\u002FREADME.md#type-safe-tinkerpop--gremlin-traversal-api) in the package docs.\n\n### Features\n\n- **Type-safe TinkerPop \u002F Gremlin traversals** — `GraphTraversal` exposes familiar steps (`V()`, `E()`, `out()`, `in()`, `both()`, `hasLabel()`, `as()` \u002F `select()`, `repeat()` …) with schema-derived typing on paths and properties; pairs with `AsyncGraph.query` for remote execution\n- **Cypher query language** — parsed via a PEG grammar, supporting `MATCH`, `WHERE`, `RETURN`, `CREATE`, `SET`, `DELETE`, `MERGE`, `UNWIND`, `UNION`, `WITH`, multi-statement queries, and more\n- **Strongly typed schema** — vertex\u002Fedge labels and their properties are defined once and inferred throughout\n- **Standard Schema validation** — property values are validated using [Standard Schema](https:\u002F\u002Fstandardschema.dev\u002F) compatible validators (works with Zod, Valibot, etc.)\n- **Multiple index types** — hash (O(1) equality), B-tree (O(log n) range), and full-text (BM25-scored)\n- **Async\u002Fdistributed graph** — `AsyncGraph` supports serializable operations for use across network boundaries\n- **Readonly mode** — parse queries with `readonly: true` to prevent mutation steps\n\n### Installation\n\n```bash\npnpm add @codemix\u002Fgraph\n```\n\n### Development\n\nRunning `pnpm install` in the monorepo configures Git to use the tracked hooks in `.githooks`.\n\nThe pre-commit hook formats staged supported source files with `oxfmt` and restages them automatically. You can re-run the hook setup at any time with `pnpm run setup:hooks`.\n\n### Quick Start\n\n```typescript\nimport { Graph, GraphSchema } from \"@codemix\u002Fgraph\";\nimport { InMemoryGraphStorage } from \"@codemix\u002Fgraph\";\nimport * as z from \"zod\";\n\n\u002F\u002F 1. Define your schema\nconst schema = {\n  vertices: {\n    Person: {\n      properties: {\n        name: { type: z.string() },\n        age: { type: z.number() },\n      },\n    },\n  },\n  edges: {\n    knows: { properties: {} },\n  },\n} as const satisfies GraphSchema;\n\n\u002F\u002F 2. Create the graph\nconst graph = new Graph({\n  schema,\n  storage: new InMemoryGraphStorage(),\n});\n\n\u002F\u002F 3. Add data\nconst alice = graph.addVertex(\"Person\", { name: \"Alice\", age: 30 });\nconst bob = graph.addVertex(\"Person\", { name: \"Bob\", age: 25 });\ngraph.addEdge(alice, \"knows\", bob, {});\n\n\u002F\u002F 4. Query with Cypher\nconst results = graph.query(\"MATCH (a:Person)-[:knows]->(b:Person) RETURN a.name, b.name\");\n\u002F\u002F [{ a: { name: \"Alice\" }, b: { name: \"Bob\" } }]\n```\n\n### Type-safe Gremlin-style traversals\n\nThe same graph is navigable with a fluent API modeled on [Apache TinkerPop Gremlin](https:\u002F\u002Ftinkerpop.apache.org\u002Fdocs\u002Fcurrent\u002Freference\u002F#gremlin); labels and properties stay typed end-to-end:\n\n```typescript\nimport { GraphTraversal } from \"@codemix\u002Fgraph\";\n\nconst g = new GraphTraversal(graph);\nfor (const path of g.V().hasLabel(\"Person\").out(\"knows\")) {\n  console.log(path.value.get(\"name\"));\n}\n```\n\nSee the [type-safe TinkerPop \u002F Gremlin traversal API](.\u002Fpackages\u002Fgraph\u002FREADME.md#type-safe-tinkerpop--gremlin-traversal-api) section in `@codemix\u002Fgraph` for the full step reference.\n\n### Defining a Schema\n\n```typescript\nimport { GraphSchema } from \"@codemix\u002Fgraph\";\nimport * as z from \"zod\";\n\nconst schema = {\n  vertices: {\n    Product: {\n      properties: {\n        sku: { type: z.string() },\n        price: { type: z.number().positive() },\n        name: {\n          type: z.string(),\n          index: { type: \"fulltext\" }, \u002F\u002F full-text search index\n        },\n      },\n      indexes: {\n        sku: { type: \"hash\", unique: true }, \u002F\u002F unique hash index\n      },\n    },\n  },\n  edges: {\n    PURCHASED: {\n      properties: {\n        quantity: { type: z.number().int().positive() },\n      },\n    },\n  },\n} as const satisfies GraphSchema;\n```\n\n### Index Types\n\n| Type       | Lookup      | Use case                                                 |\n| ---------- | ----------- | -------------------------------------------------------- |\n| `hash`     | O(1)        | Equality (`=`) on high-cardinality properties            |\n| `btree`    | O(log n)    | Range queries (`>`, `\u003C`, `>=`, `\u003C=`, `BETWEEN`)          |\n| `fulltext` | BM25 scored | `CONTAINS` \u002F free-text search via `@codemix\u002Ftext-search` |\n\nAll index types support a `unique: true` constraint that throws `UniqueConstraintViolationError` on duplicate values.\n\n### Supported Cypher Features\n\n- `MATCH` with node and relationship patterns, variable-length paths (`*1..5`), shortest path\n- `WHERE` with boolean logic, property access, `IN`, `STARTS WITH`, `ENDS WITH`, `CONTAINS`, `IS NULL`, `IS NOT NULL`, label expressions (`IS LABELED`)\n- `RETURN` with aliases (`AS`), `DISTINCT`, `ORDER BY`, `SKIP`, `LIMIT`\n- `CREATE`, `SET`, `DELETE`, `REMOVE`, `MERGE`\n- `WITH` (pipeline intermediate results)\n- `UNWIND`\n- `UNION` \u002F `UNION ALL`\n- Multi-statement queries (semicolon-separated)\n- `CALL` procedures (built-in and custom via `ProcedureRegistry`)\n- Aggregation functions: `COUNT`, `SUM`, `AVG`, `MIN`, `MAX`, `COLLECT`\n- List comprehensions, pattern comprehensions, `REDUCE`, `EXISTS` subqueries\n- Temporal types: `date`, `datetime`, `localtime`, `localdatetime`, `duration`\n- Arithmetic, string functions, math functions, type conversion functions\n- `CASE` expressions (simple and searched)\n\n### Parsing Queries\n\nFor advanced use cases, you can parse a query to a step plan without running it:\n\n```typescript\nimport { parseQueryToSteps } from \"@codemix\u002Fgraph\";\n\nconst { steps, postprocess } = parseQueryToSteps(\n  \"MATCH (n:Person) RETURN n.name\",\n  { readonly: true }, \u002F\u002F throws ReadonlyGraphError if query mutates\n);\n```\n\n### Custom Functions and Procedures\n\n```typescript\nimport { functionRegistry, procedureRegistry } from \"@codemix\u002Fgraph\";\n\n\u002F\u002F Register a custom scalar function\nfunctionRegistry.register(\"myLib.greet\", {\n  call: ([name]) => `Hello, ${name}!`,\n});\n\n\u002F\u002F Register a custom procedure\nprocedureRegistry.register(\"myLib.listItems\", {\n  call: function* (ctx, [], yields) {\n    yield { item: \"foo\" };\n    yield { item: \"bar\" };\n  },\n});\n```\n\n### AsyncGraph\n\n`AsyncGraph` wraps a regular `Graph` and exposes mutations as serializable operation objects. This is useful for sending graph mutations over a network or message bus.\n\n```typescript\nimport { AsyncGraph } from \"@codemix\u002Fgraph\";\n\nconst asyncGraph = new AsyncGraph({\n  schema,\n  storage: new InMemoryGraphStorage(),\n});\n\n\u002F\u002F Subscribe to operations emitted by writes\nasyncGraph.on(\"operation\", (op) => {\n  sendToRemote(op); \u002F\u002F op is a plain JSON-serializable object\n});\n\nasyncGraph.addVertex(\"Person\", { name: \"Alice\", age: 30 });\n```\n\n---\n\n## `@codemix\u002Ftext-search`\n\nA lightweight, dependency-free full-text search library used internally by `@codemix\u002Fgraph` for full-text indexes.\n\n### Features\n\n- BM25-inspired relevance scoring\n- English word stemming\n- Works on plain strings — no indexing infrastructure required\n\n### Usage\n\n```typescript\nimport { createMatcher, rankDocuments } from \"@codemix\u002Ftext-search\";\n\n\u002F\u002F Score a single document\nconst match = createMatcher(\"quick brown fox\");\nmatch(\"The quick brown fox jumps over the lazy dog\"); \u002F\u002F ~0.85\nmatch(\"A slow gray elephant\"); \u002F\u002F ~0.0\n\n\u002F\u002F Rank a list of documents\nconst results = rankDocuments(\"database performance\", [\n  \"How to improve database query performance\",\n  \"Database connection pooling best practices\",\n  \"Unrelated article about cooking\",\n]);\n\u002F\u002F Returns documents sorted by relevance score descending\n```\n\n---\n\n## `@codemix\u002Fy-graph-storage`\n\nA [Yjs](https:\u002F\u002Fyjs.dev\u002F) CRDT-backed storage adapter for `@codemix\u002Fgraph`. Enables real-time collaborative and offline-first graph databases that sync automatically between peers.\n\n### Features\n\n- Stores graph data inside a `Y.Doc` — compatible with any Yjs provider (WebSocket, WebRTC, IndexedDB, etc.)\n- Observable — subscribe to vertex\u002Fedge changes reactively\n- Zod integration via `ZodYTypes` helpers for schema validation\n\n### Usage\n\n```typescript\nimport * as Y from \"yjs\";\nimport { Graph } from \"@codemix\u002Fgraph\";\nimport { YGraphStorage } from \"@codemix\u002Fy-graph-storage\";\n\nconst doc = new Y.Doc();\nconst storage = new YGraphStorage(doc, schema);\nconst graph = new Graph({ schema, storage });\n\n\u002F\u002F Changes to the graph are automatically reflected in the Y.Doc\n\u002F\u002F and will sync to connected peers via any Yjs provider\ngraph.addVertex(\"Person\", { name: \"Alice\", age: 30 });\n```\n\n---\n\n## Development\n\nThis is a pnpm monorepo managed with [pnpm workspaces](https:\u002F\u002Fpnpm.io\u002Fworkspaces).\n\n### Prerequisites\n\n- Node.js 20+\n- pnpm 9+\n\n### Setup\n\n```bash\npnpm install\n```\n\n### Common Commands\n\n| Command              | Description                                |\n| -------------------- | ------------------------------------------ |\n| `pnpm test`          | Run all tests across packages (watch mode) |\n| `pnpm test:coverage` | Run all tests with coverage report         |\n| `pnpm build`         | Build all packages                         |\n| `pnpm typecheck`     | Type-check all packages                    |\n| `pnpm lint`          | Lint with oxlint                           |\n| `pnpm lint:fix`      | Lint and auto-fix                          |\n| `pnpm format`        | Format with oxfmt                          |\n| `pnpm format:check`  | Check formatting                           |\n\n### Package-level commands\n\n```bash\n# Run tests for a single package\npnpm --filter @codemix\u002Fgraph test\n\n# Build a single package\npnpm --filter @codemix\u002Fgraph build\n```\n\n## License\n\nMIT\n","codemix\u002Fgraph 是一个运行在 CRDT 中的实时协作图数据库。它支持类型安全的 Cypher 查询语言和 TinkerPop\u002FGremlin 风格的遍历 API，具有强类型的顶点和边定义，并且提供多种索引类型（哈希、B-树、全文搜索）。此外，该项目还支持异步分布式操作以及离线优先的 Yjs CRDT 存储适配器。适用于需要实时协作、离线访问或分布式处理的图数据应用场景，如知识图谱管理、产品智能平台等。","2026-06-11 02:51:47","CREATED_QUERY"]