๐ฎ Discord
๐ About The Project
Discord is a modern, feature-packed, real-time chat application built with Next.js, TypeScript, Prisma, and TailwindCSS. This project simulates a Discord-like environment, allowing users to create and join servers, participate in text and voice channels, share media, and manage servers, all in real-time.
With integrations like Clerk for authentication and LiveKit for media communication, Be-A-Guptaji Discord ensures that all real-time interactions (text, voice, video) are secure and scalable. It is designed for developers and community managers who want to create and manage online communities with ease.
โจ Key Features
- ๐ Clerk Authentication: Secure login, sign-up, and session management.
- ๐ฃ Real-Time Messaging: Instant communication via WebSocket.
- โ๏ธ Server & Channel Management: Create, manage, and organize servers and channels.
- ๐ File Uploads: Upload and share files in various channels.
- ๐ฅ Media Rooms: Audio and video communication with LiveKit.
- ๐ผ Dynamic User Interface: Built with TailwindCSS to ensure a modern and responsive layout.
- ๐ฌ Text Chat: Full-featured chat interface with emoji support, file sharing, and more.
- ๐ User Management: Assign roles, create private channels, and control server access.
๐ธ Screenshots
Sign-In Page
Create New Server
Server DashBoard
Real Time Chatting
Audio Room
Video Room
Create New Channel
Search
Server Action
Members List
๐๏ธ Architecture
The application architecture is designed for modularity, scalability, and performance. The architecture follows a client-server model, which is broken down as follows:
-
Frontend (Next.js + TailwindCSS):
- Handles rendering of UI components like the server dashboard, chat rooms, and media room interfaces.
- Manages client-side routing with dynamic route handling for each server.
- Implements state management via Zustand to manage app-level state.
-
Backend (Next.js API Routes):
- Handles real-time WebSocket communication and provides REST API routes for server management.
- Processes requests for creating and managing servers, channels, and messages.
-
Authentication (Clerk):
- Ensures secure user authentication with features like social login (Google, GitHub), email-based sign-up, and session management.
-
Database (Prisma + PostgreSQL):
- Stores user data, server information, channels, messages, roles, and more using Prisma ORM connected to PostgreSQL.
-
Real-Time Communication (LiveKit):
- Manages real-time audio and video communication in media rooms (video chat).
graph TD
%% ==============================
%% CLIENT LAYER
%% ==============================
subgraph Client
U[๐ฅ๏ธ User Browser] --> F[๐ป Next.js Frontend]
end
%% ==============================
%% BACKEND & API
%% ==============================
subgraph Backend
F --> API[โ๏ธ Next.js API Routes]
API --> DB[(๐๏ธ PostgreSQL via Prisma)]
API --> WebSocket[๐ Real-Time WebSocket]
end
%% ==============================
%% AUTHENTICATION
%% ==============================
subgraph Authentication
F --> Clerk[๐ Clerk Authentication Service]
Clerk -->|โ
Authenticate User| U
end
%% ==============================
%% MEDIA SERVICES
%% ==============================
subgraph Services
API --> LS[๐ฅ LiveKit - Video/Audio Communication]
end
%% ==============================
%% FILE UPLOAD SERVICE
%% ==============================
subgraph FileUpload
API --> Uploadthing[๐ค Uploadthing - File Upload Service]
end
%% ==============================
%% FLOWS & INTERACTIONS
%% ==============================
U -->|๐ Login| Clerk
Clerk -->|๐ Session Token| F
U -->|๐ก Join Server| API
API -->|๐ Retrieve Data| DB
API -->|๐ฌ Send/Receive Real-Time Messages| WebSocket
API -->|๐ง Join Media Call| LS
LS -->|๐บ Real-Time Media Streaming| U
API -->|๐ค File Upload| Uploadthing
Uploadthing -->|๐พ Store Files| DB
%% ==============================
%% COLOR STYLING
%% ==============================
classDef client fill:#6ac6b7,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef backend fill:#f1a4cb,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef auth fill:#92f6c5,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef db fill:#f1e1a4,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef ws fill:#92d0f9,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef services fill:#82c7f9,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef upload fill:#ffbcab,stroke:#000,stroke-width:2px,color:#000,font-weight:bold;
classDef user fill:#5c89b0,stroke:#000,stroke-width:2px,color:#fff,font-weight:bold;
%% Apply Classes
class U user;
class F client;
class API backend;
class DB db;
class WebSocket ws;
class Clerk auth;
class LS services;
class Uploadthing upload;
๐ Built With
- Frontend: Next.js 15, TypeScript, TailwindCSS
- Backend: Prisma ORM, PostgreSQL
- Authentication: Clerk
- Real-Time Communication: WebSocket, LiveKit
- State Management: Zustand
- File Uploads: Uploadthing
โ๏ธ Getting Started
Prerequisites
Make sure you have the following installed:
- Node.js 18+
- PostgreSQL (for database)
- Clerk API Key (for user authentication)
- LiveKit API Key (for real-time media rooms)
Installation
- Clone the repository:
git clone https://github.com/username/be-a-guptaji-discord.git
cd be-a-guptaji-discord
- Install the dependencies:
npm install
- Configure environment variables:
Create a .env.local file and set the following variables:
DATABASE_URL=your_postgres_connection_string
CLERK_API_KEY=your_clerk_api_key
LIVEKIT_API_KEY=your_livekit_api_key
- Set up the database:
Install Prisma and apply the migrations to set up your database.
npm install prisma --save-dev
npx prisma init
npx prisma migrate dev
npx prisma generate
- Run the application:
npm run dev
Visit http://localhost:3000 to interact with the application.
๐ Directory Structure
The project is organized as follows:
Directory structure:
โโโ discord/
โโโ README.md
โโโ components.json
โโโ eslint.config.mjs
โโโ LICENSE
โโโ middleware.ts
โโโ next.config.ts
โโโ package.json
โโโ postcss.config.mjs
โโโ tsconfig.json
โโโ types.ts
โโโ .env.samples
โโโ .prettierignore
โโโ .prettierrc.json
โโโ app/
โ โโโ globals.css
โ โโโ layout.tsx
โ โโโ not-found.tsx
โ โโโ (auth)/
โ โ โโโ layout.tsx
โ โ โโโ (routes)/
โ โ โโโ sign-in/
โ โ โ โโโ [[...sign-in]]/
โ โ โ โโโ page.tsx
โ โ โโโ sign-up/
โ โ โโโ [[...sign-up]]/
โ โ โโโ page.tsx
โ โโโ (invite)/
โ โ โโโ (routes)/
โ โ โโโ invite/
โ โ โโโ [inviteCode]/
โ โ โโโ page.tsx
โ โโโ (main)/
โ โ โโโ layout.tsx
โ โ โโโ (routes)/
โ โ โโโ server/
โ โ โโโ [serverID]/
โ โ โโโ layout.tsx
โ โ โโโ page.tsx
โ โ โโโ channel/
โ โ โ โโโ [channelID]/
โ โ โ โโโ page.tsx
โ โ โโโ conversation/
โ โ โโโ [memberID]/
โ โ โโโ page.tsx
โ โโโ (setup)/
โ โ โโโ page.tsx
โ โโโ api/
โ โโโ channels/
โ โ โโโ route.ts
โ โ โโโ [channelID]/
โ โ โโโ route.ts
โ โโโ directMessages/
โ โ โโโ route.ts
โ โโโ members/
โ โ โโโ [memberID]/
โ โ โโโ route.ts
โ โโโ messages/
โ โ โโโ route.ts
โ โโโ servers/
โ โ โโโ route.ts
โ โ โโโ [serverID]/
โ โ โโโ route.ts
โ โ โโโ invite-code/
โ โ โ โโโ route.ts
โ โ โโโ leave/
โ โ โโโ route.ts
โ โโโ token/
โ โ โโโ route.ts
โ โโโ uploadthing/
โ โโโ core.ts
โ โโโ route.ts
โโโ components/
โ โโโ actionToolTip.tsx
โ โโโ emojiPicker.tsx
โ โโโ fileUpload.tsx
โ โโโ mediaRoom.tsx
โ โโโ mobileToggle.tsx
โ โโโ modeToggle.tsx
โ โโโ socketIndicator.tsx
โ โโโ userAvatar.tsx
โ โโโ chat/
โ โ โโโ chatHeader.tsx
โ โ โโโ chatInput.tsx
โ โ โโโ chatItem.tsx
โ โ โโโ chatMessage.tsx
โ โ โโโ chatVideoButton.tsx
โ โ โโโ chatWelcome.tsx
โ โโโ modals/
โ โ โโโ createChannelModal.tsx
โ โ โโโ createServerModal.tsx
โ โ โโโ deleteChannelModal.tsx
โ โ โโโ deleteMessageModal.tsx
โ โ โโโ deleteServerModal.tsx
โ โ โโโ editChannelModal.tsx
โ โ โโโ editServerModal.tsx
โ โ โโโ initialModal.tsx
โ โ โโโ inviteModal.tsx
โ โ โโโ leaveServerModal.tsx
โ โ โโโ membersModal.tsx
โ โ โโโ messageFileModal.tsx
โ โโโ navigation/
โ โ โโโ navigationAction.tsx
โ โ โโโ navigationItem.tsx
โ โ โโโ navigationSidebar.tsx
โ โโโ providers/
โ โ โโโ modalProvider.tsx
โ โ โโโ queryProvider.tsx
โ โ โโโ socketProvider.tsx
โ โ โโโ themeProvider.tsx
โ โโโ server/
โ โ โโโ serverChannel.tsx
โ โ โโโ serverHeader.tsx
โ โ โโโ serverMember.tsx
โ โ โโโ serverSearch.tsx
โ โ โโโ serverSection.tsx
โ โ โโโ serverSidebar.tsx
โ โโโ ui/
โ โโโ avatar.tsx
โ โโโ badge.tsx
โ โโโ button.tsx
โ โโโ command.tsx
โ โโโ dialog.tsx
โ โโโ dropdown-menu.tsx
โ โโโ form.tsx
โ โโโ input.tsx
โ โโโ label.tsx
โ โโโ popover.tsx
โ โโโ scroll-area.tsx
โ โโโ select.tsx
โ โโโ separator.tsx
โ โโโ sheet.tsx
โ โโโ tooltip.tsx
โโโ hooks/
โ โโโ useChatQuery.ts
โ โโโ useChatScroll.ts
โ โโโ useChatSocket.ts
โ โโโ useModal.ts
โ โโโ useOrigin.ts
โโโ lib/
โ โโโ conversation.ts
โ โโโ currentProfile.ts
โ โโโ currentProfilePages.ts
โ โโโ db.ts
โ โโโ initialProfile.ts
โ โโโ uploadthing.ts
โ โโโ utils.ts
โ โโโ generated/
โ โโโ prisma/
โ โโโ client/
โ โโโ client.d.ts
โ โโโ client.js
โ โโโ default.d.ts
โ โโโ default.js
โ โโโ edge.d.ts
โ โโโ edge.js
โ โโโ index-browser.js
โ โโโ index.js
โ โโโ package.json
โ โโโ schema.prisma
โ โโโ wasm.d.ts
โ โโโ wasm.js
โ โโโ runtime/
โ โโโ index-browser.d.ts
โโโ pages/
โ โโโ api/
โ โโโ socket/
โ โโโ io.ts
โ โโโ directMessages/
โ โ โโโ [directMessageID].ts
โ โ โโโ index.ts
โ โโโ messages/
โ โโโ [messageID].ts
โ โโโ index.ts
โโโ prisma/
โโโ schema.prisma
Key Folders and Files:
- /components: Contains reusable components like chat input, server sidebar, message display, etc.
- /pages: Includes the main routes for pages like login, chat, and server pages.
- /api: Server-side route handlers for database interactions and real-time communication.
- /prisma: Prisma schema and client for database interaction.
- /styles: TailwindCSS styles and global styling.
๐ Authentication
The application uses Clerk for handling user authentication, including login, signup, and session management. Clerk supports social login providers like Google, GitHub, and more. It simplifies handling user authentication and ensures secure access to your application.
๐ Real-Time Communication
The LiveKit integration powers video and audio communication in media rooms. The application allows users to host video calls, making it more than just a text-based chat system.
- WebSocket: The app uses WebSocket to send real-time messages between users and chat rooms.
- LiveKit: Provides support for video/audio communication, enabling users to join live media rooms and interact in real-time.
๐ฃ๏ธ Roadmap
- [x] User Authentication with Clerk
- [x] Real-Time Messaging with WebSocket
- [x] Media Rooms with LiveKit
- [ ] Team Collaboration Support
- [ ] Channel Management Enhancements
- [ ] Export to PDF/HTML
๐ License
MIT License ยฉ 2025 Aryan Baadlas
๐ฌ Contact
๐จโ๐ป Aryan Baadlas
๐ง [email protected]
โญ Show some love!
If you like this project, give it a star โญ on GitHub!