Frontend architecture
How the web app is put together, from the route tree and the app shell to feature areas, data fetching, the sign-in guard, live Inbox updates, reloading after a deploy and tests.
The frontend is a single-page app built with React 19, Vite 8, TypeScript, Tailwind CSS 4 and React Router 7. Data from the server lives in a TanStack Query cache. The only client-side stores are the signed-in session and the campaign builder’s working copy of a flow. The build is a folder of static files that nginx serves.
The browser loads one small HTML page and the app's entry code. The app sets up the data cache, the sidebar state and toasts, and starts watching for page code that a deploy has removed.
Routes
One route tree covers the app:
| Branch | Holds |
|---|---|
| Public | The marketing landing page, accepting an invite, sign-in and sign-up |
| Signed in, inside the app shell | Home, Inbox, People, Deals, Campaigns, Templates, AI Agent, Reports, Tasks, Settings |
| Signed in, full screen | The onboarding wizard |
| Redirects | Old addresses from before the redesign, sent to their new pages with the query string and anchor kept |
| Anything else | Sign-in |
Every signed-in page sits under one app shell route, so the sidebar, the top bar and the ⌘K palette stay mounted while the user moves between pages. The landing page, sign-in, People, Campaigns with Templates, AI Agent and Settings each have a route file of their own, which the root tree includes.
Loading code
Each page’s code loads the first time someone opens it, behind a short loading message, and the app shell loads the same way. Large libraries that broke when the bundler split them into small pieces (the email editor stack and the animation library) are kept as one piece each; the rest of the vendor code is split into mid-size chunks.
Icons are bundled offline: the build scans the source for icon names and includes only those. An icon name has to be written out in full in the source; a name assembled at run time is not bundled and renders blank.
Feature areas
Product code is grouped by area: Inbox, people and companies, campaigns, templates, deals, tasks, AI agent, reports, settings, onboarding and so on. An area holds, side by side:
- its API calls, which also turn backend shapes into frontend types;
- its query hooks and the key list they use;
- its pages, one per screen, and its components;
- pure helper logic, with tests beside it.
Code shared by every area sits outside them: the component kit and the shared app components (see Design system and forms), utilities, hooks and the two stores.
Data fetching
A page asks its area's query hook for data. If the cache already holds a fresh answer for the same key, the page gets it at once.
A query parameter with several values is sent as the same parameter repeated, because the backend ignores the bracket form. Error toasts show the first message the backend returned, or a fallback.
Sign-in guard
Before any signed-in page renders, the guard looks for an access token in the browser’s storage. Without one it sends the visitor to sign-in, remembering the page they asked for. With one it loads the user’s profile and renders nothing until the profile is in. The workspace comes from the token itself, and the guard checks no roles.
Live Inbox updates
The backend pushes Inbox activity as a server-sent event stream, which only the Inbox page opens. The browser’s built-in event stream client cannot send an authorization header, and a token in the address would end up in proxy logs, so the app reads the stream with an ordinary authenticated request and parses the events itself.
A message arrives, a reply is sent, or the agent calls a tool on a person's conversation.
Periodic pings keep the connection open. When it drops anyway, the app reconnects after 1, 2, 5 and then 10 seconds, and when the stream answers with a 401 it refreshes the token before reconnecting.
Reloading after a deploy
A tab opened before a deploy still runs the old code, which asks for page chunks the new build has deleted. Two places catch the failed load: a listener for chunks that the bundler preloads, and the top-level route error page, which recognises the error messages of Chrome, Firefox and Safari.
Either one reloads the page and notes the time in the tab’s session storage. A second failure within 30 seconds does not reload again; the error page offers Reload and Go to Home instead. Any other route error shows the same page with “Something went wrong”.
The reload picks up the new build because nginx tells browsers not to cache the HTML page, and to cache the hashed asset files for a year.
Tests
Unit tests cover pure logic only, for example flow check messages, settings form grouping and variable chips in the campaign builder, Inbox timeline items, snooze, recipient checks, cache helpers, report helpers, token parsing and the reload after a deploy. No test renders a component; type checking and manual checks cover components. Tests that touch browser globals replace them with stubs.
bun run test