# Buildx — Full documentation bundle > Buildx is a self-hosted, MIT-licensed AI chatbot builder. Bots run on Google Gemini 2.5 and Qdrant vector search. Embed via a single ` ``` Paste before the closing `` tag of your site. ### What gets injected - A floating launcher button at `bottom-right` by default (positionable per bot via theme). - A hidden iframe-container that loads `/share/[publicId]?embed=true` when the launcher is clicked. - All sizing, colors, icons, and shadows are driven by the saved theme — no `data-*` attributes to set on the script tag. ### Allowed domains By default a bot is embeddable anywhere. To restrict it, add hostnames to Security → Allowed Domains in the bot editor. The check runs server-side both on the public config endpoint and on every chat request. ### Mobile Below 480px viewport width, the iframe expands to fill the screen automatically. The launcher remains in its configured corner. ### Local testing Embed against `http://localhost:3000/embed.js` while developing. The `/share/*` route sets `frame-ancestors *` in CSP so it works inside an iframe on any host. --- ## API reference Public, CORS-enabled endpoints used by the embed widget — and available to your own integrations. ### POST /api/chat Stateless. Rate-limited (default 20 requests per 60 seconds per IP). CORS `*`. ```bash curl -X POST https://your-buildx-domain.com/api/chat \ -H "Content-Type: application/json" \ -d '{ "botId": "PUBLIC_ID", "message": "Hello", "history": [], "conversationId": "" }' # Response # { "message": "...markdown text...", "model": "gemini-2.5-flash", "leadCaptured": false } ``` ### GET /api/bots/public/[publicId] Returns the renderable bot config — no auth required. CORS `*`. ```json { "config": { "publicId": "...", "name": "...", "theme": { }, "widgetPosition": "bottom-right", "allowedDomains": [], "isActive": true } } ``` ### GET /api/health Liveness and service connectivity. No auth. ```json { "status": "healthy", "uptime": 123.4, "timestamp": "...", "services": { "database": { "status": "up", "latency": 12 }, "gemini": { "status": "configured" } } } ``` ### Domain enforcement `/api/chat` uses substring match against Origin/Referer. `/api/bots/public/[publicId]` uses stricter hostname match. If you whitelist `example.com`, requests from `example.com.evil.tld` may pass `/api/chat` — keep the list tight. --- ## Troubleshooting ### Bot returns generic answers and ignores my uploaded docs Check Settings → Qdrant connection (Test button). The chat handler logs RAG errors to the server console but continues without context — so the bot keeps replying, just without your knowledge. Verify the collection name matches and the API key isn't stale. ### Embed snippet doesn't show a launcher Open the host site's devtools console. Look for `Bot CMS:` errors. Common causes: 1. The public ID is wrong. 2. The bot is marked inactive. 3. Allowed Domains doesn't include this host. ### Lead capture isn't firing Verify the Tools tab toggle is on AND the system prompt fragment is appended (open the bot in design studio — the live preview shows it). Required fields must all be present. The model only calls `capture_lead` after detecting clear intent — try saying "I want a demo, my email is x@y.com". ### Theme changes save but don't appear on the live widget Browser caching. Hard-refresh the host page — `embed.js` is served with no cache-busting by default. The iframe content updates without caching since it loads `/share/[publicId]` fresh each open. ### "Rate limit exceeded" on chat Default is 20 requests per 60 seconds per IP. Behind a proxy, ensure `x-forwarded-for` is set correctly — without it, all traffic shares one bucket. ### API keys stored in plaintext warning in logs Set `ENCRYPTION_KEY` in your environment (64-character hex string). After setting, save the key in Settings again — it'll be encrypted on write. --- ## Tech stack | Layer | Technology | |---|---| | Framework | Next.js 16 (App Router) | | Runtime | React 19 | | Language | TypeScript | | Auth | NextAuth v5, credentials provider (single-admin) | | Database | MongoDB via Mongoose | | LLM | Google Gemini 2.5 (Flash / Pro / Flash Lite) | | Vector DB | Qdrant, 768-dim cosine | | Document parsing | unpdf (PDF), mammoth (DOCX) | | Embedding | Gemini, 768 dimensions | | Encryption | AES-256-GCM | ## License MIT. See https://github.com/MayonLabs/buildx/blob/main/LICENSE. ## Repository https://github.com/MayonLabs/buildx ## Issues and feature requests https://github.com/MayonLabs/buildx/issues