Skip to content

tonyoconnell/anubis.chat

Repository files navigation

Anubis Chat

A next-generation AI chat platform combining advanced RAG (Retrieval-Augmented Generation) capabilities with Solana Web3 integration. Anubis Chat enables users to upload documents, create intelligent chatbots, and interact with multiple AI models through a secure, wallet-based authentication system.

πŸš€ Key Features

AI & Chat

  • Latest AI Models (August 2025) - GPT-5, Claude Opus 4.1, Gemini 2.5 Pro, and 14+ cutting-edge models
  • Dynamic Model Selection - Switch between AI models on-the-fly with rich UI selector
  • Multi-Provider Support - Seamless integration with OpenAI, Anthropic, and Google
  • Real-time Streaming - Convex HTTP actions for streaming AI responses
  • Document RAG System - Upload and query documents with semantic search
  • Real-time Chat - Streaming responses with conversation memory
  • Typing Indicators - Real-time typing status with automatic cleanup
  • Optimistic Updates - Instant UI feedback for better user experience
  • Context-Aware Responses - AI leverages uploaded documents for enhanced answers
  • Model Persistence - Selected model saved per chat conversation

Web3 Integration

  • Solana wallet authentication - Phantom, Backpack, and more
  • Signature-based security - Challenge/nonce verification
  • Subscription-ready - On-chain and off-chain verification flows

Platform Architecture

  • TypeScript-first across frontend and backend
  • Next.js 15 (App Router) with React 19
  • Convex backend for data, auth, and server actions
  • PWA with service worker and icon set
  • Code quality with Biome and Turborepo

Document Management

  • Multi-format ingestion - Text, Markdown, PDF, URLs
  • Semantic search - Vector embeddings and similarity search
  • User isolation - Per-wallet document scopes

πŸ›  Tech Stack

Frontend

  • Next.js 15 (App Router) + React 19
  • TypeScript, Tailwind CSS 4, Shadcn UI
  • TanStack Form + Zod validation

Backend

  • Convex - Real-time backend-as-a-service
  • Edge Functions - Serverless query/mutation functions
  • Real-time Database - Reactive data synchronization
  • Full-text Search - Built-in document search indexes

Security & Auth

  • Wallet Authentication - Solana signature verification
  • JWT Tokens with blacklisting support
  • Rate Limiting - Request throttling and abuse prevention
  • Input Validation - Zod schemas with ReDoS protection

Development

  • Turborepo, Bun, Biome, Husky

🚦 Getting Started

Prerequisites

  • Bun 1.2.19+
  • Solana wallet (Phantom recommended)
  • Convex account/project

Installation

  1. Clone and install
git clone https://github.com/your-username/anubis-chat.git
cd anubis-chat
bun install
  1. Configure environment

Frontend (apps/web/.env.local):

# Required
NEXT_PUBLIC_CONVEX_URL=https://<your-convex-deployment>.convex.cloud

# Providers (choose one or more)
OPENROUTER_API_KEY=...            # preferred for broad model access
OPENAI_API_KEY=...                # optional
GOOGLE_GENERATIVE_AI_API_KEY=...  # optional

# Solana (client)
NEXT_PUBLIC_SOLANA_NETWORK=devnet
NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com

# Optional
NEXT_PUBLIC_APP_URL=http://localhost:3001

Backend (Convex env variables; set via Convex dashboard/CLI):

# Providers
OPENROUTER_API_KEY=...
OPENAI_API_KEY=...
GOOGLE_GENERATIVE_AI_API_KEY=...

# Security / CORS / Rate-limits
ALLOWED_ORIGINS=http://localhost:3001
RATE_LIMIT_MAX_REQUESTS=100
RATE_LIMIT_WINDOW_MS=900000

# Auth / Admin (optional)
ADMIN_WALLETS=<comma-separated-solana-public-keys>
JWT_SECRET=<optional-legacy-only>

# Solana (server)
SOLANA_NETWORK=devnet
SOLANA_RPC_URL=https://api.devnet.solana.com
  1. Initialize Convex
bun dev:setup
  1. Start development
bun dev

Quick Commands

# Development
bun dev          # Start all apps
bun dev:web      # Frontend only
bun dev:server   # Convex backend only

# Code Quality
bun check        # Format + lint (Biome)
bun check-types  # TypeScript validation
bun build        # Production build

πŸ“ Project Structure

anubis-chat/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/                     # Next.js frontend
β”‚   β”‚   β”œβ”€β”€ src/app/             # App Router pages and API routes
β”‚   β”‚   β”œβ”€β”€ src/components/      # UI components
β”‚   β”‚   └── src/lib/             # Utils, env, middleware
β”‚   β”œβ”€β”€ fumadocs/                # Documentation site (Next.js + Fumadocs)
β”‚   β”‚   └── ...                  # Run with: bun -C apps/fumadocs dev
β”œβ”€β”€ packages/
β”‚   └── backend/
β”‚       └── convex/              # Convex functions and HTTP routes
β”‚           β”œβ”€β”€ http.ts          # HTTP router (uploads, streaming, payments)
β”‚           β”œβ”€β”€ streaming.ts     # WebSocket + HTTP streaming actions
β”‚           β”œβ”€β”€ files.ts         # Uploads and storage
β”‚           β”œβ”€β”€ documents.ts     # Document pipeline and CRUD
β”‚           β”œβ”€β”€ rag.ts           # RAG retrieval and formatting
β”‚           β”œβ”€β”€ users.ts         # User management
β”‚           β”œβ”€β”€ auth.ts          # Convex Auth (Solana)
β”‚           └── schema.ts        # Data model
└── turbo.json                   # Turborepo config

πŸ”§ API Reference

Next.js API routes (frontend bridge)

POST /api/chat                   # Stream chat via AI SDK providers
POST /api/ai/chat                # Tool-enabled chat endpoint
GET  /api/models                 # Available model list
GET  /api/ai-overview            # Providers/feature overview
GET  /api/mcp/servers            # List MCP servers
GET  /api/mcp/servers/[name]     # MCP server detail
POST /api/subscriptions/payment  # Subscription payment webhook/flow
POST /api/verify-payment         # Proxy to Convex payment verification

Convex HTTP routes (backend)

POST /stream-chat                # HTTP streaming fallback
POST /generateUploadUrl          # Get upload URL
POST /registerUpload             # Persist upload metadata
GET  /serveStorage               # Serve stored files
POST /verify-payment             # Verify Solana payments
# Convex Auth routes are also exposed via httpRouter (see auth.addHttpRoutes)

Note: Most application logic uses Convex queries/mutations/actions directly from the client. The REST-like endpoints above exist for streaming fallback, uploads, and integration surfaces.

πŸ” Security Features

Authentication

  • Solana wallet sign-in with nonce challenge (Convex Auth)
  • Optional legacy JWT for bridge routes only

Input & Transport

  • Zod validation across server boundaries
  • CORS allowlist with environment-configurable origins
  • Rate limiting for HTTP endpoints

Data Protection

  • Per-wallet isolation for documents and chats
  • Access controls enforced in Convex functions
  • Audit-friendly logging via structured logger

πŸš€ Deployment

  1. Build
bun build
  1. Deploy Convex
cd packages/backend
npx convex deploy
  1. Deploy Web (e.g., Vercel)
cd apps/web
vercel deploy
  1. Configure Environment
  • Set Convex env vars (providers, CORS, Solana, limits) in the Convex dashboard/CLI
  • Set web .env (NEXT_PUBLIC_CONVEX_URL, provider keys as needed)

πŸ›‘οΈ Operational Tips

  • Never commit secrets; use environment variables
  • Rotate provider keys and JWT secrets regularly if enabled
  • Monitor rate limits and model usage
  • Keep dependencies updated

🀝 Contributing

  1. Fork the repository
  2. Create a branch: git checkout -b feature/amazing-feature
  3. Add tests and ensure quality: bun check && bun check-types
  4. Commit: git commit -m 'Add amazing feature'
  5. Push: git push origin feature/amazing-feature
  6. Open a Pull Request

πŸ“„ License

MIT β€” see LICENSE.

πŸ™ Acknowledgments

About

AI-powered chat application built with Next.js, Convex, AI SDK, and modern web technologies. Features real-time messaging, PWA support, documentation with Fumadocs, and enterprise-ready architecture with Turborepo and Ultracite.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages