Skip to content

How It Works

Each tenant has its own keyspace and data key. Redfly signs staff in with a phone code and TOTP, Solr powers search, and an outbox keeps Redfly’s master database in sync.

Tenancy

The keyspace bubbl_control holds the registry: tenants, tenants_by_subdomain and tenants_by_redfly_tenant. Each tenant record holds its keyspace_name, wrapped_data_key, data_key_version and solr_core.

Tenant keyspaces are named bubbl_<tenant id as 32 hex> and use NetworkTopologyStrategy {<dc>: 3}.

Resolving the tenant on each request

  1. Host subdomain → tenants_by_subdomain → tenant.
  2. The PASETO ten claim must include the tenant’s redfly_tenant.
  3. A TenantContext holds the keyspace, and every Cassandra statement is issued against it.

Provisioning (tenant:admin, under a SunLink lock)

  1. Create the keyspace.
  2. Apply the tenant migrations.
  3. Run the data-migration steps.
  4. Generate a data key and wrap it with OpenBao Transit.
  5. Create the Solr core.
  6. Register the tenant in Redfly.

Sign-in, device sync and roles

  • Users are sent to Redfly sign-in (phone code plus TOTP for staff), then return with a PASETO.
  • RedflyTokenRealm verifies it with Redfly’s public keys, checks the SeaWave revocation deny-list, maps sub to users.redfly_user_id and loads roles from shiro_user_roles.
  • CalDAV, CardDAV and WebDAV use HTTP Basic over TLS with a Redfly app password, verified with Redfly and cached for 5 minutes. They require sync:devices.
RolePermissions
adminEvery permission
editorrecords:read, records:write, files:read, files:write, factsheets:read, search:read, sync:devices
readerrecords:read, files:read, factsheets:read, search:read, sync:devices
auditorThe reader’s permissions plus audit:read

Encrypted fields are decrypted only for callers holding records:read. Otherwise they are returned as null with a redacted: [fields] list.

Data protection

  • Each tenant has an AES-256-GCM data key, wrapped by OpenBao Transit and stored in bubbl_control.tenants. Rotation re-wraps without re-encrypting.
  • Ciphertext format: v<version>:<base64(nonce|ct|tag)>, stored in text columns.
  • Disk encryption on the PVC storage class.
  • Files are encrypted client-side (streaming AES-256-GCM) and stored at s3://<bucket>/bubbl/<tenant>/<storage_key>. Export files are encrypted client-side too.
TableEncrypted columns
clientsDate of birth, personal health number, disability, physician, pharmacy and medication notes, allergies, triggers, warning signs, de-escalation and behaviour support notes, personal history, cached medication list, and substitute decision-maker details
medicationsname, dosage, frequency, route, purpose, prescriber, notes
safety_alertsdetails
emergency_contactsphone_primary, phone_secondary, email, address, notes
intakessigned_ip, signed_user_agent
incidentsactions_taken, injury_details, police_file_number, follow_up_notes
occurrencesclient_presentation, follow_up_notes

incidents.description, occurrences.summary and occurrences.notes are deliberately not encrypted, so they can be searched. They rely on disk encryption.

Change capture for Redfly

  1. Generated writes to the 36 tracked tables put the row, its lookups, its audit row and a redfly_outbox entry in one logged batch.
  2. After the batch commits, Bubbl publishes {tenant, outbox_id} to persistent://odssbc/fairfeather/jobs-outbox-delivery.
  3. FairFeather delivers each entry to Redfly and marks it done through POST /internal/outbox/{id}/delivered (mTLS).
  4. Redfly receives encrypted values as ciphertext and never decrypts them.

Search

One Solr core per tenant, bubbl_<tenant hex>, indexing non-encrypted fields only. Each write publishes to persistent://odssbc/bubbl/index, and every replica consumes it through an Exclusive subscription, bubbl-index-<pod>. search:admin rebuilds a core from Cassandra; queries require search:read.

DocumentIndexed fields
clientFirst, last and preferred name, client identifier, program, residence, key worker, status, tags
contactName and organization fields, tags
documentTitle, folder path and extracted text
incidentIncident number, category, severity, location, occurred at and description
occurrenceOccurrence number, interaction type, purpose, location, topics, occurred at, summary and notes
goalTitle, status and the client

Chat

Messages are written to Cassandra first, then published to persistent://odssbc/bubbl/chat, keyed by <tenant>:<conversation>. Each replica pushes them to its connected browsers over WebSocket at /ws/conversations.

Generated API

One controller per tenant table at /api/v1/<table> (redfly_outbox excluded): GET list (limit default 100, max 500, with a paging-state token), GET by partition key, POST insert with a server-assigned UUIDv7, PUT upsert and DELETE by primary key. Every handler runs in TenantContext, checks @RequiresPermissions, keeps lookup tables up to date with LWT (409 on conflict), applies encryption and redaction, and writes an audit row.

PrefixCovers
recordsClients and their contacts, medications and alerts, intakes, incidents, goals, occurrences, appointments, contacts, spaces, conversations, messages, shared items, record links, tags and activities
filesBlobs, attachments, variants, documents, versions, folders and DAV files
users / rolesusers / Shiro roles, permissions and user roles
announcements / disability_typesannouncements / disability_types
auditaudits (read only)
importimport_runs (import:run for writes, audit:read for reads)

Staff SMS digests

users.digest_frequency takes off, daily or weekly. A scheduled task on Bubbl’s SunLink leader runs at 07:17 in the tenant’s time zone and sends each due staff user counts (new incidents, follow-ups due, unread messages) and a link through Redfly. The SMS contains no client names or record content.

Ports

PortBindPurpose
8446pod IPHTTPS: web UI, generated API, WebDAV/CalDAV/CardDAV, health
7000pod IP, TLSCassandra internode traffic
9042127.0.0.1CQL native (app → embedded Cassandra)
2181127.0.0.1SunLink ZooKeeper protocol (Curator)
7480pod IP, mTLSSunLink Raft ring between replicas
6379127.0.0.1SeaWave RESP (Spring Session, deny-list)
7481pod IP, mTLSSeaWave peer replication

Key environment variables

VariablePurpose
BUBBL_CASSANDRA_DATA_DIR, _DC, _SEEDSEmbedded Cassandra
BUBBL_SOLR_DATA_DIREmbedded Solr (one core per tenant)
BUBBL_REDFLY_URLRedfly base URL (keys, app-password verify)
BUBBL_OPENBAO_ADDR, _TRANSIT_KEYOpenBao Transit key that wraps tenant data keys
BUBBL_S3_ENDPOINT / _BUCKET / _CREDENTIALS_FILEFile storage
BUBBL_PULSAR_SERVICE_URL, BUBBL_SUNLINK_CLUSTERPulsar broker and SunLink peers