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:
- Typescript for programming the frontend
- SvelteKit v2 for routing
- Skeleton v4 for theming and components
- Tailwind CSS v4 for style
- Firebase for authentication
- Vite v7 for building
The backend is build using the following:
- Python3 for the backend
- FastAPI for backend server
- OpenAI-Python for chat completions (works with other services like Google Gemini)
This project is designed for:
- AI startup enthusiasts building chat applications.
- Developers exploring Svelte and FastAPI.
- Hobbyists experimenting with OpenAI's GPT models.
- Modern Frontend: Built with SvelteKit for reactive UI.
- FastAPI Backend: Async API integration with OpenAI.
- Secure Authentication: Firebase for user authentication.
- Boilerplate for AI Apps: A great foundation for interactive AI chat solutions.
- Features
- Getting Started
- Project Structure
- Environment Variables
- Running the Project
- Authentication
- Contributing
- License
- Node.js Install from Node.js official site.
- Python Install from Python's official site.
- Firebase Project Create a Firebase project for authentication (free tier is sufficient).
- OpenAI API Key Obtain an API key from OpenAI's platform.
git clone https://github.com/mthomason/mbot.git
cd mbotcd backend
python -m venv venv
source venv/bin/activate (On Windows: venv\Scripts\activate)
pip install -r ../requirements.txtAlternatively, 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.txtcd frontend
npm installfrontend/ # 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 filesTo 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- GOOGLE_PROJECT_ID_MBOT: Your Firebase project ID, used for authentication.
- OPENAI_API_KEY_MBOT: Your API key for OpenAI services. Remember that usage may incur costs.
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-ABCDEF7890Note 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:
- Open the project root in VSCode.
- After you've created the
venvvirtual environment, VS Code should automatically detect it and ask if you want to use it for the workspace. Click "Yes" to accept. - If you are not prompted, you can manually select the interpreter by opening the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) and typing "Python: Select Interpreter". Choose the interpreter located in thevenv/bin(orvenv\Scriptson Windows) directory. - Navigate to the "Run and Debug" view (usually in the left-hand sidebar).
- Select the
Launch mbot (client and server)configuration from the dropdown menu. - Press F5 or click the green play button to start both the frontend and backend servers.
Alternatively, you can run the components manually:
cd backend
source venv/bin/activate
uvicorn main:fastapi_app --reloadcd frontend
npm run devTo 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:
- Write clear documentation for new features.
- Follow the existing code style.
This project is licensed under the MIT License. See the LICENSE file for details.
This project has a webfront here.
