Collections
Collections are durable document stores. Use them for real records:- contacts
- reports
- bookmarks
- audit logs
- user-owned resources
- scopes (
app,user,owner,session) - CRUD from Python
- direct UI table binding
- sorting, filtering, and pagination hints
Data handlers
Data handlers are named JSON endpoints created with@app.data(...).
Use them when the data is:
- computed on demand
- fetched from an API
- an aggregate over collections
- temporary and not worth storing
Settings
Settings are scoped key-value configuration, not records. Use them for:- user preferences
- toggles and modes
- small numeric or string configuration values
- prompt templates or feature switches
Toggle, TextInput, NumberInput, and Select.
session.data
session.data is lightweight per-conversation state. It is great for:
- wizard progress
- temporary memory
- multi-step conversation context
Choosing the right model
| Need | Best tool |
|---|---|
| Durable records with CRUD and tables | collection |
| Computed or external JSON | data handler |
| User/app configuration | setting |
| Temporary per-chat state | session.data |
Identity and scope
Collections and settings can depend on identity:userfor per-person stateownerfor per-account or per-organization statesessionfor per-conversation state
session.db.
A common pattern
Real apps often use all four layers together:- collection for raw entities
- data handler for summary metrics or joined views
- setting for display preferences
session.datafor transient flow state