Skip to content

Devang47/discord-clone

Repository files navigation

๐ŸŽฎ Discord Clone - Full Stack Real-Time Chat Application

A modern, full-featured Discord clone built with Next.js 13, React, Socket.io, Prisma, TailwindCSS, MySQL, and TypeScript. This application provides real-time messaging, voice/video calls, server management, and a beautiful, responsive user interface.

Discord Clone React TypeScript TailwindCSS Prisma

โœจ Features

๐Ÿ” Authentication & Security

  • Secure Authentication with Clerk
  • Role-based Access Control (Admin, Moderator, Guest)
  • Protected Routes and API endpoints

๐Ÿ’ฌ Real-Time Communication

  • Real-time messaging using Socket.io
  • WebSocket fallback with polling for reliability
  • Message editing and deletion in real-time
  • File attachments support (images, PDFs) via UploadThing
  • Emoji picker for enhanced messaging experience

๐Ÿ“บ Voice & Video Calls

  • Text, Audio, and Video channels
  • 1:1 video calls between members
  • Group voice/video calls using LiveKit
  • High-quality audio/video streaming

๐Ÿข Server Management

  • Create and customize servers with images and names
  • Channel creation (Text, Audio, Video)
  • Member management (Kick, Role changes)
  • Unique invite link generation with full invite system
  • Server settings and permissions

๐ŸŽจ User Experience

  • Beautiful UI with TailwindCSS and ShadcnUI components
  • Dark/Light mode theme switching
  • Fully responsive mobile and desktop design
  • Infinite scroll message loading (batches of 10)
  • Loading states and error handling

๐Ÿ› ๏ธ Technical Features

  • Form validation using react-hook-form and Zod
  • RESTful API with route handlers (app/api)
  • Database ORM with Prisma
  • File upload system with UploadThing
  • Real-time updates across all connected clients

๐Ÿ—๏ธ Tech Stack

Technology Purpose Version
Next.js React framework with SSR/SSG 13.x
React Frontend library 18.x
TypeScript Type-safe JavaScript 5.x
TailwindCSS Utility-first CSS framework 3.x
Prisma Database ORM 5.x
Socket.io Real-time communication 4.x
MySQL Database (PlanetScale) -
Clerk Authentication service 4.x
LiveKit Video/Audio streaming 1.x
UploadThing File upload service 5.x
Zod Schema validation 3.x
React Hook Form Form handling 7.x

๐Ÿš€ Quick Start

Prerequisites

  • Node.js version 18.x.x or higher
  • npm or yarn package manager
  • MySQL database (PlanetScale recommended)
  • Clerk account for authentication
  • UploadThing account for file uploads
  • LiveKit account for video/audio calls

๐Ÿ“ฆ Installation

  1. Clone the repository

    git clone https://github.com/devang47/discord-clone.git
    cd discord-clone
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Environment Setup

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

    # Clerk Authentication
    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
    CLERK_SECRET_KEY=your_clerk_secret_key
    NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
    NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
    NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
    NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
    
    # Database
    DATABASE_URL=your_mysql_database_url
    
    # UploadThing (File Uploads)
    UPLOADTHING_SECRET=your_uploadthing_secret
    UPLOADTHING_APP_ID=your_uploadthing_app_id
    
    # LiveKit (Video/Audio)
    LIVEKIT_API_KEY=your_livekit_api_key
    LIVEKIT_API_SECRET=your_livekit_api_secret
    NEXT_PUBLIC_LIVEKIT_URL=your_livekit_url
  4. Database Setup

    # Generate Prisma client
    npx prisma generate
    
    # Push database schema
    npx prisma db push
    
    # (Optional) Seed the database
    npx prisma db seed
  5. Start the development server

    npm run dev
    # or
    yarn dev

    Open http://localhost:3000 in your browser.

๐Ÿ“ Project Structure

discord-clone/
โ”œโ”€โ”€ app/                    # Next.js 13 app directory
โ”‚   โ”œโ”€โ”€ (auth)/            # Authentication routes
โ”‚   โ”œโ”€โ”€ (invite)/          # Invite handling routes
โ”‚   โ”œโ”€โ”€ (main)/            # Main application routes
โ”‚   โ”œโ”€โ”€ (setup)/           # Initial setup page
โ”‚   โ”œโ”€โ”€ api/               # API routes
โ”‚   โ””โ”€โ”€ globals.css        # Global styles
โ”œโ”€โ”€ components/            # Reusable React components
โ”‚   โ”œโ”€โ”€ chat/              # Chat-related components
โ”‚   โ”œโ”€โ”€ modals/            # Modal components
โ”‚   โ”œโ”€โ”€ navigation/        # Navigation components
โ”‚   โ”œโ”€โ”€ providers/         # Context providers
โ”‚   โ”œโ”€โ”€ server/            # Server-related components
โ”‚   โ””โ”€โ”€ ui/                # UI components (shadcn/ui)
โ”œโ”€โ”€ hooks/                 # Custom React hooks
โ”œโ”€โ”€ lib/                   # Utility functions and configurations
โ”œโ”€โ”€ pages/                 # API routes for Socket.io
โ”œโ”€โ”€ prisma/                # Database schema and migrations
โ””โ”€โ”€ public/                # Static assets

๐Ÿ› ๏ธ Available Scripts

Command Description
npm run dev Start development server
npm run build Build production bundle
npm run start Start production server
npm run lint Run ESLint
npm run lint:fix Fix ESLint errors
npm run type-check Run TypeScript checks

๐ŸŽฏ Key Features Explained

Real-Time Messaging

  • Messages are instantly delivered using Socket.io
  • Support for text, images, and PDF files
  • Message editing and deletion with real-time updates
  • Emoji reactions and rich text formatting

Server & Channel Management

  • Create unlimited servers with custom names and images
  • Organize conversations with Text, Audio, and Video channels
  • Manage members with role-based permissions
  • Generate shareable invite links

Voice & Video Calls

  • High-quality audio/video streaming powered by LiveKit
  • Support for both 1:1 conversations and group calls
  • Screen sharing capabilities
  • Adaptive bitrate for optimal performance

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  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, please open an issue on GitHub or contact the maintainers.


Built with โค๏ธ using Next.js and modern web technologies

About

FullStack Discord Clone: Next.js 13, React, Socket.io, Prisma, Tailwind, MySQL & TypeScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published