mbot is an open-source starter project for building AI-powered chatbot applications. Combining a modern tech stack of Svelte for the frontend and FastAPI for the backend, it provides Firebase authentication and integrates seamlessly with OpenAI APIs. It should work with any of the major AI providers.
This project currently uses the following tools and packages on the frontend:
The backend is build using the following:
This project is designed for:
git clone https://github.com/mthomason/mbot.git
cd mbot
cd backend
python -m venv venv
source venv/bin/activate (On Windows: venv\Scripts\activate)
pip install -r ../requirements.txt
Alternatively, you can install the .venv in the projects root directory
python -m venv .venv
source .venv/bin/activate (On Windows: .venv\Scripts\activate)
pip install requirements.txt
cd frontend
npm install
frontend/ # SvelteKit app for the UI
backend/ # FastAPI app for APIs
backend/app/ # FastAPI endpoints and logic
backend/mserv/ # Backend utilities and config
electron/ # Optional Electron app (if applicable)
docs/ # Documentation files
To configure your backend environment variables, create a .env file in the root directory of the project with the following structure:
# Used for Firebase authentication
GOOGLE_PROJECT_ID_MBOT=my-firebase-project-id
# Used for OpenAI services
OPENAI_API_KEY_MBOT=sk-xxxxxxxxxxxxxxxxxxxx
To configure the frontend environment variables, create a .env file in the frontend directory of the project with the following structure:
# These values are given to you by Google when
# You create a new Firebase project.
# They will be in the form of a .JSON file.
# It's your Firebase Project config information for auth.
VITE_FIREBASE_API_KEY=ABCDEFGHIJKLMNOPQRSTUVWXYZA-12345678901
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=my-firebase-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=777777777777
VITE_FIREBASE_APP_ID=1:777777777777:web:3333333333333333333333
VITE_FIREBASE_MEASUREMENT_ID=G-ABCDEF7890
Note that VITE_FIREBASE_PROJECT_ID is the same value as GOOGLE_PROJECT_ID_MBOT in the backend.
This project was developed using Visual Studio Code as the IDE and includes a pre-configured launch profile for a seamless startup experience.
The recommended way to run the application is by using the provided "Launch mbot (client and server)" debug configuration. The configuration file, launch.json, is included in the .vscode folder.
To run the project:
venv virtual environment, VS Code should automatically detect it and ask if you want to use it for the workspace. Click "Yes" to accept.Ctrl+Shift+P or Cmd+Shift+P) and typing "Python: Select Interpreter". Choose the interpreter located in the venv/bin (or venv\Scripts on Windows) directory.Launch mbot (client and server) configuration from the dropdown menu.Alternatively, you can run the components manually:
cd backend
source venv/bin/activate
uvicorn main:fastapi_app --reload
cd frontend
npm run dev
To use the chat functionality, you must be authenticated. This is a deliberate feature of this starter project to demonstrate how to protect routes and integrate authentication in a modern web application.
Note: Currently, there is no warning message if you attempt to use the chat without being authenticated. The chat simply will not respond. This is a known issue and will be addressed in a future update.
Contributions are welcome! Please fork the repo and submit a pull request. Before contributing, make sure to:
This project is licensed under the MIT License. See the LICENSE file for details.
This project has a webfront here.