A modern, full-stack AI chat application built with Next.js 15, featuring support for multiple AI providers, real-time messaging, and a beautiful responsive UI.
- Multiple AI Providers: Support for OpenAI, Mistral, Anthropic (Claude), Google (Gemini), and OpenRouter
- Model Selection: Choose from GPT-4o, Claude 3.5 Sonnet, Gemini 2.0 Flash, Mistral Large, and more
- Real-time Streaming: Get responses as they're generated with streaming support
- Custom API Keys: Use your own API keys for cost optimization
- Real-time Messaging: Instant message delivery and responses
- Chat History: Persistent conversation storage with PostgreSQL
- Message Formatting: Full Markdown support with code syntax highlighting
- Message Management: Pin important chats, delete conversations
- Responsive Design: Optimized for mobile, tablet, and desktop
- Clerk Authentication: Secure user management with Google OAuth
- Session Management: Persistent login sessions
- User Profiles: Customizable user settings and preferences
- Modern Design: Clean, intuitive interface with shadcn/ui components
- Dark/Light Mode: Theme switching with system preference detection
- Animations: Smooth transitions and loading states
- Accessibility: WCAG compliant design
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- Shadcn/ui - Modern UI component library
- Radix UI - Accessible component primitives
- Lucide React - Beautiful icons
- Next.js API Routes - Serverless API endpoints
- Drizzle ORM - Type-safe database queries
- PostgreSQL - Reliable relational database
- Neon Database - Serverless PostgreSQL hosting
- Vercel AI SDK - AI provider integration
- OpenAI API - GPT models
- Anthropic API - Claude models
- Google AI API - Gemini models
- Mistral API - Mistral models
- OpenRouter - Multiple model access
- Clerk - User authentication and management
- Node.js 18+
- npm, yarn, or pnpm
- PostgreSQL database (or Neon account)
- Clerk account for authentication
- AI API keys (optional, for custom usage)
-
Clone the repository
git clone https://github.com/yourusername/t3chat-clone.git cd t3chat-clone
-
Install dependencies
npm install # or yarn install # or pnpm install
-
Set up environment variables
Create a
.env.local
file in the root directory:# Database DATABASE_URL=your_postgresql_connection_string # Clerk Authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth # AI API Keys (Optional - users can add their own) OPENAI_API_KEY=your_openai_api_key MISTRAL_API_KEY=your_mistral_api_key OPENROUTER_API_KEY=your_openrouter_api_key UPSTASH_REDIS_REST_URL=your_upstash_url UPSTASH_REDIS_REST_TOKEN=your_upstash_token
-
Set up the database
npm run db:generate npm run db:migrate
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
- Sign in with your Google account via Clerk
- Select an AI model from the dropdown
- Start typing your message
- Press Enter or click Send to get AI responses
- Choose from multiple AI providers and models
- Each model has different capabilities and pricing
- Premium models offer better performance
- Add your own API keys in Settings for cost optimization
- Supports OpenAI, OpenRouter, and other providers
- Keys are stored locally in your browser
- View chat history in the sidebar
- Pin important conversations
- Delete conversations you no longer need
t3chat-clone/
βββ app/ # Next.js App Router
β βββ (auth)/ # Authentication pages
β βββ (main)/ # Main application pages
β βββ api/ # API routes
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ ui/ # Base UI components
β βββ settings/ # Settings components
β βββ ... # Feature components
βββ contexts/ # React contexts
βββ hooks/ # Custom React hooks
βββ lib/ # Utilities and configurations
β βββ ai/ # AI provider configurations
β βββ ... # Other utilities
βββ server/ # Server-side code
β βββ actions/ # Server actions
β βββ db/ # Database schema and config
βββ styles/ # Global styles
npm run dev
- Start development servernpm run build
- Build for productionnpm run start
- Start production servernpm run lint
- Run ESLint
npm run db:generate
- Generate database migrationsnpm run db:migrate
- Run database migrationsnpm run db:studio
- Open Drizzle Studio
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Vercel for the AI SDK and hosting platform
- Shadcn for the beautiful UI components
- Clerk for authentication services
- Neon for serverless PostgreSQL
- All the AI providers for their amazing APIs
- Real-time chat interface with message history
- Support for multiple AI models (e.g., GPT-4, Mistral)
- Message streaming for real-time responses
- Markdown support in messages
- Code block formatting
- Message status indicators (sending, sent, error)
- Message timestamps
- User avatars and display names
- User registration and login
- OAuth integration (Google)
- [] User profile management
- Session management
- Chat history persistence
- Real-time synchronization across devices
- Message search functionality
- Chat export/import
- Data backup system
- Responsive design (mobile, tablet, desktop)
- Dark/Light mode
- Loading states and animations
- Error handling and user feedback
- Keyboard shortcuts
- Accessibility compliance (WCAG 2.1)
- Chat branching (create alternative conversation paths)
- Chat sharing with unique URLs
- Collaborative chat rooms
- Message reactions and replies
- Voice input/output (+++)
- Custom AI model fine-tuning
- File upload support (images, PDFs, documents)
- File preview
- Image generation with AI
- Document summarization
- OCR for image text extraction
- Web search integration
- Context-aware responses
- Multi-language support
- Custom AI model training
- AI-powered code completion
- AI-powered content summarization
- Syntax highlighting for code blocks
- Code execution environment
- API documentation
- Webhook support
- Rate limiting and usage tracking
- Resumable streams
- End-to-end encryption
- Rate limiting
- DDOS protection
- Performance monitoring
- Error tracking and logging
- Next.js 15 (App Router)
- TypeScript
- Tailwind CSS
- Shadcn/ui
- vercel ai sdk
- Next.js API Routes
- OpenAI API
- Mistral API
- Openrouter API