Examples
These examples are the shortest concrete code paths for the current FACTSTR API.
Rust Examples In This Repository
Basic Memory Store
Source:
Run it:
cargo run --manifest-path examples/basic-memory/Cargo.toml
What it proves:
- create a
MemoryStore - append one committed batch
- query the stored facts
- inspect:
- returned
EventRecordvalues last_returned_sequence_numbercurrent_context_version
Account Projection
Source:
Run it:
cargo run --manifest-path examples/account-projection/Cargo.toml
What it proves:
- define a feature-local read model
- register
stream_to(&EventQuery, handle)for only the relevant facts - append one committed batch where some facts match and others do not
- update the read model from the one delivered committed batch
- keep unrelated facts out of that projection by contract
This is the main feature-slice story in the current repository: the feature owns its own query model, receives only relevant future facts, and updates that model from committed batches.
These examples stay on the memory store because it is the fastest way to understand the current contract without database setup.
Bank Slices CLI
Source:
Run it:
cargo run --manifest-path examples/bank-slices-cli/Cargo.toml
What it proves:
- SQLite-backed feature slices can stay independent without a central
Eventenum or aggregate - write-side slices remain explicit
*Commandtypes - read-side slices are explicit queries such as
BalanceQueryandMovementHistoryQuery - the
fetch_balanceslice owns a realstream_to(...)registration and keeps its local read model current from committed batches - the
fetch_movement_historyslice reads facts directly and stays separate fromfetch_balance
This is the production-like example for the current repository: persisted facts in SQLite, local write-side rule checks, and a real stream-driven read model without introducing a shared domain layer.
Node and TypeScript Package Examples
The current Node and TypeScript examples live with the published package surface rather than as a separate repository example directory.
Use:
docs/node-typescript.mdfor the current package examplesfactstr-node/NPM.mdfor the npm-facing package documentation sourcefactstr-node/smoke/README.mdfor the behavior-owned package verification suite
The exhaustive Node package behavior is verified by the smoke suite under factstr-node/smoke.
That smoke suite is package verification, not a public example application.
The package documentation source lives in factstr-node/NPM.md.
Polished public examples for the Node.js bindings can be added separately later.