A modern, feature-rich AI chat application built with Svelte 5, Bun, and OpenRouter. Performance-optimized, secure, and supports multi-model conversations with intelligent auto-routing, Ollama integration, and comprehensive analytics.
- Features
- Quick Start
- Docker Deployment
- Desktop App (Electron)
- Mobile App (Android via Capacitor)
- Project Structure
- Configuration
- Usage
- Development
- Security Considerations
- Roadmap
- Contributing
- License
- Acknowledgments
- Support
- Auto Mode: Intelligent model routing using
arcee-ai/trinity-mini:freeto select the best model for each query. - Manual Multi-Model Mode: Run multiple models simultaneously and compare responses side-by-side.
- Ollama Integration: Support for local models via Ollama.
- Zero Data Retention (ZDR): Toggle to use only privacy-compliant models with ZDR policies.
- Real-time Streaming: Token-by-token streaming with smooth animations and Svelte 5 reactivity.
- Chat Summaries: Automatic generation of descriptive chat titles.
- Image Generation: Native image generation with Gemini, Seedream, and GPT-5 models.
- Web Search: Integration with citations for up-to-date information.
- Per-message statistics (tokens, cost, latency).
- Multi-model aggregated stats.
- Dashboard with time-series charts (cost, usage, performance).
- Cost tracking and optimization insights.
- AES-256-GCM encrypted API key storage.
- Optional client-side encryption with IndexedDB.
- Data Management: Quickly clear local cache or database records.
- Secure, self-hosted session management.
- Performance: Virtualized sidebar list for handling thousands of chat histories smoothly.
- Modern UI: Dark developer-tool aesthetic using Tailwind CSS v4.
- Responsive: Three-column layout with collapsible sidebars.
- Cross-Platform: Web, Desktop (Electron), and Mobile (Android).
- Bun runtime (required)
- OpenRouter API key (Get one here)
- (Optional) Ollama for local models
- Clone the repository
git clone https://github.com/aydenstechdungeon/selfhostablechat
cd selfhostablechat- Install dependencies
bun install- Set up environment variables
cp .env.example .env- Start the development server
bun run devVisit http://localhost:5173
The easiest way to self-host this application is using Docker.
- Build and run with Docker Compose
docker-compose up -d- Access the application
http://localhost:3420
# View logs
docker-compose logs -f
# Rebuild after updates
docker-compose up -d --build
# Stop the application
docker-compose downBuild a native desktop application for Linux, Windows, and macOS.
# Development
bun run desktop
# Build (Linux AppImage)
bun run electron:build:linux
# Build (Windows EXE)
bun run electron:build:win
# Build (macOS DMG)
bun run electron:build:macBuilt applications will be in dist-electron/.
Build a native Android application with a bundled Node.js server.
# Build SvelteKit and sync Capacitor
bun run mobile
# Open in Android Studio
bun run mobile:openSee CAPACITOR_IMPLEMENTATION.md for details.
src/
βββ lib/
β βββ components/ # Svelte 5 components (Runes, Snippets)
β βββ server/ # AI routing, streaming, and database
β βββ stores/ # Reactive stores for state
β βββ shared/ # Shared constants (Model definitions)
β βββ types.ts # TypeScript definitions
βββ routes/
β βββ api/ # SSE streaming and analytics endpoints
β βββ (app)/ # Main UI routes (Chat, Dashboard, Settings)
static/ # Assets (Icons, WebP images)
arcee-ai/trinity-mini:free- Primary Router/Summarizergoogle/gemini-3-flash-preview- Latest Gemini with visiongoogle/gemini-3.1-pro-preview- High-quality reasoninganthropic/claude-sonnet-4.6- Advanced coding & writinganthropic/claude-opus-4.6- Complex reasoningdeepseek/deepseek-r1-0528:free- Deep reasoningopenai/gpt-4o-mini- Fast, efficientx-ai/grok-4.1-fast- Fast general purpose
The application can connect to a local Ollama instance (default: http://localhost:11434). Configure this in the Settings panel or via environment variables in future updates.
- API Keys: Stored with AES-256-GCM encryption. Use server-side storage for the best security.
- Privacy: Zero Data Retention mode filters for providers that guarantee your data isn't used for training.
- Self-Hosting: You own your database (SQLite) and data.
- Core chat functionality with Svelte 5 Runes
- Auto-routing with Trinity Mini
- Ollama local model integration
- Multi-model comparison mode
- Desktop & Mobile (Android) app builds
- Image Generation (Gemini, Seedream)
- Web search integration
- Virtualized sidebar for huge chat histories
- Data management features (Clear Cache)
- iOS app support (Capacitor)
- Voice input/output support
- Advanced plugin system
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this project for personal or commercial purposes.
Happy chatting! π