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
- Host subdomain →
tenants_by_subdomain→ tenant. - The PASETO
tenclaim must include the tenant’sredfly_tenant. - A
TenantContextholds the keyspace, and every Cassandra statement is issued against it.
Provisioning (tenant:admin, under a SunLink lock)
- Create the keyspace.
- Apply the tenant migrations.
- Run the data-migration steps.
- Generate a data key and wrap it with OpenBao Transit.
- Create the Solr core.
- 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.
RedflyTokenRealmverifies it with Redfly’s public keys, checks the SeaWave revocation deny-list, mapssubtousers.redfly_user_idand loads roles fromshiro_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.
| Role | Permissions |
|---|---|
admin | Every permission |
editor | records:read, records:write, files:read, files:write, factsheets:read, search:read, sync:devices |
reader | records:read, files:read, factsheets:read, search:read, sync:devices |
auditor | The 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 intextcolumns. - 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.
| Table | Encrypted columns |
|---|---|
clients | Date 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 |
medications | name, dosage, frequency, route, purpose, prescriber, notes |
safety_alerts | details |
emergency_contacts | phone_primary, phone_secondary, email, address, notes |
intakes | signed_ip, signed_user_agent |
incidents | actions_taken, injury_details, police_file_number, follow_up_notes |
occurrences | client_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
- Generated writes to the 36 tracked tables put the row, its lookups, its audit row and a
redfly_outboxentry in one logged batch. - After the batch commits, Bubbl publishes
{tenant, outbox_id}topersistent://odssbc/fairfeather/jobs-outbox-delivery. - FairFeather delivers each entry to Redfly and marks it done through
POST /internal/outbox/{id}/delivered(mTLS). - 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.
| Document | Indexed fields |
|---|---|
| client | First, last and preferred name, client identifier, program, residence, key worker, status, tags |
| contact | Name and organization fields, tags |
| document | Title, folder path and extracted text |
| incident | Incident number, category, severity, location, occurred at and description |
| occurrence | Occurrence number, interaction type, purpose, location, topics, occurred at, summary and notes |
| goal | Title, 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.
| Prefix | Covers |
|---|---|
records | Clients and their contacts, medications and alerts, intakes, incidents, goals, occurrences, appointments, contacts, spaces, conversations, messages, shared items, record links, tags and activities |
files | Blobs, attachments, variants, documents, versions, folders and DAV files |
users / roles | users / Shiro roles, permissions and user roles |
announcements / disability_types | announcements / disability_types |
audit | audits (read only) |
import | import_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
| Port | Bind | Purpose |
|---|---|---|
| 8446 | pod IP | HTTPS: web UI, generated API, WebDAV/CalDAV/CardDAV, health |
| 7000 | pod IP, TLS | Cassandra internode traffic |
| 9042 | 127.0.0.1 | CQL native (app → embedded Cassandra) |
| 2181 | 127.0.0.1 | SunLink ZooKeeper protocol (Curator) |
| 7480 | pod IP, mTLS | SunLink Raft ring between replicas |
| 6379 | 127.0.0.1 | SeaWave RESP (Spring Session, deny-list) |
| 7481 | pod IP, mTLS | SeaWave peer replication |
Key environment variables
| Variable | Purpose |
|---|---|
BUBBL_CASSANDRA_DATA_DIR, _DC, _SEEDS | Embedded Cassandra |
BUBBL_SOLR_DATA_DIR | Embedded Solr (one core per tenant) |
BUBBL_REDFLY_URL | Redfly base URL (keys, app-password verify) |
BUBBL_OPENBAO_ADDR, _TRANSIT_KEY | OpenBao Transit key that wraps tenant data keys |
BUBBL_S3_ENDPOINT / _BUCKET / _CREDENTIALS_FILE | File storage |
BUBBL_PULSAR_SERVICE_URL, BUBBL_SUNLINK_CLUSTER | Pulsar broker and SunLink peers |