A full-stack multi-provider AI chat application that allows you to interact with multiple LLM providers from a single unified interface โ with per-user authentication and isolated chat history.
Available on:
๐ https://multillm.net/
This project combines:
- โก A streaming FastAPI backend (Dockerized)
- ๐จ A premium Next.js frontend
- ๐ PostgreSQL persistence
- ๐ Firebase Authentication (Google OAuth + Email/Password)
- ๐ณ Dockerized backend environment
- ๐ Multi-chat session management per user
- ๐ง Dynamic model/provider routing
The platform allows users to:
- Sign in via Google OAuth or Email/Password (Firebase Auth)
- Chat with multiple AI providers (OpenAI, Anthropic, Groq, OpenRouter, Gemini)
- Stream responses token-by-token in real time
- Manage multiple chat sessions isolated per user
- Delete chats (persisted in DB)
- Switch models per conversation
- Render Markdown (GFM support)
- Copy responses with animated feedback
- Use a collapsible sidebar UI
- Persist conversations in PostgreSQL scoped to authenticated user
This is a production-style architecture, not just a demo chatbot.
multi-llm-platform/
โ
โโโ apps/
โ โโโ api/ # FastAPI backend (Dockerized)
โ โ โโโ main.py
โ โ โโโ requirements.txt
โ โ โโโ Dockerfile
โ โ โโโ secrets/
โ โ โ โโโ firebase-sa.json # Firebase service account (not committed)
โ โ โโโ ...
โ โ
โ โโโ web/ # Next.js frontend
โ โโโ src/
โ โโโ package.json
โ โโโ ...
โ
โโโ .gitignore
โโโ README.md
Authentication is handled by Firebase Auth on the frontend. The backend verifies identity server-side using the Firebase Admin SDK.
- User signs in via Google OAuth or Email/Password on the frontend
- Firebase issues a JWT ID token on the client
- The frontend attaches the token to every API request (
Authorization: Bearer <token>) - The FastAPI backend verifies the token using the Firebase Admin SDK
- All DB queries are scoped to the verified
user_idโ chats are fully isolated per user
- ๐ต Google OAuth โ one-click sign-in
- ๐ง Email + Password โ standard registration/login
The frontend is built using modern React architecture and runs locally during development.
- Next.js 16 (App Router)
- React 19
- TypeScript
- Tailwind CSS
- Firebase SDK (Auth)
- React Markdown
- remark-gfm
- Fetch API with streaming
- Custom animated UI components
- Firebase Auth (Google + Email/Password)
- Protected routes (redirect to login if unauthenticated)
- JWT token forwarded to backend on every request
- Collapsible sidebar
- Chat previews per user
- Streaming token rendering
- Model selector dropdown
- Copy button with animated "Copied" state
- Premium dark UI
- Responsive layout
- Markdown rendering (GFM support)
cd apps/web
npm install
npm run devFrontend runs at:
http://localhost:3000
The frontend is NOT containerized. It runs using the Next.js dev server.
The backend handles:
- Firebase ID token verification (Admin SDK)
- Per-user chat session management
- Message persistence scoped to
user_id - Provider routing
- Streaming responses (SSE-compatible)
- File-aware prompt building
- Temperature control
- Provider-specific SDK handling
- Python 3.12
- FastAPI
- Uvicorn
- SQLAlchemy (Async)
- asyncpg
- PostgreSQL
- firebase-admin (Python SDK)
- OpenAI SDK
- Anthropic SDK
- Google GenAI SDK
- httpx
- python-dotenv
- Pydantic v2
The backend is containerized using Docker.
cd apps/api
docker build -t mlm-backend .docker run -p 8000:8000 --env-file .env mlm-backendBackend will be available at:
http://localhost:8000
NEXT_PUBLIC_*variables are exposed to the browser by Next.js.
The Firebase Web API key is not a secret, but it must be restricted in Google Cloud (HTTP referrers + API restrictions).
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_web_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_firebase_app_idDATABASE_URL=postgresql+asyncpg://user:password@host:5432/dbname
FIREBASE_SERVICE_ACCOUNT_JSON=./secrets/firebase-sa.json
OPENAI_API_KEY=your_key
ANTHROPIC_API_KEY=your_key
GOOGLE_API_KEY=your_key
OPENROUTER_API_KEY=your_key
GROQ_API_KEY=your_key
โ ๏ธ Thesecrets/firebase-sa.jsonfile is never committed. Download it from the Firebase Console under Project Settings โ Service Accounts โ Generate new private key.
The backend connects to a PostgreSQL database using async SQLAlchemy.
Example connection string:
postgresql+asyncpg://mlm:mlm@localhost:5433/mlm
Tables typically include:
usersโ Firebase UID + optional metadatachatsโ linked touser_idmessagesโ linked tochat_idcreated_at/updated_attimestamps- model metadata per chat
All queries are filtered by the authenticated user_id โ no user can access another user's chats.
- Uses async generators (
yield) - Streams provider tokens progressively
- Normalizes provider-specific streaming APIs
- Uses
ReadableStream - Appends tokens live to UI
- Maintains reactive state updates
Models are selected dynamically using a prefix pattern:
provider:model_name
Examples:
openai:gpt-5
anthropic:claude-sonnet-4-6
groq:llama-3.3-70b-versatile
openrouter:mistralai/mistral-large-2512
The backend parses the provider prefix and initializes the correct SDK client.
- Node 18+
- Python 3.11+ (3.12 recommended)
- Docker (for backend)
- PostgreSQL instance (local or remote)
- Firebase project with Auth enabled (Google + Email/Password providers)
Make sure:
- No port conflicts (3000 / 8000)
- Only one
next devinstance is running .env/.env.localfiles exist for both frontend and backendsecrets/firebase-sa.jsonis placed inapps/api/secrets/and is gitignored
- Can be deployed to Vercel
- Add all
NEXT_PUBLIC_FIREBASE_*vars to Vercel environment settings - Or self-hosted with
next buildandnext start
- Can be deployed using Docker to:
- VPS
- Railway
- Render
- Fly.io
- Kubernetes
- Inject
FIREBASE_SERVICE_ACCOUNT_JSONas a secret (or mount the file via volume)
Production run example:
uvicorn main:app --host 0.0.0.0 --port 8000- Rate limiting per user
- Redis caching
- Vector database (RAG)
- Tool calling support
- File upload UI
- Chat export (Markdown / PDF)
- Cost tracking per model
- Multi-modal support
Built by Eliachar Feig
Senior Mobile & Full-Stack Engineer
iOS ยท Flutter ยท React ยท AI Systems ยท Architecture-first development
๐ Website: https://www.eliacharfeig.com/
MIT License
This project demonstrates:
- Firebase Auth with per-user chat isolation
- Multi-provider LLM abstraction
- Streaming architecture
- Full-stack separation
- Production-style backend design
- Modern TypeScript + Python integration
- Clean and scalable AI chat foundation

