Backend
What the backend is made of, how its modules split the work, and the pieces they all share: workspace scoping, roles, the event bus, scheduled jobs, the live Inbox stream and encrypted account secrets.
The backend is one server process. It serves the JSON API the app calls, receives webhooks from the channel providers, answers the tracking links inside emails, runs scheduled jobs and works through background events. Everything it stores lives in one Postgres database, which also holds the vectors used for Knowledge search. Campaign runs are executed by Restate, a durable workflow engine that runs as its own service and calls back into the backend for each step. Files go to local disk or to S3.
Ways in
Feature modules
Shared foundation
Hover or tap a box to see what it does.
Modules
| Module | Responsible for | Details |
|---|---|---|
| Accounts and sign-in | Users, workspaces, members, invites, connected accounts, workspace settings, tokens | Auth and accounts |
| CRM | People, channel identities, companies, audiences, deals, tasks, notes, tags, the Unassigned pool, import and export, Inbox threads, Home’s Today list, lead research, meeting booking | CRM |
| Content | Products, Knowledge documents and their search, templates, email images | Content and knowledge |
| Channel clients | Sending and receiving on email, LinkedIn, Telegram and Zalo | Channels |
| AI agent | The reply agent, the Ask agent and their tools | AI agent |
| Campaign engine | Campaigns, triggers, runs and the workflow for each person | Automation |
| Analytics | Events, tracking links, delivery notices, the Reports queries | Analytics and tracking |
| Outside apps | Slack notifications and the one-way HubSpot and Salesforce import | Channels |
Dependencies point one way. Accounts sit at the bottom, content and CRM build on accounts, the agent and the campaign engine build on CRM and content, and analytics builds on the campaign engine and CRM. Work that travels the other way, such as an inbound message that the channel clients receive and CRM and the agent handle, goes over the event bus.
Workspace scoping
Each access token names one workspace, and every service adds that workspace to each read and write it runs. No central filter or database rule does this for them. A record that belongs to another workspace answers exactly like a missing one, with a 404. Before a write links records by id (adding people to an audience, tagging people in bulk), the ids are first narrowed to those the workspace owns.
A new endpoint that leaves the workspace out of one query can read or change another workspace’s data, and nothing outside that query catches it.
Some data is shared on purpose:
- A user is a login for the whole installation and can be a member of several workspaces.
- A channel identity (an email address, a LinkedIn profile, a Telegram user) is stored once and linked to the person in each workspace that has it. Its opt-out state is shared with it.
- Companies without a workspace form a read-only global pool that every workspace sees. Only the system writes to it.
Roles
A member is an owner or a member. Owners alone can rename the workspace, change a member’s role, remove a member, manage invites, and edit or delete other people’s notes. Every other action is open to any member, including connecting or deleting channels and AI accounts, changing how the agent behaves and deleting people in bulk. Users also carry a platform-wide admin flag in their token, and nothing checks it.
Event bus
Modules hand work to each other as events. The bus is durable: each delivery is a row in Postgres, so an event survives a restart and a failed handler is retried.
The publisher names a topic and a payload. An event on a topic nobody subscribes to is dropped with a warning in the log.
The events that carry most of the work:
| Event | Raised when | Handled by |
|---|---|---|
| Inbound message | A webhook or a mailbox read receives a message | CRM, which writes the thread message and hands it to the agent |
| Outbound message | Anything sends a message | CRM (timeline entry) and analytics (send event) |
| Reply, debounced 2 s per person | An inbound message is recorded | Analytics, for reply attribution |
| Account connected | LinkedIn hosted sign-in finishes | Accounts, which saves the LinkedIn account |
| CSV import | A file is uploaded on People | The import worker |
| Document ingest | A Knowledge document is added or needs new vectors | The Knowledge pipeline |
| Embedding model changed | The workspace picks another embedding model | Re-embedding of documents and lead memories |
| Tracking | An open, click or unsubscribe arrives | Analytics, and the engagement part of the fit score |
| Bounce | A mailbox read finds a bounce report | CRM, which opts the address out |
| Notify | A hand-off to a person, a Draft held for review, a won deal, a campaign reply | Slack |
The handlers for the inbound message, the Knowledge ingest and the outbound timeline entry catch their own errors and log them. The bus sees success and never retries those, so an inbound message that fails halfway is lost.
Scheduled jobs
| Job | How often |
|---|---|
| Read IMAP mailboxes | Every 60 seconds |
| Fire campaign schedule triggers | Every 30 seconds |
| Run queued lead research | Every 10 seconds |
| Import from HubSpot or Salesforce | Checked every 5 minutes; each account has its own interval |
| Drop idle agent sessions | Every 5 minutes |
| Analytics daily rollup | 01:00 server time |
Every backend instance runs every job. The jobs that must not run twice at once take a lease row in Postgres or claim their rows with a conditional update.
Cache and locks
Compose runs a Redis container and the configuration requires its address, but nothing in the backend connects to it. The only cache is in the memory of each process; it keeps one AI provider client per connected AI account. Locks between instances are lease rows in Postgres that expire on their own.
Live inbox stream
The Inbox updates live over a server-sent events stream for the user’s workspace.
- Every timeline entry the backend writes (a message in either direction, a draft, a tracking event, an agent tool call) pushes a small notice, except the read, snooze, close and reopen markers of the Inbox. The notice goes to the open streams of that workspace: ids, type, channel, direction and a summary. The client then refetches the thread over the normal API.
- A ping goes out every 25 seconds.
- The stream closes when an owner removes the user from the workspace.
- The browser’s built-in event source cannot send the token header, so the app reads the stream with a plain fetch and reconnects after 1, 2, 5 and then every 10 seconds.
The notices live in the memory of one process. With two backend instances, a user connected to one of them does not see activity written by the other.
Configuration and errors
The configuration is checked when the backend starts. A missing or malformed value stops the start with one line per problem. Each domain error has an HTTP status, a stable code, a message and a retryable flag that campaign steps read to decide whether to try again. The response shape is on API conventions.
File storage
Files go to local disk or to an S3 bucket, chosen by configuration. The backend stores three kinds: Knowledge files, CSV imports with their error reports, and images uploaded for emails.
Secrets at rest
The stored data of a connected account, which holds its passwords, API keys and bot tokens, is encrypted with AES-256-GCM as it is written to the database and decrypted when it is read, by a layer under every query, so services never handle ciphertext. The key comes from configuration; when it is missing, the backend derives one from the token-signing secret and logs a warning. At start, rows still in plain text are encrypted and rows under the previous key are re-encrypted with the current one, which is how a key is rotated.