factcircuit
FactCircuit: an auditable claim-and-evidence verification loop with immutable provenance, staged checks, bounded retrieval, and reproducible evaluation.
Embedded knowledge graph for TypeScript. Define your ontology with Zod, query with a fluent builder, blend BM25 fulltext with vector similarity, and extend the schema at runtime when your agents need
DataTypeScript · JavaScriptGitHub @nicia-aiOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
The Knowledge Graph for TypeScript
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
TypeScript-first embedded knowledge graph library.
TypeGraph brings property graph modeling and practical ontology support to your existing SQLite or PostgreSQL
database. Define nodes and edges with Zod, query with a fluent TypeScript API, and keep graph + app data in one
deployment.Read the full README ↗TypeScript-first embedded knowledge graph library.
TypeGraph brings property graph modeling and practical ontology support to your existing SQLite or PostgreSQL database. Define nodes and edges with Zod, query with a fluent TypeScript API, and keep graph + app data in one deployment.
subClassOf, implies, inverseOf, and disjointWithTypeGraph works well for:
TypeGraph is not designed for:
npm install @nicia-ai/typegraph zod drizzle-orm better-sqlite3
npm install -D @types/better-sqlite3
For edge/serverless environments (Cloudflare Durable Objects, D1, libsql, bun:sqlite), see the docs: Edge and Serverless.
import { z } from "zod";
import { defineEdge, defineGraph, defineNode } from "@nicia-ai/typegraph";
import { createLocalSqliteStore } from "@nicia-ai/typegraph/sqlite/local";
const Person = defineNode("Person", {
schema: z.object({ name: z.string(), role: z.string().optional() }),
});
const Project = defineNode("Project", {
schema: z.object({ name: z.string(), status: z.enum(["active", "done"]) }),
});
const worksOn = defineEdge("worksOn");
const graph = defineGraph({
id: "my_app",
nodes: {
Person: { type: Person },
Project: { type: Project },
},
edges: {
worksOn: { type: worksOn, from: [Person], to: [Project] },
},
});
const store = await createLocalSqliteStore(graph);
const alice = await store.nodes.Person.create({ name: "Alice", role: "Engineer" });
const website = await store.nodes.Project.create({ name: "Website", status: "active" });
await store.edges.worksOn.create(alice, website, {});
const results = await store
.query()
.from("Person", "p")
.traverse("worksOn", "e")
.to("Project", "proj")
.select((ctx) => ({ person: ctx.p.name, project: ctx.proj.name }))
.execute();
console.log(results);
// [{ person: "Alice", project: "Website" }]
For production schema management, see: createStoreWithSchema.
The managed SQLite entrypoint provisions the schema and returns the complete,
schema-derived Store API without exposing Drizzle types. PostgreSQL consumers
can use the equivalent createLocalPgliteStore from
@nicia-ai/typegraph/postgres/pglite. Bring-your-own-connection integrations
live under the explicit /adapters/drizzle/... entrypoints.
Packages that only define or share graph schemas can import the DSL and its
schema-derived types from @nicia-ai/typegraph/core. Custom backend and search
strategy authors can use the complete Drizzle-free contract vocabulary from
@nicia-ai/typegraph/backend.
drizzle-orm is an optional peer dependency. @nicia-ai/typegraph/sqlite/local
and @nicia-ai/typegraph/postgres/pglite load it only when their factory is
called and refuse with a typed ConfigurationError
(MISSING_PEER_DEPENDENCY) naming the package and the install command
(npm install drizzle-orm) when it is absent. The six explicit
/adapters/drizzle/... entrypoints expose Drizzle-native backends, connections,
or schema builders and load drizzle-orm when the module is evaluated. Importing
one without the peer installed therefore surfaces the raw module-resolution
error, which names the same package.
TypeGraph publishes agent-friendly documentation following the llms.txt convention:
Recommended retrieval order: llms-small → llms-full → examples.
MIT