Not A Wrapper — Open-source multi-AI chat application with unified model interface.
Provide a powerful AI chat interface that lets users interact with any AI model through a unified experience, with support for multi-model comparison and BYOK.
- User authentication (Clerk)
- Multi-model AI chat (Vercel AI SDK)
- Chat history persistence
- Streaming responses
- Convex database integration
- Multi-model comparison (side-by-side)
- BYOK (Bring Your Own Key) support
- Model performance analytics
- Response quality comparison tools
- Smart model routing (cost/speed optimization)
- Model chains and workflows
- Custom system prompts per model
- Conversation branching
- Export/import conversations
- API access for developers
- Flowglad payment integration
- Subscription tiers (Free/Pro/Enterprise)
- Usage-based billing for API calls
| Requirement | Target | Priority |
|---|---|---|
| Response time (streaming start) | < 500ms | High |
| Uptime | 99.9% | High |
| Context window efficiency | < 80% usage | Medium |
| Mobile responsiveness | Full support | Medium |
Decision: Use Convex for real-time data
Rationale:
- Built-in RAG and vector search for AI memory
- Real-time reactive queries (essential for chat)
- TypeScript-first (matches our stack)
- Native Clerk integration
Trade-offs:
- ❌ No local development (cloud-only)
- ❌ Vendor lock-in (proprietary)
- ✅ Faster development for AI features
- ✅ Better developer experience
Decision: Use Clerk for authentication
Rationale:
- Pre-built UI components
- Native integrations: Convex, Flowglad
- Handles OAuth complexity
- Good free tier for MVP
Decision: Abstract AI providers through Vercel AI SDK
Rationale:
- Switch models without code changes
- Consistent streaming API
- Future-proof for new models
Model Selection:
| Use Case | Model | Reason |
|---|---|---|
| Primary chat | Claude Opus 4.5 | Best reasoning, 1M context |
| Fast tasks | Claude Haiku 4.5 | Speed, cost efficiency |
| Vision tasks | Claude Sonnet 4.5 | Good balance, vision support |
Decision: Use Flowglad over Stripe
Rationale:
- Open-source
- Native Clerk integration
- Better DX for subscription management
- Designed for AI usage-based billing
// convex/schema.ts
// User - Managed by Clerk, synced to Convex
interface User {
clerkId: string
email: string
name?: string
subscriptionTier: "free" | "pro" | "enterprise"
createdAt: number
}
// Chat
interface Chat {
_id: Id<"chats">
userId: string
title: string
model?: string
createdAt: number
updatedAt: number
}
// Message
interface Message {
_id: Id<"messages">
chatId: Id<"chats">
role: "user" | "assistant" | "system"
content: string
model?: string
tokens?: number
createdAt: number
}
// UserKeys (BYOK)
interface UserKey {
_id: Id<"userKeys">
userId: string
provider: string
encryptedKey: string
createdAt: number
}User (1) ──→ (n) Chat
Chat (1) ──→ (n) Message
User (1) ──→ (n) UserKey
Stream a chat completion.
Request:
{
messages: Array<{
role: "user" | "assistant" | "system"
content: string
}>
model?: string // Default: gpt-4.1-nano
chatId?: string // For persistence
}Response: Server-Sent Events (streaming)
Get user's chat history.
Response:
{
chats: Array<{
id: string
title: string
lastMessage: string
updatedAt: string
}>
}| Category | Priority | Approach |
|---|---|---|
| Auth flows | 🔴 Critical | Integration tests |
| Data transforms | 🔴 Critical | Unit tests |
| Rate limiting | 🔴 Critical | Unit tests |
| API routes | 🟠 High | Integration tests |
| Chat persistence | 🟠 High | Integration tests |
| UI interactions | 🟡 Medium | E2E (Playwright) |
- AI response quality (non-deterministic)
- UI rendering/snapshots (too brittle)
- Animation timing
- Third-party API responses (mock them)
- Users can sign up and chat with AI
- Chat history persists across sessions
- Multiple AI models available
- Response time < 500ms to first token
- 1,000 active users
- Multi-model comparison feature adoption
- < 5% monthly churn
- NPS > 40
- Model routing: How to automatically select best model for task?
- Caching strategy: Cache responses for identical prompts?
- Privacy: How long to retain user chat data?
- International: Multi-language UI support timeline?
See plan.md for implementation roadmap.