Skip to content

SoroushMB/multi-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LLM Chat App

A full-stack application for managing and chatting with multiple LLM providers (Ollama, Claude, OpenAI, OpenRouter, Gemini). Users can store API keys, chat with different models, and export their conversations.

Features

  • πŸ” User Authentication: Register and login with secure JWT authentication
  • πŸ”‘ API Key Management: Store and manage API keys for multiple LLM providers
  • πŸ’¬ Multi-Provider Chat: Chat with Ollama, Claude, OpenAI, OpenRouter, and Gemini
  • πŸ“Š Chat History: All conversations are stored per user
  • πŸ“₯ CSV Export: Export your chat history as CSV
  • 🎨 Modern UI: Black and white theme with Geist Mono font
  • πŸš€ One-Click Deployment: Easy setup for any platform

Tech Stack

Backend

  • FastAPI - Modern Python web framework
  • SQLite - Lightweight database
  • SQLAlchemy - ORM for database operations
  • JWT - Authentication tokens
  • UV - Fast Python package manager

Frontend

  • React 19 - Latest React version
  • TypeScript - Type-safe development
  • Vite - Fast build tool
  • Bun - Fast JavaScript runtime and package manager
  • Axios - HTTP client

Project Structure

llm-chat-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ core/          # Configuration and database
β”‚   β”‚   β”œβ”€β”€ models/        # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ schemas/       # Pydantic schemas
β”‚   β”‚   β”œβ”€β”€ routers/      # API routes
β”‚   β”‚   β”œβ”€β”€ services/     # Business logic
β”‚   β”‚   └── main.py        # FastAPI app
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   └── schema.sql     # SQL schema
β”‚   └── pyproject.toml     # Python dependencies
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/   # React components
β”‚   β”‚   β”œβ”€β”€ contexts/     # React contexts
β”‚   β”‚   β”œβ”€β”€ pages/        # Page components
β”‚   β”‚   β”œβ”€β”€ services/     # API services
β”‚   β”‚   └── types.ts       # TypeScript types
β”‚   └── package.json       # Node dependencies
β”œβ”€β”€ deploy.sh              # Linux/Mac deployment script
β”œβ”€β”€ deploy.bat             # Windows deployment script
└── README.md

Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+ (or Bun)
  • UV (will be installed automatically if missing)
  • Bun (will be installed automatically if missing)

One-Click Deployment

Linux/Mac:

./deploy.sh

Windows:

deploy.bat

The script will:

  1. Install UV and Bun if needed
  2. Set up the backend with all dependencies
  3. Initialize the SQLite database
  4. Start the backend server (port 8000)
  5. Set up the frontend
  6. Start the frontend server (port 5173)

Manual Setup

Backend Setup

cd backend

# Install UV if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv pip install -e .

# Initialize database
python -c "from app.core.database import init_db; init_db()"

# Run server
uvicorn app.main:app --reload

Frontend Setup

cd frontend

# Install Bun if not already installed
curl -fsSL https://bun.sh/install | bash

# Install dependencies
bun install

# Run dev server
bun run dev

Usage

  1. Register/Login: Create an account or login
  2. Add API Keys: Go to the API Keys tab and add your API keys for the providers you want to use
  3. Start Chatting: Select a provider and model, then start asking questions
  4. Export Chats: Click "Export CSV" to download your chat history

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login and get token
  • GET /api/auth/me - Get current user info

API Keys

  • GET /api/api-keys - Get all API keys
  • POST /api/api-keys - Create a new API key
  • DELETE /api/api-keys/{id} - Delete an API key

Chats

  • GET /api/chats - Get user's chats
  • POST /api/chats - Create a new chat
  • GET /api/chats/{id} - Get a specific chat
  • DELETE /api/chats/{id} - Delete a chat

Export

  • GET /api/export/chats/csv - Export chats as CSV

Database Schema

The SQL schema is defined in backend/database/schema.sql:

  • users: User accounts
  • api_keys: Shared API keys (all users can use)
  • chats: User-specific chat history

Environment Variables

Create a .env file in the backend directory (optional):

DATABASE_URL=sqlite:///./llm_chat.db
SECRET_KEY=your-secret-key-change-in-production
ACCESS_TOKEN_EXPIRE_MINUTES=30
CORS_ORIGINS=["http://localhost:5173"]

Supported LLM Providers

  • Ollama: Local models (default: llama3)
  • OpenAI: GPT models (default: gpt-4)
  • Claude: Anthropic models (default: claude-3-5-sonnet-20241022)
  • OpenRouter: Multiple models (default: openai/gpt-4)
  • Gemini: Google models (default: gemini-pro)

Development

Backend Development

cd backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

API documentation available at: http://localhost:8000/docs

Frontend Development

cd frontend
bun run dev

Frontend available at: http://localhost:5173

License

MIT

About

Portable Chatbot with React and FastAPI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors