Skip to content

li3500764/opencat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OpenCat

Open-source AI Agent Orchestration Platform

Multi-model LLM Gateway Β Β·Β  ReAct Agent Engine Β Β·Β  RAG Pipeline Β Β·Β  Desktop Client

Features Β β€’Β  Tech Stack Β β€’Β  Getting Started Β β€’Β  Architecture Β β€’Β  Roadmap Β β€’Β  δΈ­ζ–‡ζ–‡ζ‘£


What is OpenCat?

OpenCat is a self-hosted AI agent platform that gives you full control over your LLM workflows. Instead of relying on closed-source tools, you get a production-grade system with multi-model routing, autonomous agents, knowledge retrieval, and a clean desktop experience β€” all running on your own infrastructure.

No LangChain. No magic wrappers. Every agent loop, tool call, and retrieval pipeline is implemented from scratch for full transparency and zero vendor lock-in.


Features

Shipped

  • SSE Streaming Chat β€” Real-time token streaming via Server-Sent Events
  • Authentication β€” NextAuth v5 with GitHub OAuth + email/password credentials
  • Conversation Persistence β€” Full message history stored in PostgreSQL
  • Encrypted API Key Storage β€” AES-256-GCM encryption for all stored secrets
  • Theme System β€” Warm gray + amber design with light/dark mode
  • Zustand State β€” Client-side conversation management with optimistic updates

In Progress

  • Multi-Model Gateway β€” Route between OpenAI, Anthropic, and custom providers
  • ReAct Agent Engine β€” Autonomous reasoning + action loops with tool calling
  • Multi-Agent Orchestration β€” Orchestrator pattern for complex workflows
  • Memory System β€” Auto-summarization with pgvector similarity search
  • RAG Pipeline β€” Document upload β†’ chunking β†’ embedding β†’ retrieval
  • Token Dashboard β€” Usage analytics and cost tracking
  • Tauri 2.0 Desktop β€” Native cross-platform client

Tech Stack

Layer Technology
Framework Next.js 16 (App Router) + React 19
Language TypeScript 5 (strict mode)
Styling TailwindCSS 4 + Geist Font
Database PostgreSQL 17 + pgvector
ORM Prisma 7 with @prisma/adapter-pg
Cache Redis 7
Auth NextAuth v5 (JWT sessions)
AI Vercel AI SDK 6.x
State Zustand 5
Validation Zod 4
Desktop Tauri 2.0 (planned)
Package Manager pnpm 10

Getting Started

Prerequisites

  • Node.js 22 LTS
  • pnpm 10+
  • Docker (for PostgreSQL + Redis)

1. Clone & Install

git clone https://github.com/li3500764/opencat.git
cd opencat
pnpm install

2. Start Services

docker compose up -d

This spins up:

  • PostgreSQL 17 (pgvector) on port 5433
  • Redis 7 on port 6379

3. Configure Environment

cp .env.example .env

Edit .env with your values:

DATABASE_URL="postgresql://opencat:opencat@localhost:5433/opencat?schema=public"
AUTH_SECRET="your-auth-secret"          # openssl rand -base64 32
ENCRYPTION_KEY="your-encryption-key"    # openssl rand -hex 32
OPENAI_API_KEY="sk-..."

4. Initialize Database

npx prisma db push

5. Run

pnpm dev

Open http://localhost:3001 and create an account to start chatting.


Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Client (React 19)               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Chat UI  β”‚  β”‚ Sidebar  β”‚  β”‚ Theme Provider β”‚  β”‚
β”‚  β”‚ useChat()β”‚  β”‚ Zustand  β”‚  β”‚ Light / Dark   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚       β”‚ SSE Stream                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       β–Ό          Server (Next.js App Router)      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Chat APIβ”‚  β”‚ Auth API β”‚  β”‚ Conversations   β”‚  β”‚
β”‚  β”‚ stream  β”‚  β”‚ NextAuth β”‚  β”‚ API             β”‚  β”‚
β”‚  β”‚ Text()  β”‚  β”‚ v5 + JWT β”‚  β”‚ CRUD            β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚       β”‚                              β”‚            β”‚
β”‚  β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚          Prisma 7 + pg Pool Adapter          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     β–Ό         Infrastructure      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  PostgreSQL 17       β”‚  β”‚  Redis 7          β”‚  β”‚
β”‚  β”‚  + pgvector          β”‚  β”‚  Cache / Queue    β”‚  β”‚
β”‚  β”‚  15 tables           β”‚  β”‚                   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Database Schema (15 tables)

User ──┬── Account (OAuth)
       β”œβ”€β”€ Session
       β”œβ”€β”€ ApiKey (AES-256-GCM encrypted)
       β”œβ”€β”€ Project ──┬── Agent (systemPrompt, tools[], model)
       β”‚             β”œβ”€β”€ Conversation ── Message (role, parts, tokenCount)
       β”‚             └── KnowledgeBase ── Document ── DocumentChunk (embedding)
       β”œβ”€β”€ Memory (pgvector 1536d)
       └── UsageLog (token tracking)

Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/          # Login / Register pages
β”‚   β”œβ”€β”€ (dashboard)/     # Protected chat interface
β”‚   └── api/
β”‚       β”œβ”€β”€ auth/        # NextAuth + registration
β”‚       β”œβ”€β”€ chat/        # SSE streaming endpoint
β”‚       └── conversations/  # CRUD operations
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ chat/            # ChatPanel, MessageList, ChatInput, Markdown
β”‚   └── layout/          # Sidebar, ThemeProvider, ThemeToggle
β”œβ”€β”€ lib/                 # auth.ts, crypto.ts, utils.ts
β”œβ”€β”€ server/db/           # Prisma client singleton
β”œβ”€β”€ stores/              # Zustand (chat, theme)
└── types/               # NextAuth type augmentation

Roadmap

Phase Milestone Status
1 Scaffolding + Auth + Database Schema βœ…
2 Single Model Chat + SSE Streaming βœ…
3 Multi-Model Gateway + API Key Management ⏳
4 Tool Calling + ReAct Agent Engine ⏳
5 Multi-Agent Orchestration + Project Isolation ⏳
6 Memory System + RAG with pgvector ⏳
7 Usage Dashboard + Tauri 2.0 Desktop Client ⏳

Design Philosophy

  • No LangChain β€” Self-implemented agent runtime for full control and zero abstraction overhead
  • No AI-gradient UI β€” Clean warm-gray + amber palette inspired by Linear and Raycast
  • Security first β€” AES-256-GCM encrypted key storage, JWT sessions, bcrypt password hashing
  • Production patterns β€” Connection pooling, singleton clients, streaming responses, usage tracking

License

MIT


Built with obsession by @li3500764

About

🐱 OpenCat - Open-source AI Agent orchestration platform with multi-model LLM Gateway, ReAct Agent engine, RAG pipeline, and Tauri desktop client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages