Logo Lanfrica

cleven12/chatbot_api

Domain:

natural language processing

Record type:

software
Creator:
cle
Host:
Lightweight multi-tenant RAG API for East African tourism chatbots (safari & trekking operators) # Tourism RAG API + Chat UI Multi-tenant RAG chatbot for East African safari/trek operators. - **API** — Next.js route handlers under `/api/v1/*` - **Client** — chat UI at `/` (deployed together on Vercel) - **DB** — Supabase Postgres + pgvector - **Embeddings** — Gemini `embedding-001` - **LLM** — Groq Llama 3.1 (primary), Gemini fallback --- ## Fix the RLS error first If create-tenant fails with: ```text new row violates row-level security policy for table "tenants" ``` you are almost always using the **anon** key instead of the **service_role** key. 1. Open Supabase → **Project Settings** → **API** 2. Copy **`service_role`** (secret) — not `anon` / `public` 3. Put it in `.env` as `SUPABASE_SERVICE_KEY` 4. Run SQL in Supabase SQL editor: - `supabase/migrations/0001_init.sql` (if not already) - `supabase/migrations/0002_fix_rls.sql` Restart the app after updating `.env`. --- ## Local setup (Vercel / Next.js) ```bash # clean old Netlify deps if you installed them earlier rm -rf node_modules package-lock.json npm install cp .env.example .env # fill SUPABASE_* (service_role!), GEMINI_*, GROQ_*, ADMIN_API_KEY npm run dev ``` Open: - UI: localhost - Health: localhost --- ## Deploy with Vercel CLI ```bash # one-time npx vercel login # link project + set env vars when prompted, or: npx vercel env add SUPABASE_URL npx vercel env add SUPABASE_SERVICE_KEY npx vercel env add GEMINI_API_KEY npx vercel env add GROQ_API_KEY npx vercel env add ADMIN_API_KEY # preview npx vercel # production npx vercel --prod # or: npm run deploy ``` In the Vercel dashboard you can also paste the same env vars under **Settings → Environment Variables**. --- ## Bootstrap a tenant ```bash # 1) Create tenant (save api_key — shown once) curl -s -X POST localhost \ -H "Content-Type: application/json" \ -H "x-admin-key: $ADMIN_API_KEY" \ -d '{ "name": "Serengeti Trails", "system_prompt": "You are a helpful safari …