The Problem Enterprises that need a trustworthy, auditable knowledge base struggle with static graph stores that lose the when of a fact. When policies change or data is corrected, there is no built‑in history, making compliance reviews and “what‑if” simulations costly and error‑prone.
What This Does Utopia implements a bitemporal knowledge graph where every assertion is versioned in time and governed by an immutable ontology. Core logic lives in the Rust crates under crates/:
utopia-core(crates/utopia-core/src/lib.rs) defines shared models, error handling and configuration.utopia-store(crates/utopia-store/src/) provides the persistence layer (PostgreSQL viadb.rs) and enforces ontology constraints.utopia-reason(crates/utopia-reason/src/lib.rs) houses the reasoning engine that evaluates axioms and resolves conflicts.utopia-server(crates/utopia-server/src/main.rs) boots an Actix‑Web HTTP API and ties the store, reasoner, and ingestion pipelines together.
A lightweight React front‑end in web/ (built with pnpm) offers UI for ontology editing, alert monitoring and query exploration.
How It Is Wired
- Startup –
cargo run --bin utopia-server(or the Docker image) executescrates/utopia-server/src/main.rs. - Configuration –
main.rsloadsdotenv::from_path(".env.example")and builds aConfig(fromcrates/utopia-core/src/config.rs). - Web server – Actix registers routes from
src/api/*.rs(e.g.,admin_routes.rs,graph_routes.rs). Each route handler receives anAppStatethat contains aStore(fromutopia-store::db::Pool) and aReasoner(fromutopia-reason). - Request flow – A request to
/api/graphcallsgraph_routes::get_graph, which invokesutopia-store::graph::Graph::loadto fetch the current snapshot, then passes the data toutopia-reason::engine::evaluatefor temporal reasoning. Results are serialized to JSON and returned. - Ingestion –
utopia-ingestprovides parsers (parsers.rs,ontology_rdf.rs) and a chunker (chunker.rs). The server’s/api/ingestendpoint streams RDF/Turtle files intoutopia-ingest::run, which writes new facts viautopia-store::extraction_drops::store_extraction. - Reasoning loop – After each ingestion,
utopia-reason::derive::apply_axiomsruns across the new data, updating derived facts and emitting alerts (utopia-server/src/alerting.rs). - Persistence – All writes go through
utopia-store::db::executewhich runs the migration scripts inmigrations/(e.g.,0001_core.sql,0015_what_it_did_not_just_what_it_said.sql).
The most “blast‑radius” component is utopia-server/src/main.rs because it wires every crate together; changes to the AppState or route registration ripple through the whole API surface.
How To Use It
# 1. Clone (preserves the exact URL the client asked for)
git clone https://github.com/moses-y/utopia.git
cd utopia
# 2. Build the Rust workspace
cargo build --workspace # builds all crates, including server
# 3. Optional: run the UI
pnpm install # installs React deps in ./web
pnpm --filter web build # produces static assets (served by server)
# 4. Prepare the database (PostgreSQL required)
docker compose -f docker-compose.yml up -d db # starts a DB container
# apply migrations (run once)
cargo run -p utopia-server -- migrate
# 5. Start the service (local dev)
cargo run -p utopia-server
# or via Docker (image built from docker/Dockerfile)
docker compose up --build
Configuration lives in .env.example; copy it to .env and adjust DATABASE_URL, HOST, PORT as needed before step 4.
Real‑World Use A compliance team can ingest quarterly policy documents (RDF/Turtle) via POST /api/ingest. The system timestamps each fact, runs the reasoning engine to detect conflicts, and stores an immutable audit trail. When auditors request “why was decision X made on 2023‑07‑15?”, the API can reconstruct the exact ontology state at that timestamp and present the chain of derived facts that led to the decision.
Code Health & Issues
- Low – No CI failures detected; GitHub Actions workflow
ci.ymlrunscargo test --workspaceandpnpm lint. - Low – License file present (
LICENSEApache‑2.0). - Low – Test coverage moderate: 21 test files across core and store crates.
- Low – Secrets not committed (environment variables loaded from
.env.example). - Low – Documentation present (
docs/,README.md,README.zh-CN.md).
Static analysis found no structural red flags; the repository includes lockfiles (Cargo.lock), CI scripts, and a LICENSE, satisfying baseline SDLC hygiene.
The Bottom Line Utopia delivers a Rust‑centric, bitemporal knowledge platform with a clear separation between core models, storage, reasoning and HTTP API. It is well‑structured, container‑ready, and includes a modest test suite. The codebase is suitable for teams that need an auditable, time‑aware ontology engine and are comfortable with Rust and Docker; it may be overkill for simple graph use‑cases.