Skip to content

vinhnx/vtchat

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VTChat

License: MIT TypeScript Next.js Deployed on Fly.io

A modern, privacy-first AI chat application with enterprise-grade security

Live Demo | Documentation | Security Guide


πŸš€ Overview

VTChat is a production-ready, privacy-focused AI chat application delivering cutting-edge AI capabilities through a sophisticated dual-tier subscription system. Built with modern web technologies and a privacy-first architecture, VTChat offers advanced AI reasoning, document processing, web search integration, and comprehensive multi-AI provider support.

✨ Key Features

🧠 Advanced AI Capabilities

  • Reasoning Mode (VT+ exclusive): Complete AI SDK reasoning tokens support with transparent thinking process
  • 9 Free AI Models: Gemini 2.0/2.5 Flash series + OpenRouter models (DeepSeek V3, DeepSeek R1, Qwen3 14B)
  • Multi-AI Provider Support: OpenAI, Anthropic, Google, Fireworks, Together AI, and xAI integration
  • Document Processing (VT+ exclusive): Upload and analyze PDF, DOC, DOCX, TXT, MD files (up to 10MB)
  • Structured Output Extraction (VT+ exclusive): AI-powered JSON data extraction from documents
  • Web Search Integration (VT+ exclusive): Grounding capabilities with real-time information
  • Mathematical Calculator: Advanced functions including trigonometry, logarithms, and arithmetic

πŸ”’ Privacy-First Architecture

  • Local-First Storage: All chat data stored in browser's IndexedDB via Dexie.js
  • Zero Server Storage: Conversations never leave the user's device
  • Multi-User Isolation: Complete data separation on shared devices
  • Enterprise-Grade Security: Secure authentication with Better Auth
  • Advanced Application Security: Arcjet protection with rate limiting, bot detection, email validation, and WAF

πŸ’Ό Subscription Tiers

  • VT_BASE (Free): 9 AI models, calculator, basic chat, local privacy
  • VT_PLUS ($10/month): All free features + reasoning mode, dark theme, web search, document upload, structured extraction
  • Seamless Management: Creem.io integration with customer portal

🎨 Modern User Experience

  • Shadcn UI Design System: Consistent, accessible interface
  • Dark Mode (VT+ exclusive): Premium theming experience
  • Responsive Design: Optimized for desktop and mobile
  • 87% Performance Improvement: Faster compilation and load times

πŸ—οΈ Architecture

VTChat utilizes a Turborepo-managed monorepo structure:

vtchat/
β”œβ”€β”€ apps/
β”‚   └── web/              # Next.js 14 web application (App Router)
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ actions/          # Server actions (e.g., feedback)
β”‚   β”œβ”€β”€ ai/               # AI models, providers, tools, workflow logic
β”‚   β”œβ”€β”€ common/           # Shared React components, hooks, context, store
β”‚   β”œβ”€β”€ orchestrator/     # Workflow engine and task management
β”‚   β”œβ”€β”€ shared/           # Shared types, constants, configs, utils, logger
β”‚   β”œβ”€β”€ tailwind-config/  # Shared Tailwind CSS configuration
β”‚   β”œβ”€β”€ typescript-config/# Shared TypeScript configurations
β”‚   └── ui/               # Base UI components (from Shadcn UI)
β”œβ”€β”€ docs/                 # Documentation and guides
β”œβ”€β”€ memory-bank/          # Project context and evolution tracking
└── scripts/              # Utility scripts (e.g., data sync)

πŸ› οΈ Tech Stack

Frontend & Core

  • Framework: Next.js 14 (App Router) with TypeScript
  • Styling: Tailwind CSS + Shadcn UI design system
  • State Management: Zustand + React Query
  • Animations: Framer Motion
  • Icons: Lucide React

Backend & Infrastructure

  • Database: Neon PostgreSQL with Drizzle ORM
  • Authentication: Better Auth (modern session management)
  • Application Security: Arcjet protection (rate limiting, bot detection, attack prevention)
  • Payment Processing: Creem.io integration
  • Local Storage: IndexedDB via Dexie.js
  • Deployment: Fly.io (production-ready)

Development & Build

  • Runtime: Bun (package manager + JavaScript runtime)
  • Monorepo: Turborepo with optimized caching
  • Testing: Vitest with Testing Library
  • Linting: oxlint (faster than ESLint)
  • Type Checking: TypeScript with strict configuration

AI & Integrations

  • AI Providers: OpenAI, Anthropic, Google, Fireworks, Together AI, xAI
  • AI SDK: Vercel AI SDK with reasoning tokens support
  • Document Processing: Multi-format file analysis
  • Web Search: Real-time grounding capabilities

πŸš€ Getting Started

Prerequisites

  • Bun (JavaScript runtime and package manager) - v1.1.19 or higher
  • Node.js (for some Turborepo operations, though Bun is primary)
  • Git for version control

Installation

  1. Clone the repository:

    git clone https://github.com/vinhnx/vtchat.git
    cd vtchat
  2. Install dependencies:

    bun install
  3. Set up environment variables:

    cp apps/web/.env.example apps/web/.env.local

    Configure the following required variables in apps/web/.env.local:

    Essential Services:

    • DATABASE_URL - Neon PostgreSQL connection string
    • BETTER_AUTH_SECRET - Authentication secret key
    • BETTER_AUTH_URL - Authentication URL (http://localhost:3000 for development)

    AI Provider Keys (choose one or more):

    • OPENAI_API_KEY - OpenAI API access
    • ANTHROPIC_API_KEY - Anthropic Claude API access
    • GOOGLE_API_KEY - Google Gemini API access

    Payment & Subscription:

    • CREEM_WEBHOOK_SECRET - Creem.io webhook validation
    • CREEM_API_KEY - Creem.io API access
    • CREEM_PRODUCT_ID - VT Plus subscription product ID

    Security:

    • ARCJET_KEY - Application security and rate limiting
    • NEXT_PUBLIC_BASE_URL - Application base URL
  4. Set up the database:

    cd apps/web
    bun run generate  # Generate database schema
  5. Start the development server:

    bun dev
  6. Open the application: Navigate to http://localhost:3000 in your browser.

Development Commands

# Development
bun dev                 # Start development server with Turbopack
bun build              # Build for production
bun start              # Start production server
bun test               # Run tests
bun test:coverage      # Run tests with coverage

# Code Quality
bun lint               # Lint with oxlint
bun format             # Format code with Prettier
bun format:check       # Check code formatting

# Database
cd apps/web
bun run generate       # Generate Drizzle schema

πŸ”§ Configuration

Environment Setup

The application requires several environment variables for full functionality. Refer to apps/web/.env.example for the complete list. Key configurations include:

  • Database: Neon PostgreSQL for user data and subscriptions
  • Authentication: Better Auth for secure session management
  • AI Providers: Support for multiple AI APIs
  • Payment: Creem.io for subscription management
  • Security: Arcjet for application protection

Subscription Tiers

VTChat implements a dual-tier system:

  • VT_BASE: Free tier with access to 9 AI models
  • VT_PLUS: Premium tier ($10/month) with advanced features

🚒 Deployment

VTChat is production-ready and deployed on Fly.io:

Production Deployment

  • URL: https://vtchat.io.vn
  • Infrastructure: Fly.io with 2-region setup (Singapore primary, Virginia secondary)
  • Performance: 87% faster compilation, optimized bundle size
  • Security: Enterprise-grade security with Arcjet protection
  • Monitoring: Comprehensive error tracking and performance monitoring

Deployment Configuration

  • Memory: 1GB RAM per instance
  • CPU: 1 shared CPU
  • Regions: Asia-Pacific (primary), USA East (secondary)
  • Health Checks: HTTP and TCP monitoring
  • Auto-scaling: Suspend/resume based on traffic

πŸ“š Documentation

Production Readiness

Development & Integration

  • AGENT.md: Development guidelines and conventions
  • Security Guide: Comprehensive Arcjet application security implementation
  • Subscription System: Plan management, caching, and Creem.io integration
  • Customer Portal: User subscription management interface

Project Context

The /memory-bank directory contains contextual documents tracking project evolution, feature implementations, and development insights for continuous improvement.

πŸ” Security

VTChat implements comprehensive security measures:

  • Privacy-First: All conversations stored locally in IndexedDB
  • Authentication: Better Auth with secure session management
  • Application Security: Arcjet protection against bots, DDoS, and attacks
  • Rate Limiting: Prevents abuse with intelligent rate limiting
  • Data Protection: No server-side storage of sensitive chat data
  • Secure Communication: HTTPS enforced, secure headers implemented

πŸ§ͺ Testing

VTChat includes comprehensive testing:

# Run all tests
bun test

# Run tests with UI
bun test:ui

# Run tests with coverage
bun test:coverage

# Run specific test suites
bun test app/tests/rate-limit-simple.test.ts

Testing framework: Vitest with Testing Library for React components.

🀝 Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository and create a feature branch
  2. Follow the coding standards defined in AGENT.md
  3. Write tests for new features
  4. Update documentation as needed
  5. Submit a pull request with a clear description

Development Standards

  • Use TypeScript with strict configuration
  • Follow the existing code style and patterns
  • Ensure all tests pass before submitting
  • Update AGENT.md with any significant changes

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸ† Achievements

  • Zero TypeScript Errors: Complete type safety across the codebase
  • 87% Performance Improvement: Optimized compilation and runtime
  • Production-Ready: Deployed and running in production environment
  • Security Hardened: Comprehensive protection against common threats
  • Privacy-First: Industry-leading approach to user data protection

🎯 Roadmap

  • Mobile app development (React Native)
  • Additional AI provider integrations
  • Advanced collaboration features
  • Enhanced document processing capabilities
  • API access for developers

Visit VTChat | View Documentation | Report Issues

Built with ❀️ by the VTChat team

About

VT is a minimal chat app

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.2%
  • JavaScript 2.4%
  • Other 1.4%