Elixir umbrella
The four umbrella apps in platform/ and what each owns.
platform/ is one Mix umbrella. mix release cardinal builds the release every node runs. The core and gate apps join the umbrella through symlinks in platform/apps/.
| App | Owns | Depends on |
|---|---|---|
cardinal_core | The kernel: NIF bridge, Repo, tenants, transactions, metadata, records, permissions, auth, secrets, files, templates, PDFs | Rustler, Ecto, Postgrex, Argon2 |
cardinal_web | HTTP and realtime: the router, the record and RPC API, the desk and website, the WebSocket | cardinal_core, cardinal_jobs, Phoenix, Bandit |
cardinal_jobs | Background jobs on Oban, mail, the scheduler, webhooks, automations' engine | cardinal_core, Oban |
cardinal_cli | The dev cardinal commands as mix cardinal | All of the above |
core | Symlink to apps/core, the core app | |
gate | Symlink to apps/gate, only in dev, test and CARDINAL_DEV_BUILD=1 builds |
cardinal_core
| Module | Role |
|---|---|
CardinalCore.Native | The Elixir side of the cardinal_nif library |
CardinalCore.Repo | The Ecto Postgres repo |
CardinalCore.Release | Commands for bin/cardinal eval in a release |
Cardinal.* | The public app contract: Cardinal.App, Cardinal.DB, Cardinal.Rpc, Cardinal.ApiRoute, Cardinal.Realtime, Cardinal.Test and others |
services/ | One module per operation: TxnService, TenantService, MetaService, RecordService, PermService, AuthService, SecretService, FileService, TemplateService, PdfService, RpcService and more |
workers/ | MetaCacheWorker (the ETS table of compiled metadata), SandboxSlotsWorker (template sandbox slots), HeartbeatWorker (the node's row in platform.nodes) |
priv/migrations/platform/ | The shared platform schema: tenants, sealed data keys, meta_version_seq, claimed_at, nodes |
priv/migrations/tenant/ | Base tables every site schema gets |
cardinal_web
| Module | Role |
|---|---|
CardinalWeb.Endpoint | Phoenix on Bandit. The realtime socket, then the router |
CardinalWeb.Router | Plugs, auth, setup, boot and static files |
CardinalWeb.Api | Records, meta, RPC, files, print and desk endpoints |
CardinalWeb.Website | Every other path, through WebsiteService |
CardinalWeb.AppFrontend | An app's own frontend at /<mount>/ |
CardinalWeb.Plugs.Identity, Plugs.Errors | The Ctx for each request, and the 500 handler that writes an Error Log |
CardinalWeb.RealtimeSocket, RealtimeChannel | Socket connect and topic joins |
RealtimeListenerWorker | The node's LISTEN cardinal_realtime |
Bandit listens only when the node serves HTTP: CARDINAL_ROLE is web or all, or under cardinal start.
cardinal_jobs
Jobs are inserted in the caller's transaction, stamped with the site, user and request id. They run in their site's transaction as that user. See Background jobs.
Apps reach it through the part of the contract in cardinal_jobs/lib/cardinal/:
| Module | Does |
|---|---|
Cardinal.Jobs.enqueue/4 | Insert a job in the caller's transaction |
Cardinal.Mail.send/2 | Queue a mail |
Cardinal.Push.send/3 | Queue a Web Push to each of a user's browsers |
Cardinal.SMS.send/3 | Queue an SMS through SMS Settings |
Cardinal.Telegram | Send to a User's linked Telegram chat |
Cardinal.Automation | The step catalog, save checks, and resuming a waiting step |
cardinal_cli
Mix.Tasks.Cardinal dispatches every command in the CLI reference. Its services do the work:
| Service | Commands |
|---|---|
WorkspaceService | init, finding the workspace, starting its services, the environment it passes |
ScaffoldService | app new |
AppGetService | app get, app remove, the pull step of update |
AppFrontendService | Desk plugins and app frontends for build and app build |
BuildService | build/build.json |
ReleaseService | build --target release |
I18nService | i18n extract, new, update |
PerchService | perch get, perch |
priv/templates/ holds what app new --with-frontend writes and the workspace Dockerfile template.