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, each limited to the scopes it was created with (
messages:write,chat:read) - Webhook trigger modes for existing chats:
user,assistant(write-only), andbackground(async agent trigger) - Webhook read routes (scope
chat:read): threads (filterable by persona), persona names, messages, and job status; see the webhooks guide and the integration reference
- 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 an OpenAI API key, which you add in the app.
# Start the stack. On first run it generates this install's secrets, runs
# migrations, and seeds the model catalog.
docker compose up --buildThen open http://localhost:8081, create an account, and add your OpenAI key when the
app asks (it lives in Profile & Settings โ API keys, where you can add other
providers' keys too). Keys belong to your account and are stored encrypted; there is
nothing to put in .env.
The JWT and token-encryption secrets are generated once per install and kept in a
Docker volume; nothing is shipped in the repository. Values you set in your shell or
.env take precedence. docker compose down -v deletes them along with the database.
| 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 and other provider keys |
Not used by default: each account adds its own keys in the app. A deployment that supplies keys for everyone binds providerkeys.New to these instead |
JWT_SECRET, JWT_REFRESH_SECRET |
JWT access/refresh token signing (โฅ32 chars). Generated automatically under Docker Compose |
TOKEN_ENCRYPTION_SECRET |
Encryption key for at-rest secrets (โฅ32 chars). Generated automatically under Docker Compose |
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.