Documentation Index
Fetch the complete documentation index at: https://docs.vizochok.com/llms.txt
Use this file to discover all available pages before exploring further.
Multi-Tenant Architecture
VIZOCHOK is a multi-tenant SaaS where each tenant (retailer) gets an isolated environment with their own:- Product catalog and vector embeddings
- AI configuration (LLM model, system prompt, disabled tools)
- API keys (public and secret)
- Webhook endpoints (products, cart)
- Usage limits and billing
- Admin users
Tenant A
- Catalog + Embeddings
- API Keys (pk_, sk_)
- LLM Config (configurable per tenant)
- Webhooks (products, cart)
- Usage Limits + Billing
- Admin Users
Tenant B
- Catalog + Embeddings
- API Keys (pk_, sk_)
- LLM Config (configurable per tenant)
- Webhooks (products, cart)
- Usage Limits + Billing
- Admin Users
Data Flow
The complete data flow from a user message to a response:VIZOCHOK Backend
WS Handler authenticates and checks rate limits. Shopping Agent (LLM + Tools) processes the request using Hybrid Search and Webhook Calls.
Client Backend
VIZOCHOK calls your Products API and Cart API via HTTP webhooks to get live prices and confirm cart operations.
Step-by-Step Flow
- User sends a message via the Widget SDK over WebSocket
- API server authenticates the connection using the API key
- Rate limits are checked at three tiers: per-connection, per-user, per-tenant
- Agent is initialized with tenant config, session state, and user profile
- AI processes the message using a tool-based architecture:
- Search tools: Hybrid search across the product catalog
- Cart tools: Add, remove, update, clear — each calls the client’s webhook
- UI tools: Show products, ask user, show recipe checklist, show meal plan
- Prices are fetched from the client’s backend via the products webhook (server-to-server)
- Cart operations call the client’s cart webhook, which confirms or rejects
- Results stream back to the widget via WebSocket as
text_delta,product_cards,cart_changed, etc. - Session is saved for the next message
What VIZOCHOK Stores vs. What the Client Stores
Understanding the data boundary is critical for integration:VIZOCHOK Stores
| Data | Storage | Purpose |
|---|---|---|
| Product catalog | Database | Names, descriptions, categories, images, SKUs — for search and embeddings |
| Product embeddings | Vector database | Vector embeddings for semantic search |
| Conversation history | Database | Full chat log for analytics and session restore |
| Session state | Cache | Cart, pending tools, conversation context |
| API keys (hashed) | Database | Authentication |
| Tenant configuration | Database | LLM, webhooks, limits, prompts |
| Usage counters | Cache | Rate limiting and billing |
| User profiles | Database | Language, dietary preferences, favorite brands |
Client Stores
| Data | Purpose |
|---|---|
| Product prices | Returned via products_url webhook on demand |
| Product availability | Returned via products_url webhook on demand |
| Shopping cart | Managed via cart_url / cart_get_url webhooks |
| User identity | Passed as userId to the widget |
| Order history | Never shared with VIZOCHOK |
| Payment information | Never shared with VIZOCHOK |
VIZOCHOK intentionally does not store prices or availability. These are always fetched in real-time from the client’s backend via webhooks, ensuring the AI always has current data.
Session Lifecycle
New Connection
- Client sends
authmessage - Server responds with
auth_ok - Server sends
conversation_startedwith newconversation_id - Message loop begins
- On disconnect, session saved server-side
Reconnection
- Client sends
authmessage - Server responds with
auth_ok - Server sends
session_restoredwith cart + pending tools - Message loop resumes
- On disconnect, session saved server-side
Session Details
- Server side: Sessions are cached server-side and expire after a period of inactivity. On reconnect, the server restores cart state and pending tools.
- Client side:
sessionStorage(per-tab) stores conversation ID and message history under keyvz-session-{storeId} - On expiry: After a period of inactivity, the session expires and a new conversation starts
Smart Model Routing
VIZOCHOK uses a dual-model strategy to balance quality and cost:- A complex model handles the first message in each conversation for accurate intent understanding
- A fast model handles subsequent tool-chain iterations for responsive, cost-effective processing
Agent Tool Architecture
The AI agent uses a tool-based architecture where the AI decides which tools to call based on the conversation:Non-Interactive Tools
These tools execute in the background and return results to the AI for further processing:| Category | Description |
|---|---|
| Search | Searches your product catalog using hybrid search |
| Cart | Add, remove, update, clear cart items (via your webhooks) |
| Details | Retrieve detailed product information |
Interactive Tools
These tools render UI in the widget and pause for user input:| Tool | Widget UI |
|---|---|
| Product display | Product cards with quantity steppers |
| Quick replies | Suggestion buttons for the user to choose from |
| Recipe checklist | Checkable ingredient list with submit button |
| Meal plan | Multi-day plan with approve/modify options |
Hybrid Search
Product search combines multiple strategies for high relevance:- Semantic search — understands meaning and intent, not just keywords
- Full-text search — matches exact words and phrases
- Fuzzy matching — handles typos, transliterations, and brand name misspellings
Webhook Architecture
VIZOCHOK uses server-to-server webhooks for all commercial data:- Products webhook — returns prices and stock for requested SKUs
- Cart webhook — confirms cart operations (add, remove, update, clear)
- Cart GET webhook — returns current cart contents at session start
Error Handling
Errors flow through the system as machine-readable codes:- Backend detects error (rate limit, validation, LLM failure)
- Backend sends
{"type": "error", "code": "rate_limit_exceeded"}via WebSocket - SDK maps the code to a localized message using its i18n dictionary
- SDK renders the error in the chat and fires the
onErrorcallback - The host page can handle the error (e.g., show a toast, log to analytics)