Skip to content

maybeswapnil/botforge-backend

Repository files navigation

🧠 ChatBotForge – Custom AI Chatbots for Businesses

ChatBotForge is a platform that allows businesses to create AI-powered chatbots trained on their own data — including documents, websites, and internal knowledge. Each bot is isolated, customizable, and easily embeddable on any site.


🚀 Features

For Businesses

  • Create and manage multiple bots
  • Upload files (PDF, DOCX, TXT) or crawl web pages
  • Fine-tune bot tone, greeting, and settings
  • Test bots instantly in a chat playground
  • View chat history and analytics (optional)

For End Users (Your Customers)

  • Real-time AI chat interface
  • Context-aware responses based on business content
  • Multi-language support
  • Mobile-friendly UI
  • Easy embed via iframe, widget, or SDK

🧱 System Architecture Overview

Components

  • Frontend (React/Vue/Next.js): Dashboard for businesses + embeddable chat widget
  • Backend (Golang):
    • Auth and User/Bot management
    • File ingestion and document parsing
    • Embedding and chunking logic
    • Vector DB integration
    • Prompt building and LLM integration
  • Vector Database (e.g., Qdrant, Pinecone):
    • Stores embeddings per bot (namespaced)
  • LLM Provider (e.g., OpenAI, Claude):
    • Generates final response using top-matching vectors

🧭 Message Flow

  1. User submits query to /api/chat
  2. Backend:
    • Fetches bot config by bot_id
    • Looks up vector namespace from DB (e.g., vec_abc123)
    • Embeds user message
    • Queries vector DB for top-k similar chunks
    • Builds prompt with retrieved context
    • Calls LLM API and returns response

🗂️ Example DB Schema

bots table

Field Type Description
id UUID Primary key
user_id UUID Bot owner
name VARCHAR Bot name
vector_namespace VARCHAR Vector DB namespace
settings JSON Greeting, tone, etc.
created_at TIMESTAMP Creation date

files table

Field Type Description
id UUID File ID
bot_id UUID Linked bot
filename VARCHAR Name of the uploaded file
type VARCHAR pdf, docx, text, url
status VARCHAR indexed, failed, pending
uploaded_at TIMESTAMP Upload time

⚙️ Vector Store Setup

  • Each bot gets a unique namespace in the vector DB
  • Namespace is stored in the bots table under vector_namespace
  • Example: vec_abc123 used for all embeddings of that bot

🛠️ Tech Stack

  • Backend: Golang (Gin/Fiber/Echo)
  • Vector Store: Qdrant / Pinecone
  • Embeddings: OpenAI Embedding API (text-embedding-3-small)
  • LLM: OpenAI GPT-4 or Claude
  • Frontend: React / Next.js
  • Auth: JWT-based (email/password or OAuth)

⚙️ Configuration

The application supports two configuration methods:

1. Environment Variables (Recommended)

Create a .env file in the project root:

# Copy the example file
cp .env.example .env

# Or migrate from existing config.json
./migrate-config.sh

Edit .env with your actual values. See ENV_CONFIG.md for detailed documentation.

2. config.json (Fallback)

If environment variables are not set, the application falls back to ./app/config/config.json.

Priority: Environment variables take precedence over config.json.

For detailed configuration options, migration guide, and security best practices, see ENV_CONFIG.md.


🔐 Authentication

  • Use JWT for all authenticated routes
  • Authorization header required for:
    • /api/upload
    • /api/chat
    • /api/bots
    • /api/files

🧪 Testing the Bot

Once a bot is created:

  • Upload a PDF via /api/upload
  • Query the bot via /api/chat with:
{
  "botId": "abc123",
  "message": "What services do you offer?"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages