Skip to content

aydenstechdungeon/selfhostablechat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Self-Hostable AI Chat Application

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.

Table of Contents

✨ Features

πŸ€– AI Capabilities

  • Auto Mode: Intelligent model routing using arcee-ai/trinity-mini:free to 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.

πŸ“Š Analytics & Stats

  • Per-message statistics (tokens, cost, latency).
  • Multi-model aggregated stats.
  • Dashboard with time-series charts (cost, usage, performance).
  • Cost tracking and optimization insights.

πŸ” Security & Privacy

  • 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.

🎨 User Experience

  • 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).

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository
git clone https://github.com/aydenstechdungeon/selfhostablechat
cd selfhostablechat
  1. Install dependencies
bun install
  1. Set up environment variables
cp .env.example .env
  1. Start the development server
bun run dev

Visit http://localhost:5173

🐳 Docker Deployment

The easiest way to self-host this application is using Docker.

Quick Deploy

  1. Build and run with Docker Compose
docker-compose up -d
  1. Access the application
http://localhost:3420

Docker Commands

# View logs
docker-compose logs -f

# Rebuild after updates
docker-compose up -d --build

# Stop the application
docker-compose down

πŸ–₯️ Desktop App (Electron)

Build 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:mac

Built applications will be in dist-electron/.

πŸ“± Mobile App (Android via Capacitor)

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:open

See CAPACITOR_IMPLEMENTATION.md for details.

πŸ“ Project Structure

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)

πŸ”§ Configuration

Supported Models (Auto-Routing)

  • arcee-ai/trinity-mini:free - Primary Router/Summarizer
  • google/gemini-3-flash-preview - Latest Gemini with vision
  • google/gemini-3.1-pro-preview - High-quality reasoning
  • anthropic/claude-sonnet-4.6 - Advanced coding & writing
  • anthropic/claude-opus-4.6 - Complex reasoning
  • deepseek/deepseek-r1-0528:free - Deep reasoning
  • openai/gpt-4o-mini - Fast, efficient
  • x-ai/grok-4.1-fast - Fast general purpose

Local Models (Ollama)

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.

πŸ”’ Security Considerations

  • 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.

🎯 Roadmap

  • 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

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

MIT License - feel free to use this project for personal or commercial purposes.


Happy chatting! πŸš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors