Cartesiandocs

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 · suggestions
text

CartesianClient

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 buttonCartesianPanelHost + CartesianAskButton
Open the assistant from non-Compose codeCartesian.present(context)
Put the assistant inside a tab or screenCartesianChat()
Keep the layout but restyle piecesCartesianSlots + CartesianComponents
Build a completely custom UIcartesian-core only

Names on each platform

ConceptAndroidiOSReact
Core packagecartesian-coreCartesianCore@cogitx/cartesian-react/core
UI packagecartesian-uiCartesianUI@cogitx/cartesian-react
Set up onceCartesian.initialize(context, config, options)Cartesian.configure(config, options:)new CartesianClient(config) + <CartesianProvider>
ClientCartesianClientCartesianClientCartesianClient
ControllerrememberCartesianChatController()CartesianChatControlleruseCartesian()
PanelCartesianPanelHost + rememberCartesianPanelState().cartesianPanel(state) + CartesianPanelState<CartesianPanel> + useCartesianPanel()
Embedded chatCartesianChat()CartesianChatView()<CartesianChat>
TriggersCartesianAskButton, CartesianAskBarCartesianAskButton, CartesianAskBar<CartesianAskButton>, <CartesianAskBar>
Host callbacksCartesianListenerCartesianDelegate (held weakly)CartesianListener object
Your cart stateCartesian.host.setCart(...)Cartesian.host.setCart(...)CartesianHostState.setCart(...)
Default componentsCartesianComponentsCartesianComponentsCartesianComponents
Token storagePrivate SharedPreferencesKeychainlocalStorage