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 via db.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

  1. Startup – cargo run --bin utopia-server (or the Docker image) executes crates/utopia-server/src/main.rs.
  2. Configuration – main.rs loads dotenv::from_path(".env.example") and builds a Config (from crates/utopia-core/src/config.rs).
  3. Web server – Actix registers routes from src/api/*.rs (e.g., admin_routes.rs, graph_routes.rs). Each route handler receives an AppState that contains a Store (from utopia-store::db::Pool) and a Reasoner (from utopia-reason).
  4. Request flow – A request to /api/graph calls graph_routes::get_graph, which invokes utopia-store::graph::Graph::load to fetch the current snapshot, then passes the data to utopia-reason::engine::evaluate for temporal reasoning. Results are serialized to JSON and returned.
  5. Ingestion – utopia-ingest provides parsers (parsers.rs, ontology_rdf.rs) and a chunker (chunker.rs). The server’s /api/ingest endpoint streams RDF/Turtle files into utopia-ingest::run, which writes new facts via utopia-store::extraction_drops::store_extraction.
  6. Reasoning loop – After each ingestion, utopia-reason::derive::apply_axioms runs across the new data, updating derived facts and emitting alerts (utopia-server/src/alerting.rs).
  7. Persistence – All writes go through utopia-store::db::execute which runs the migration scripts in migrations/ (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.yml runs cargo test --workspace and pnpm lint.
  • Low – License file present (LICENSE Apache‑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.