Get started
Core concepts
The five objects you work with, and which layer to use for which job.
Every SDK has the same two layers: a core that handles the network, sessions and chat state, and a UI kit built on top of it. You can use the UI, or only the core. The examples on this page use Android names; the table at the end maps them to iOS and React.
your app
├─ CartesianPanelHost / CartesianAskButton / CartesianChat ← cartesian-ui
│ └─ CartesianChatController (UI state + actions, per screen)
└─ CartesianClient ← cartesian-core (one per app)
├─ authState · connection · cart · wishlist · threads (StateFlow)
└─ ChatSession: state · events · suggestionstextCartesianClient
There is one client per app, created by Cartesian.initialize. It owns the session token, the REST calls and the WebSocket to your backend, and it exposes everything as StateFlow. It reconnects with backoff, keeps the session through network failures, and signs out only when the backend returns 401. See the CartesianClient reference.
ChatSession
client.chat turns the backend's streaming frames into one immutable ChatState: the messages, the agent steps, the products shown and the cart updates. It also emits ChatEvents for analytics. It is the same reducer the web app uses, and it is checked against recorded sessions. See the ChatSession reference.
CartesianChatController
The controller is a Compose-side object that holds the screen's state, such as the draft text, the open drawer, offline status and suggestions, and the actions: send, stop, addToCart, openCart and so on. Actions are routed according to your feature modes. Every built-in component takes the controller, so any replacement you write gets exactly the same powers. See the CartesianChatController reference.
CartesianOptions
CartesianOptions is the presentation config: theme, title, starters, features, slots and strings. You set it once in Cartesian.initialize, or you can pass a different one to a single surface.
Panel and launchers
CartesianPanelHost wraps your screen and decides how to show the assistant on the current device. CartesianPanelState opens and closes it. CartesianAskButton and CartesianAskBar are ready-made triggers, and you can call state.open() from anything else.
Choosing a layer
| You want to… | Use |
|---|---|
| Ship fast with a floating button | CartesianPanelHost + CartesianAskButton |
| Open the assistant from non-Compose code | Cartesian.present(context) |
| Put the assistant inside a tab or screen | CartesianChat() |
| Keep the layout but restyle pieces | CartesianSlots + CartesianComponents |
| Build a completely custom UI | cartesian-core only |
Names on each platform
| Concept | Android | iOS | React |
|---|---|---|---|
| Core package | cartesian-core | CartesianCore | @cogitx/cartesian-react/core |
| UI package | cartesian-ui | CartesianUI | @cogitx/cartesian-react |
| Set up once | Cartesian.initialize(context, config, options) | Cartesian.configure(config, options:) | new CartesianClient(config) + <CartesianProvider> |
| Client | CartesianClient | CartesianClient | CartesianClient |
| Controller | rememberCartesianChatController() | CartesianChatController | useCartesian() |
| Panel | CartesianPanelHost + rememberCartesianPanelState() | .cartesianPanel(state) + CartesianPanelState | <CartesianPanel> + useCartesianPanel() |
| Embedded chat | CartesianChat() | CartesianChatView() | <CartesianChat> |
| Triggers | CartesianAskButton, CartesianAskBar | CartesianAskButton, CartesianAskBar | <CartesianAskButton>, <CartesianAskBar> |
| Host callbacks | CartesianListener | CartesianDelegate (held weakly) | CartesianListener object |
| Your cart state | Cartesian.host.setCart(...) | Cartesian.host.setCart(...) | CartesianHostState.setCart(...) |
| Default components | CartesianComponents | CartesianComponents | CartesianComponents |
| Token storage | Private SharedPreferences | Keychain | localStorage |