Channels are a fundamental part of the Couchbase database, engineered for high-availability and high-reliability.
Each document in the Couchbase database has an array of channels, which are simple text strings. Each user registered on the system also has an array of channels. On mobile devices Couchbase Sync Gateway provides an efficient mechanism which works out which documents need to be pushed to the device, filtering by the channels which the user is allowed to see. On the API, and therefore on the browser, Whitespace code filters lists of documents using the same logic.
For the Whitespace platform, we implement channels as follows:
- We have a “public” channel which all users can see, for reference data.
- Each team at a broker or carrier has its own channel; this is in the form (companyID)_(teamID) giving rise to values like “priceforbes_MARINEHULL” or “neon_PROPERTY”. Most of the system data has the team channels for the parties working on that risk.
- Lastly, each user has a channel with a unique value of the form MU(guid) giving a value like “MU8DFCE4B7-0728-4CB8-A466-298106298870”. This channel is used for tracking what the user has seen, so that badges can indicate what they have not seen.
The operation of the system depends on documents being created with specific channels, documents having channels added to them, or being cloned into new documents with a new set of channels. For instance:
- Broker creates new draft: a single channel which is the broker’s team.
- Broker shows draft to a carrier: the risk document is cloned, to have two channels – one for the broker, one for the carrier.
- Underwriter sends a chat message: the chat document is created with two channels – one for the broker, one for the carrier.
All the logic for creating, adding or cloning channels is in a business-layer software library developed in Swift, which is shared by the iOS app and the API. This allows us to test and demonstrate the logic, and then use it consistently across the platform.
Users are assigned to customer teams by the admin portal which centralises and automates the assignment of team channels, enforcing uniqueness and the association of channel to company.