Skip to content

Better-Chat is a Next.js 15 app that lets you chat with multiple AIs like OpenAI, Gemini, and Claude in one place.

License

Notifications You must be signed in to change notification settings

akdevv/better-chat

Repository files navigation

Better Chat

A modern, feature-rich AI chat application built with Next.js 15 that supports multiple AI providers including OpenAI, Anthropic Claude, Google Gemini, and Groq. The application provides a seamless chatting experience with file uploads, user management, and a beautiful, responsive interface.

Better Chat TypeScript Tailwind CSS Prisma

✨ Features

πŸ€– Multi-Provider AI Support

  • OpenAI: GPT-4o, GPT-4o Mini
  • Anthropic: Claude Opus 4, Claude Sonnet 4
  • Google: Gemini 2.5 Pro, Gemini 2.5 Flash
  • Groq: DeepSeek R1, Llama 4 (Free models)

πŸ’¬ Advanced Chat Features

  • Real-time streaming responses
  • File upload support (images, PDFs, text files, code)
  • Vision-capable models for image analysis
  • Thinking models support
  • Chat history and management
  • Star/favorite chats
  • Auto-generated chat titles

πŸ” User Management

  • NextAuth.js authentication
  • User registration and login
  • Secure API key management with encryption
  • Profile and usage statistics
  • Settings management

🎨 Modern UI/UX

  • Responsive design for all devices
  • Dark/light mode support
  • Beautiful animations and transitions
  • Mobile-friendly sidebar
  • Drag-and-drop file uploads
  • Syntax highlighting for code blocks
  • Markdown rendering with LaTeX support

πŸš€ Tech Stack

  • Framework: Next.js 15 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS v4
  • Database: PostgreSQL with Prisma ORM
  • Authentication: NextAuth.js v5
  • UI Components: Radix UI primitives
  • File Uploads: UploadThing
  • AI SDKs: OpenAI, Anthropic, Google AI, Groq
  • Deployment: Vercel-ready

πŸ“ Project Structure

better-chat/
β”œβ”€β”€ app/                          # Next.js 15 app directory
β”‚   β”œβ”€β”€ (main)/                   # Main authenticated routes
β”‚   β”‚   β”œβ”€β”€ chat/                 # Chat interface
β”‚   β”‚   └── settings/             # User settings
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ chats/                # Chat management
β”‚   β”‚   β”œβ”€β”€ keys/                 # API key management
β”‚   β”‚   └── files/                # File upload handling
β”‚   β”œβ”€β”€ auth/                     # Authentication pages
β”‚   └── globals.css               # Global styles
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ chat/                     # Chat-related components
β”‚   β”œβ”€β”€ sidebar/                  # Navigation sidebar
β”‚   β”œβ”€β”€ settings/                 # Settings components
β”‚   β”œβ”€β”€ ui/                       # Reusable UI components
β”‚   └── shared/                   # Shared components
β”œβ”€β”€ contexts/                     # React contexts
β”œβ”€β”€ hooks/                        # Custom React hooks
β”œβ”€β”€ lib/                          # Utility libraries
β”‚   β”œβ”€β”€ ai/                       # AI provider integrations
β”‚   β”œβ”€β”€ services/                 # Business logic services
β”‚   β”œβ”€β”€ types/                    # TypeScript type definitions
β”‚   └── utils.ts                  # Utility functions
β”œβ”€β”€ prisma/                       # Database schema and migrations
β”œβ”€β”€ public/                       # Static assets
β”œβ”€β”€ middleware.ts                 # Next.js middleware
└── package.json                  # Dependencies and scripts

πŸ› οΈ Getting Started

Prerequisites

  • Node.js 18+ or Bun
  • PostgreSQL database
  • AI provider API keys (optional for free Groq models)

Installation

  1. Clone the repository

    git clone https://github.com/your-username/better-chat.git
    cd better-chat
  2. Install dependencies

    npm install
    # or
    bun install
  3. Set up environment variables

    cp .env.example .env.local
  4. Configure your environment variables (see Environment Variables)

  5. Set up the database

    npx prisma generate
    npx prisma db push
  6. Run the development server

    npm run dev
    # or
    bun dev
  7. Open your browser Navigate to http://localhost:3000

πŸ”§ Environment Variables

Create a .env.local file in the root directory with the following variables:

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/better_chat"
DIRECT_URL="postgresql://username:password@localhost:5432/better_chat"

# NextAuth.js
NEXTAUTH_SECRET="your-nextauth-secret-key-here"
NEXTAUTH_URL="http://localhost:3000"

# AI Provider API Keys (optional - Groq models are free)
OPENAI_API_KEY="your-openai-api-key"
ANTHROPIC_API_KEY="your-anthropic-api-key"
GOOGLE_AI_API_KEY="your-google-ai-api-key"
GROQ_API_KEY="your-groq-api-key"

# File Upload (UploadThing)
UPLOADTHING_SECRET="your-uploadthing-secret"
UPLOADTHING_APP_ID="your-uploadthing-app-id"

# Encryption Key for API Keys
ENCRYPTION_KEY="your-32-character-encryption-key"

Getting API Keys

πŸ“œ Available Scripts

# Development
npm run dev          # Start development server with Turbopack
bun dev             # Start development server with Bun

# Production
npm run build       # Build for production
npm run start       # Start production server

# Database
npx prisma generate # Generate Prisma client
npx prisma db push  # Push schema changes to database
npx prisma studio   # Open Prisma Studio

# Linting
npm run lint        # Run ESLint

🎯 Features in Detail

AI Model Support

  • Free Models: DeepSeek R1 and Llama 4 via Groq (no API key required)
  • Premium Models: Access to latest OpenAI, Anthropic, and Google models
  • Vision Support: Upload and analyze images with vision-capable models
  • Thinking Models: Support for reasoning-capable models

File Handling

  • Supported Formats: Images (PNG, JPG, WebP), PDFs, text files, code files
  • Drag & Drop: Intuitive file upload interface
  • File Preview: Preview uploaded files before sending
  • Context Integration: Files are automatically included in chat context

User Experience

  • Responsive Design: Works seamlessly on desktop, tablet, and mobile
  • Dark/Light Mode: Automatic theme switching support
  • Real-time Streaming: See AI responses as they're generated
  • Chat Management: Organize, rename, star, and delete chats
  • Usage Statistics: Track your API usage and costs

πŸš€ Deployment

Vercel (Recommended)

  1. Push your code to a Git repository
  2. Import your project to Vercel
  3. Add your environment variables in the Vercel dashboard
  4. Deploy automatically

Other Platforms

The application can be deployed to any platform that supports Next.js:

  • Netlify
  • Railway
  • AWS Amplify
  • DigitalOcean App Platform

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

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

πŸ™ Acknowledgments

πŸ“ž Support

If you have any questions or need help getting started, please open an issue on GitHub.


Made with ❀️ using Next.js and modern web technologies

About

Better-Chat is a Next.js 15 app that lets you chat with multiple AIs like OpenAI, Gemini, and Claude in one place.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published