This document captures the current architectural direction for a PG-first, event-driven system spanning:
foundation-basestatstrade-corestatstrade-v1gw-v2The goal is to preserve the original strengths of the old system:
while also preserving newer work in:
rt.postgresserver -> client.:db/sync.:db/sync.defpolicy.pg stay in the server/database layer.statstrade-core style.xt.db Is Part Of The Backbonext.db is a major part of the architecture, not a side utility.xt.db already carries graph query, sql/cache, pull, and sync-oriented
behavior.rt.postgres and xt.db as the
core pair.l/script :xtalk .clj Files Are The Shared Operational Layer.clj
files.l/script :xtalk.xt.dbCanonical substrate for:
rt.postgresxt.dbImportant shared-layer examples:
Canonical reference for:
:db/sync-oriented client updatesReference for:
Reference for:
rt.postgres usageflowchart LR
PG["rt.postgres<br/>entities, functions, policies"]
XDB["xt.db<br/>graph query, pull, sql/cache, sync"]
XT["xtalk .clj modules<br/>shared operational layer"]
LUA["Lua/server output"]
JS["JS/client output"]
PAGE["Page declaration"]
LINK["Dashboard/List link"]
PROJ["Client sqlite / local projection"]
PG --> XDB
PG --> XT
XDB --> XT
XT --> LUA
XT --> JS
JS --> LINK
PAGE --> LINK
LINK --> PROJ
rt.postgres defines canonical database structures and commands.xt.db defines a large part of query, pull, and sync behavior.l/script :xtalk .clj files are the operational layer that connects these
pieces to Lua and JS.Keep the initial entity language mostly PG-compatible.
Primary authoring forms should remain close to:
deftype.pgdefn.pgdefpolicy.pgThe database layer remains the hard truth.
The initial language should work with the existing backbone:
rt.postgresxt.dbl/script :xtalk .clj modulesIntroduce a thin authoring macro such as defentity.pg that:
deftype.pgdefentity.pg should not hide large expansions in macro output.
Instead, it should support code generation of real files.
From entity specs, generators should emit normal source files for:
Later stages should also be able to emit or support:
xt.db-compatible schema/query layersl/script :xtalk .clj operational modulesDo not finalize a large page language yet.
The current stable requirement is only that a page declaration be able to describe:
:db/sync tables/topics it listens toThis page layer should remain above the rt.postgres + xt.db backbone.
Example conceptual form:
(deflink.js Dashboard
{:queries {:summary summary-query
:members members-query}
:actions {:invite-member invite-member!
:remove-member remove-member!}
:listen ["Organisation" "OrganisationAccessRole" "User"]})
This should compile to a plain object spec.
The runtime should stay simple initially.
A compiled link spec should know:
:db/sync tables/topicsThis can later be implemented over l/script :xtalk .clj modules rather
than ad hoc UI glue.
A live link instance should expose a small interface:
{:data {:summary ...
:members ...}
:status :ready ;; or :loading | :acting | :error
:error nil
:load! fn
:set! fn
:act! fn}
load! runs the link's queriesset! changes params/filters and reruns queriesact! calls a named server mutation and marks the link :acting:db/sync triggers reload or refresh:ready:errorTesting must begin with the data/sync contract, not the visual page.
:db/sync testsIf the page is a consumer of synced state, then UI success depends on:
:db/sync deliveryTherefore the page contract must be testable independently of component layout.
The first concrete test target should be a Dashboard link, not a full page UI.
Given:
:db/syncThe test should verify:
:ready:acting:db/sync causes refresh:ready(fact "dashboard link converges from mutation + :db/sync"
(let [link (dashboard-runtime/create
Dashboard
{:organisation-id "org-1"})]
(.load! link)
(:status (dashboard-runtime/state link))
=> :ready
(.act! link :invite-member
{:email "new@example.com"
:role "member"})
(:status (dashboard-runtime/state link))
=> :acting
(dashboard-runtime/apply-sync!
link
{:topic ":db/sync"
:tables ["OrganisationAccessRole" "User"]})
(:status (dashboard-runtime/state link))
=> :ready))
This is the first test shape to stabilize.
The following should remain open for now:
Those can wait until:
rt.postgres / xt.db / :db/sync contract in foundation-base.statstrade-core.defentity.pg authoring model.Dashboard link spec.The current direction is:
:db/sync as the only client sync eventxt.db as a major part of the backbonel/script :xtalk .clj modules as the shared operational layerCan you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |