๐ง KnowBase AI
June 16, 2026 ยท View on GitHub
Build custom AI chatbots trained on your documents, URLs, and Q&A data โ with citations, embed widgets, and real-time conversations. A production-ready, self-hostable Next.js SaaS boilerplate with semantic context retrieval and iframe-embeddable bots. A free open-source alternative to Chatbase, CustomGPT, Botpress, SiteGPT, and Stack AI โ powered by the MuAPI AI engine.
Tech stack: Next.js 14 (App Router) ยท Prisma ยท PostgreSQL ยท NextAuth (Google OAuth) ยท Stripe ยท Tailwind CSS ยท MuAPI ยท RAG / semantic retrieval ยท OpenAI Use cases: Customer support automation ยท Internal documentation Q&A ยท Sales lead qualification ยท Documentation chatbots ยท Course/training assistants ยท SaaS help bots ยท Knowledge management ยท Onboarding assistants ยท Embeddable site chat widgets
๐ Project Details
GitHub Repository: github.com/SamurAIGPT/ai-knowledge-base
Live Demo Preview: ai-knowledge-base-six.vercel.app
๐ธ Studio Workspace Preview

KnowBase AI is a production-ready, highly-optimized AI web application. Out of the box, it seamlessly manages User Authentication, Credits & Billing, Custom Document Persistence, semantic keyword-matched context retrieval, and AI generation using Next.js (App Router) architecture. It empowers businesses, developers, and creators to build custom chatbots with specific datasets.
Why use KnowBase AI?
- Production-Ready SaaS โ Complete with Google OAuth and Stripe Checkout workflows built-in.
- Custom Knowledge Builder โ Create sandbox bases, load web URLs, custom text files, or write Q&A entries.
- High-Contrast Playground โ Chat dynamically with custom bots showing exact reference matches and citation sources below dialogue bubbles.
- Embeddable Widgets & API Access โ Generate iframe scripts to embed customized chatbots directly on third-party blogs or landing pages.
- Responsive Screen-Fitting โ Dynamic viewports stacked as clean scrolling components on mobile and locks screen height on desktop for premium desktop UX.
โจ Core Features
๐จ Custom Knowledge Sandboxes (Main Page /)
- Sandboxes list sidebar with modal trigger to forge new custom RAG spaces.
- Cost: Free (0 credits) per Knowledge Base created.
๐๏ธ Multi-Source Trainer
- Scrap URL: Submit document links, scrap site contents, and index automatically.
- Add Q&A: Custom type precise matching prompts and answers.
- Upload File: Insert custom raw documents data.
- Cost: 10 credits per source trained.
๐ฌ Dialogue Playground
- Natural dialogue balloon interface with real-time semantic context injection.
- Expandable citation logs referencing matching sources and snippet previews.
- Cost: 2 credits per chatbot query.
๐ณ Stripe Credit Billing (/pricing)
- Four credit packs based on a $1 = 200 credits conversion rate:
- Basic Pack ($5 / 1,000 credits)
- Standard Pack ($10 / 2,000 credits)
- Professional Pack ($20 / 4,000 credits โ Most Popular)
- Business Pack ($50 / 10,000 credits)
- Credit balance is automatically topped up via Stripe webhook on checkout completion.
โก Deployment: Vercel & Production
This architecture is engineered explicitly for Vercel serverless environments.
One-Click Deploy
Live App: ai-knowledge-base-six.vercel.app
๐ Required Environment Variables
To successfully deploy and run, you must populate the following environment variables in your Vercel project settings:
| Service | Variable | Description & Source |
|---|---|---|
| Database | DATABASE_URL | PostgreSQL connection string (Supabase or Neon) |
| NextAuth / Google | NEXTAUTH_SECRET | Secure random string generated via openssl rand -base64 32 |
NEXTAUTH_URL | Your production domain (e.g. https://my-app.vercel.app) | |
WEBHOOK_URL | Public URL for MuAPI async callbacks (same as NEXTAUTH_URL in production) | |
GOOGLE_CLIENT_ID | Get from Google Cloud Console | |
GOOGLE_CLIENT_SECRET | Get from Google Cloud Console | |
| Stripe Billing | STRIPE_SECRET_KEY | Get from Stripe Dashboard |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Get from Stripe Dashboard | |
STRIPE_WEBHOOK_SECRET | Webhook secret for resolving credit purchases | |
| AI LLM Queries | MU_API_KEY | Create an account and get key from muapi.ai/access-keys |
๐ Launching on Vercel: Step-by-Step
- Database Provisioning: Create a new Postgres database (via Supabase or Neon). Retrieve the connection string (
DATABASE_URL). - Project Creation: Import your GitHub fork into the Vercel dashboard.
- Configure Environment Variables: Copy the variables above into the Vercel project settings environment tab.
- Deploy: Hit "Deploy". Vercel will automatically run the build steps (
npm run build). - Database Push: Run
npx prisma db pushto synchronize database models before launching. - Integrations Setup:
- Establish a Google Cloud OAuth app, enabling the callback URL:
https://your-app.vercel.app/api/auth/callback/google - Setup a Stripe Webhook, pointing to
https://your-app.vercel.app/api/stripe/webhookand selecting thecheckout.session.completedevent.
- Establish a Google Cloud OAuth app, enabling the callback URL:
๐ ๏ธ Local Development
Ready to iterate locally? Setup is straightforward.
Prerequisites
- Node.js (v18 or higher)
- A local PostgreSQL instance or a free cloud Database URL.
Setup
# 1. Clone the repository
git clone https://github.com/SamurAIGPT/ai-knowledge-base
cd ai-knowledge-base
# 2. Install dependencies
npm install
# 3. Setup Environment
cp .env.example .env
# Open .env and insert your specific keys.
# 4. Initialize Database Schema
# Note: Because the database is shared, see the Safety Warning below!
npx prisma generate
npx prisma db push
# 5. Start the Development Server
npm run dev
The console should now be active on http://localhost:3000.
โ ๏ธ Database Safety Warning (Shared Pool)
The workspace database is shared with other applications. Running npx prisma db push on a clean, empty schema will drop tables belonging to other applications. Always follow the Pull-Declare-Push-Cleanup sequence:
- Run
npx prisma db pullto fetch all database tables. - Declare your
KnowledgeBase,Source,KBChat, andKBMessagetables and update the relations on theUsermodel. - Run
npx prisma db pushto add your changes safely. - Clean up
schema.prismato keep only NextAuth models,KnowledgeBase,Source,KBChat,KBMessage, and the updatedUserrelations. - Run
npx prisma generateto rebuild the type-safe client.
๐๏ธ Technical Architecture
ai-knowledge-base/
โโโ prisma/
โ โโโ schema.prisma # Postgres schema (User, Account, Session, KnowledgeBase, Source, KBChat, KBMessage)
โโโ src/
โ โโโ app/ # Next.js App Router
โ โ โโโ page.js # Main Workspace Studio (Sources, Playground RAG, Widget export)
โ โ โโโ dashboard/ # Personal gallery list overview
โ โ โโโ pricing/ # 4-Plan credit pricing grid structured at \$1 = 200 credits
โ โ โโโ api/
โ โ โโโ auth/ # NextAuth dynamic sessions
โ โ โโโ kb/ # GET / POST / DELETE knowledge bases
โ โ โโโ kb/[id]/sources # GET / POST / DELETE data sources (Files, URLs, Q&As)
โ โ โโโ kb/[id]/chat # GET / POST / DELETE playground chats
โ โ โโโ kb/[id]/chat/[chatId]/messages # GET / POST query messages (Context, citations, LLM)
โ โ โโโ stripe/ # Stripe checkout creation + checkout webhook
โ โโโ components/
โ โ โโโ Providers.js # NextAuth SessionProvider wrapper
โ โ โโโ layout/Navbar.jsx # Sticky header with Vercel Deploy button & credit balance
โ โโโ lib/
โ โโโ auth.js # NextAuth config with Prisma adapter
โ โโโ config.js # Central config mapping Google, Stripe, MuAPI keys
โ โโโ prisma.js # Cached Prisma client singleton
โ โโโ stripe.js # Stripe instance initializer
โ โโโ services/
โ โโโ user.js # Credit management service
โ โโโ billing.js # Stripe checkout and payment webhook parser
โโโ next.config.mjs # Next.js configuration
๐ License
MIT Licensed.
KnowBase AI: A premium, high-contrast, fully responsive customized semantic knowledge agent SaaS builder.