An open-source, self-hostable AI assistant where your continuity and memory are not tied to a single model provider.
WhatIff keeps the persistent AI state in your stack: conversations, long-term memory, personalities, tools, and scheduled agents. The model that generates the next response is interchangeable, so you can move between supported providers without making any one of them the owner of your AI's continuity.
WhatIff is the open-source core that powers whatiff.chat, a Go API server and an Angular web app you can run yourself. It owns the continuity layer independently of the model provider: semantic memory, personalities, conversation state, tools, and recurring work stay with the WhatIff deployment while supported models can be selected per user and per chat. Bring your own model API keys and host the whole thing on your own infrastructure.
Want the story behind it? Read the Imagination Foundry blog.
- Chat with models from OpenAI, Anthropic, Google (Gemini), Z.ai (GLM), Mistral, DeepSeek, Qwen, and Xiaomi โ configurable per user and per chat
- Streaming responses with Markdown rendering and an emoji picker
- Multiple chat sessions with sidebar navigation, inline renaming, and per-chat settings
- Long-term memory stored as vector embeddings (pgvector) and recalled by conversation context
- Filter and search memories by date, scope, chat, and content
- Memory merging and compaction with checkpoints so context stays coherent over time
- Define reusable AI personas with custom system prompts and behavior
- Switch personalities per chat or set a default; attach reference documents to a persona
- Full create/edit/organize UI
- Reusable prompt templates you can invoke with customizable keyboard shortcuts
- Bind a ritual to a personality and auto-enrich messages with its context
- File attachments with 30+ supported types, plus semantic search over uploaded documents
- Code interpreter, image generation, and web search available to the assistant
- Agents โ scheduled and background AI jobs with a distributed-lock-aware scheduler
- AI-generated files saved straight back into the conversation
- Remote MCP connectors with per-chat activation controls
- Webhook API tokens (stored as one-way hashes) with static bearer auth isolated from session JWTs
- Webhook trigger modes for existing chats:
user,assistant(write-only), andbackground(async agent trigger)
- OpenAPI specification and structured logging (Zap)
- Ent ORM with automatic, non-destructive database migrations
- Docker & Docker Compose for local development
- GitHub Actions CI
| Layer | Technologies |
|---|---|
| Backend | Go 1.27 ยท Gorilla Mux ยท Ent ORM ยท PostgreSQL 16 + pgvector ยท JWT auth ยท Zap |
| Frontend | Angular 22 ยท TypeScript 5 ยท Tailwind CSS 4 ยท RxJS ยท ngx-markdown |
| AI | OpenAI, Anthropic, Google, Z.ai, Mistral, DeepSeek, Qwen, Xiaomi (bring your own keys) |
| Infra | Docker & Docker Compose ยท GitHub Actions |
The fastest way to run the full stack locally is Docker Compose.
Prerequisites: Docker, and at least one model provider API key (e.g. OpenAI).
# 1. Set the required secrets. docker-compose.yml ships no fallbacks โ the server
# refuses to boot on a missing, short (<32 char), or default-looking value.
export OPENAI_API_KEY="your-api-key-here"
export JWT_SECRET="$(openssl rand -hex 32)"
export JWT_REFRESH_SECRET="$(openssl rand -hex 32)"
export TOKEN_ENCRYPTION_SECRET="$(openssl rand -hex 32)"
# 2. Start the stack (runs migrations and seeds a default model automatically)
docker compose up --build| Service | URL |
|---|---|
| Frontend | http://localhost:8081 |
| API | http://localhost:8080 |
| PostgreSQL | localhost:5432 |
Compose is for local development only. Its defaults (
DESTRUCTIVE_MIGRATION=false,DB_SSL_MODE=disable, no secret fallbacks) are deliberately conservative โ every deployed environment must set its own real secrets and connection settings explicitly.
Run the backend and frontend directly for a faster inner loop.
Backend (Go 1.27+, a running PostgreSQL 16 with pgvector):
go run ./cmd/api-server
# Connects to Postgres, enables pgvector, runs non-destructive migrations
# (AUTO_MIGRATE=true), seeds a default model, and serves on :8080.Frontend (Node.js 20+):
cd web/app
npm install
npm start # Angular dev server on :4200, proxying the API on :8080Configuration is via environment variables. The essentials:
| Variable | Purpose |
|---|---|
OPENAI_API_KEY |
Model provider key (required for AI features; add other providers' keys as needed) |
JWT_SECRET, JWT_REFRESH_SECRET |
JWT access/refresh token signing (โฅ32 chars) |
TOKEN_ENCRYPTION_SECRET |
Encryption key for at-rest secrets (โฅ32 chars) |
DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME |
PostgreSQL connection |
SERVER_HOST, SERVER_PORT |
API bind address (default localhost:8080) |
ENVIRONMENT |
development | staging | production |
AUTO_MIGRATE |
Run migrations on boot (true/false) |
DESTRUCTIVE_MIGRATION |
Allow dropping columns/indexes during auto-migrate โ keep false in deployed envs |
See .env.example and docker-compose.yml for the full set.
what-iff/
โโโ cmd/api-server/ # Application entry point
โโโ internal/
โ โโโ agent/ # Tool-using AI agent, tools, and file processing
โ โโโ agentjobs/ # Scheduled & background agent jobs (scheduler)
โ โโโ auth/ # JWT, password hashing, token utilities
โ โโโ datastore/ # Database operations (repository pattern over Ent)
โ โโโ handlers/ # HTTP request handlers
โ โโโ memoryutil/ # Semantic memory helpers
โ โโโ metering/ # Usage-metering seam (no-op in the open-source build)
โ โโโ middleware/ # Auth, CORS, logging
โ โโโ models/ # Data transfer objects
โ โโโ providers/ # Model provider integrations
โ โโโ server/ # HTTP server wiring & routing
โโโ ent/schema/ # Ent database schema (generated code is not committed)
โโโ web/app/ # Angular frontend
โโโ docs/ # Architecture and reference docs
โโโ openapi.yaml # OpenAPI specification
- ARCHITECTURE.md โ system design, patterns, and internals
- openapi.yaml โ full REST API specification
- CONTRIBUTING.md โ how to contribute
- SECURITY.md โ reporting vulnerabilities
Contributions are welcome! Please read CONTRIBUTING.md and our Code of Conduct before opening a pull request. Issues and feature ideas are equally appreciated.
Licensed under the Apache License 2.0.