/t2chat

Primary LanguageTypeScriptMIT LicenseMIT

T2Chat

The modern, open-source AI chat application.
Explore Features »

Getting Started · Deployment · Contributing · Issues

Github Stars License Commits-per-month Pricing

About T2Chat

chat-interface

AI chat infrastructure for absolutely everyone

The open source ChatGPT alternative. You are in charge of your own data, conversations, and AI models.

ChatGPT and other AI chat tools are incredible. They've revolutionized how we interact with AI. We use them for work, learning, creative projects, and problem-solving. However, most tools are very limited in terms of control, customization, and data ownership.

That's where T2Chat comes in. Self-hosted or hosted by us. Multi-model by design. API-driven and ready to be deployed on your own domain. Full control of your conversations and data.

✨ Features

  • 🤖 Multi-Model AI Support: Integration with multiple AI providers (OpenAI, Google, Groq, OpenRouter, etc.)
  • 💬 Real-time Chat: Instant messaging with AI models using streaming responses
  • 📱 Responsive Design: Beautiful UI that works seamlessly on desktop and mobile
  • 🔐 Secure Authentication: User authentication with Better Auth and PostgreSQL
  • 💾 Data Persistence: Chat history stored securely in Convex database
  • 🎨 Customizable Interface: Dark/light themes with extensive customization options
  • 🗂️ Advanced Chat Management: Organize, rename, share, and delete conversations
  • 🔑 API Key Management: Secure storage and management of your API keys
  • 🎤 Speech Features: Text-to-speech and speech recognition capabilities
  • 📤 File Uploads: Support for file attachments via UploadThing
  • 🔍 Smart Search: Search through your entire conversation history
  • ⚙️ Comprehensive Settings: Extensive customization and personalization options
  • 🌐 Easy Sharing: Share conversations with others securely
  • 📊 Chat Analytics: Track your usage and conversation metrics
  • 🔄 Chat Branching: Create conversation branches for different discussion paths
  • ⚡ Optimized Performance: Fast loading and smooth interactions

🛠️ Built With

Frontend

Backend & Database

  • Convex - Real-time backend-as-a-service
  • Better Auth - Modern authentication solution
  • Dexie - IndexedDB wrapper for local storage

AI & APIs

Development Tools

Getting Started

To get a local copy up and running, please follow these simple steps.

Prerequisites

Here is what you need to be able to run T2Chat.

  • Node.js (Version: >=18.x)
  • npm/yarn/pnpm (npm is used here might switch to pnpm)

If you want to enable any of the available AI integrations, you may want to obtain API keys for each provider. More details can be found below under the AI Providers section.

Development

Setup

  1. Clone the repository

    git clone https://github.com/nyaughh/t2chat.git
    cd t2chat
  2. Install dependencies

    npm install
    # or
    yarn install
    # or
    pnpm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Convex
    CONVEX_DEPLOYMENT=your-convex-deployment-url (eg: dev:blue-bird-144)
    NEXT_PUBLIC_CONVEX_URL=your-convex-url (eg: https://blue-bird-144.convex.cloud)
    NEXT_PUBLIC_CONVEX_SITE_URL=your-convex-site-url (eg: https://blue-bird-144.convex.site)
    
    # Better Auth
    BETTER_AUTH_SECRET=your-auth-secret
    BETTER_AUTH_URL=http://localhost:3000
    
    # UploadThing
    UPLOADTHING_SECRET=your-uploadthing-secret
    UPLOADTHING_APP_ID=your-uploadthing-app-id
    
    # AI Providers
    OPENAI_API_KEY=your-openai-key
    GOOGLE_AI_API_KEY=your-google-ai-key
    GROQ_API_KEY=your-groq-key
  4. Set up Convex

    npx convex dev

    This will:

    • Create a new Convex project (if needed) or use an existing one

    Whille it syncs:

    1. Navigate to your convex dashboard
    2. Select the "dev" environment of your project and go to the "Environmental Variables" tab in Settings
    3. Add the following variables:
      BETTER_AUTH_SECRET
      BETTER_AUTH_URL
      
      GITHUB_CLIENT_ID (for github auth)
      GITHUB_CLIENT_SECRET
      
      OPENAI_API_KEY
      GOOGLE_AI_API_KEY
      GROQ_API_KEY
      
      TAVILY_API_KEY (for web search tool)
      
  5. Start the development server

    npm run dev
    # or
    yarn dev
    # or
    pnpm dev

    Make sure npx convex dev is running in the background.

  6. Open your browser

    Navigate to http://localhost:3000

Deployment

Set up your Convex Production Environment (Required)

Go to your convex dashboard and select the "prod" environment of your project.

Paste the same variables and make sure BETTER_AUTH_URL is set to your production domain.

Vercel

Deploy with Vercel

You can directly deploy your fork to Vercel or use the CLI.

Override the default Build command with npm run build:prod

Add all your environment variables in the Vercel dashboard.

The following variables should be your production variables not the same as the development variables.

CONVEX_DEPLOYMENT=your-convex-deployment-url
NEXT_PUBLIC_CONVEX_URL=your-convex-url 

Railway

Deploy on Railway

Other Platforms

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

  • Netlify
  • DigitalOcean App Platform
  • AWS Amplify
  • Google Cloud Run

Make sure to:

  1. Set all required environment variables
  2. Build the application with npm run build:prod
  3. Configure the start command as npm run start

⚙️ Configuration

AI Providers

Configure AI providers in the Settings → Models & Keys section:

Google AI

  1. Get your API key from Google AI Studio
  2. Add it in settings or set GOOGLE_AI_API_KEY environment variable

Groq

  1. Get your API key from Groq Console
  2. Add it in settings or set GROQ_API_KEY environment variable

OpenRouter

  1. Get your API key from OpenRouter
  2. Access to 100+ models through a single API

Customization

T2Chat supports extensive customization:

  • Themes: Light/dark mode with custom color schemes
  • Fonts: Choose from multiple font options for main text and code
  • User Profile: Set your name, role, and personality traits
  • Behavior: Configure send behavior (Enter vs Ctrl+Enter) and auto-save
  • Speech: Text-to-speech settings and voice selection

📁 Project Structure

t2chat/
├── src/
│   ├── app/                   # Next.js App Router pages
│   │   ├── (chat)/            # Chat-related pages and components
│   │   │   └── chat/          # Chat-related pages and components
│   │   │   ├── settings/      # Settings page
│   │   ├── api/               # API routes (auth, chat, uploadthing)
│   │   ├── auth/              # Authentication pages
│   │   ├── _providers/        # Providers for Convex, Better Auth, etc.
│   ├── components/            # React components
│   │   ├── ui/                # UI components (buttons, inputs, etc.)
│   │   └── settings/          # Settings-specific components
│   ├── hooks/                 # Custom React hooks
│   ├── lib/                   # Utility libraries and configurations
│   └── styles/               # Global styles and CSS
├── convex/                    # Convex backend functions
│   ├── chat/                 # Chat-related backend functions
│   ├── auth.ts               # Authentication configuration
│   └── schema.ts             # Database schema definitions
├── public/                    # Static assets and images
├── package.json              # Dependencies and npm scripts
├── tailwind.config.ts        # Tailwind CSS configuration
├── next.config.ts            # Next.js configuration
└── README.md                 # This file

Repo Activity

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Getting Started

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

Development Guidelines

  • Code Style: Use Prettier for formatting (npm run format)
  • Linting: Ensure ESLint passes (npm run lint)
  • TypeScript: Maintain type safety throughout the codebase
  • Testing: Add tests for new features when applicable
  • Documentation: Update documentation for significant changes

Good First Issues

We have a list of help wanted issues that are great for newcomers. These contain features and bugs with limited scope, perfect for getting started.

License

Distributed under the MIT License. See LICENSE for more information.

This means you can:

  • ✅ Use commercially
  • ✅ Modify and distribute
  • ✅ Use privately
  • ✅ Include in proprietary software

🙏 Acknowledgments

Special thanks to these amazing projects which help power T2Chat:

📞 Support

If you need help with T2Chat:

  1. Check the documentation in this README
  2. Search existing issues on GitHub
  3. Create a new issue if you found a bug
  4. Start a discussion for feature requests or questions

Built by kmrb.tech

⭐ Star us on GitHub if `T2Chat` helps you!