Core Concepts
Understanding the architecture and key ideas behind Produck SDK.
Architecture Overview
Produck SDK connects your frontend with an AI backend to create intelligent website experiences.
βββββββββββββββββββββββββββββββββββββββββββββββ
β Your Website β
β β
β βββββββββββββββ βββββββββββββββββββββββ β
β β Chat Widget β β SDK Core β β
β β (UI) β β - DOM Extractor β β
β β β β - API Handler β β
β ββββββββ¬ββββββββ ββββββββββββ¬βββββββββββ β
β β β β
βββββββββββΌββββββββββββββββββββββΌβββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Produck Backend β
β β
β ββββββββββββ βββββββββββββ ββββββββββββ β
β β Chat API β β Knowledge β β API β β
β β (GPT-4o) β β Base β β Proxy β β
β β β β (Qdrant) β β β β
β ββββββββββββ βββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββKey Components
1. SDK Projects
SDK Projects are the top-level organizational unit.
- Belong to an organization
- Have a unique SDK key for authentication
- Configure knowledge base, API schema, and DOM context
- Independent from each other
2. Knowledge Base
The knowledge base stores information about your product as vector embeddings.
Sources:
- Website URLs (crawled via Firecrawl)
- Sitemaps
- Uploaded documents (PDF, DOCX, TXT)
- Raw text
Retrieval: When a user asks a question, the backend performs vector search to find relevant content and injects it into the AI's context.
3. API Schema
Provide an OpenAPI/Swagger schema and the AI can understand and execute your API endpoints.
Flow:
- SDK loads schema on init
- Endpoint summaries are sent with each chat message
- AI identifies the right endpoint when the user requests an action
- SDK executes the call (client-side or via proxy)
- Result is returned to the AI for confirmation
Security: Only whitelisted endpoints can be called.
4. DOM Context
The AI can read the current page on demand to answer page-specific questions.
Key design decisions:
- On-demand only β content is never sent automatically
- Selector scoping β control what the AI can read
- No persistence β extracted content is used once and discarded
5. Chat Widget
A pre-built, customizable chat interface that handles:
- Message display and input
- Typing indicators
- API call result rendering
- Mobile responsiveness
- Theme customization
Authentication Model
SDK Key (Public)
The SDK key identifies your project. It's safe to embed in client-side code.
<ProduckProvider sdkKey="pk_live_..." />API Authentication (Private)
For API calls, authentication is handled separately:
| Type | How It Works |
|---|---|
| Cookie | Browser cookies sent automatically (same-origin) |
| Bearer | Token added to Authorization header |
| API Key | Custom header added to requests |
Data Flow
Chat Message Flow
1. User types message
2. SDK optionally extracts DOM context (if AI requests it)
3. Message + context sent to backend
4. Backend retrieves relevant knowledge base chunks
5. Backend builds AI prompt with: message + knowledge + API schema + DOM context
6. GPT-4o generates response
7. If response contains API call β SDK executes it β result sent back
8. Final response displayed to userAPI Call Flow
1. AI identifies needed API call from schema
2. SDK checks endpoint against whitelist
3. SDK attempts client-side fetch
4. If CORS error β SDK retries via server proxy
5. Result returned to AI for confirmation messageNext Steps
- Getting Started β Set up your first project
- Knowledge Base β Teach the AI
- API Schema β Enable API actions
- Security β Understand the security model