How safamathlouthi06/chatbot-factory works
Chatbot Factory is a multi-tenant SaaS for companies and employees to create and deploy role-configured chatbots. Its core workflow is knowledge setup (documents and FAQs), conversational testing/use through the RAG answer path, and conversation history; widget deployment, account administration, notifications, and usage analytics are additional product branches. The README and sampled files support the documented RAG stages, but several routes and frontend screens were not sampled, so their internal calls are not expanded here.
Main entry points: database.py Supabase data and vectors · chat.py Chat endpoint · document_service.py Document processing · rag_service.py RAG retrieval and selection
Components 29
Web application
- Company and employee workspace
frontend/app/dashboard - Admin console
frontend/app/admin - Login and registration
frontend/app/login/page.tsx - Chatbot setup
frontend/app/dashboard/chatbots - Knowledge and deployment screens
frontend/app/dashboard/chatbots/[chatbotId]
API and access
- FastAPI application
backend/main.py - JWT authentication and accounts
backend/auth.py - Chatbot management
backend/routes/chatbot.py - Employee management
backend/routes/employe.py
Knowledge management
- Document endpoints
backend/routes/document.py - FAQ endpoints
backend/routes/faq.py - Document processing
backend/services/document_service.py - FAQ indexing
backend/services/faq_service.py - Text chunking
backend/services/chunking_service.py
Answer engine
- RAG retrieval and selection
backend/services/rag_service.py - Local embeddings
backend/services/embedding_service.py - Chat endpoint
backend/routes/chat.py - Answer generation
backend/services/generation_service.py - Conversation history
backend/routes/conversation.py - Embeddable widget API
backend/routes/widget.py
Platform operations
- Usage analytics
backend/routes/statistiques.py - Notification endpoints
backend/routes/notification.py - Notification handling
backend/services/notification_service.py - Supabase data and vectors
backend/database.py - AI and Supabase configuration
backend/core/config.py
Other components
- Company / employee
- Website visitor
- Azure OpenAI
- Supabase / PostgreSQL
Connections 28
- Company / employee → Login and registration: signs in
- Company / employee → Company and employee workspace: manages workspace
- Website visitor → Embeddable widget API: uses widget
- Company and employee workspace → FastAPI application: calls REST API
- Login and registration → JWT authentication and accounts: authenticates
- Admin console → JWT authentication and accounts: manages companies
backend/auth.py - Chatbot setup → Chatbot management: manages bots
- Knowledge and deployment screens → Document endpoints: uploads documents
- Knowledge and deployment screens → FAQ endpoints: manages FAQs
- Document endpoints → Document processing: delegates processing
backend/routes/document.py - FAQ endpoints → FAQ indexing: delegates indexing
backend/routes/faq.py - Document processing → Text chunking: chunks text
- Document processing → Supabase data and vectors: stores knowledge
- FAQ indexing → Supabase data and vectors: indexes FAQ
- Chat endpoint → RAG retrieval and selection: retrieves context
backend/routes/chat.py - RAG retrieval and selection → Local embeddings: embeds question
backend/services/rag_service.py - RAG retrieval and selection → AI and Supabase configuration: queries vector RPC
backend/services/rag_service.py - AI and Supabase configuration → Supabase / PostgreSQL: connects to
backend/core/config.py - Chat endpoint → Answer generation: generates response
backend/routes/chat.py - Answer generation → Azure OpenAI: requests completion
backend/services/generation_service.py - Chat endpoint → Supabase data and vectors: records conversation
backend/routes/chat.py - Conversation history → Supabase data and vectors: reads history
backend/routes/conversation.py - Embeddable widget API → Supabase data and vectors: loads bot data
backend/routes/widget.py - Usage analytics → Supabase data and vectors: queries usage
backend/routes/statistiques.py - Notification endpoints → Notification handling: delegates handling
backend/routes/notification.py - Notification handling → Supabase data and vectors: stores notifications
backend/services/notification_service.py - JWT authentication and accounts → Supabase data and vectors: reads and writes accounts
backend/auth.py - Employee management → Supabase data and vectors: manages employee records
backend/routes/employe.py