A modern, real-time chat application built with Next.js, featuring guild/server systems, real-time messaging, and a beautiful user interface.
- Real-time Messaging: Instant message delivery powered by Pusher
- Guild/Server System: Create or join private chat servers with invite codes
- Rich Message Types:
- Text messages with emoji support
- File and image uploads
- Interactive polls with real-time voting
- User Authentication: Secure authentication with Clerk
- Presence System: See who's online in real-time
- Message Management:
- Edit your messages
- Delete messages (owners can delete any message in their guild)
- Message read receipts
- Theme Support: Light and dark mode toggle
- Responsive Design: Works seamlessly on desktop and mobile devices
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Database: SQLite with Drizzle ORM
- Real-time: Pusher
- Authentication: Clerk
- State Management: Zustand
- UI Components:
- Heroicons
- Lucide React
- Emoji Picker React
- Node.js 18+
- npm or yarn or pnpm
- A Clerk account (for authentication)
- A Pusher account (for real-time features)
-
Clone the repository:
git clone https://github.com/a-rustacean/chat.git cd chat -
Install dependencies:
npm install
-
Set up environment variables:
Create a
.envfile in the root directory with the following variables:# Database TURSO_DATABASE_URL=database_url TURSO_AUTH_TOKEN=database_auth_token # Clerk Authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key # Pusher (Real-time) PUSHER_APP_ID=your_pusher_app_id NEXT_PUBLIC_PUSHER_KEY=your_pusher_key PUSHER_SECRET=your_pusher_secret NEXT_PUBLIC_PUSHER_CLUSTER=your_pusher_cluster
-
Set up the database:
npm run db:push
Run the development server:
npm run devOpen http://localhost:3000 in your browser to see the application.
npm run dev- Start the development servernpm run build- Build the application for productionnpm run start- Start the production servernpm run lint- Run ESLintnpm run db:push- Push database schema changesnpm run db:studio- Open Drizzle Studio (database GUI)npm run db:generate- Generate database migrations
chat/
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ ├── chat/ # Chat page
│ ├── sign-in/ # Sign-in page
│ ├── sign-up/ # Sign-up page
│ └── page.tsx # Landing page
├── components/ # React components
├── db/ # Database schema and configuration
│ ├── schema.ts # Drizzle schema definitions
│ └── index.ts # Database instance
├── lib/ # Utility functions
├── store/ # Zustand state management
├── public/ # Static assets
└── middleware.ts # Next.js middleware (auth protection)
The application uses SQLite with the following main tables:
- Messages: Store all chat messages with support for different types
- Guilds: Server/guild information
- GuildMembers: User memberships in guilds
- Rooms: Chat rooms within guilds
The easiest way to deploy this application is using Vercel:
- Push your code to a GitHub repository
- Import the project to Vercel
- Add your environment variables in the Vercel dashboard
- Deploy!
The vercel-build script will automatically push database changes and build the application.
- Create an account at clerk.com
- Create a new application
- Copy your publishable key and secret key to
.env
- Create an account at pusher.com
- Create a new Channels app
- Copy your app credentials to
.env - Enable client events in your Pusher dashboard
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Dilshad
- GitHub: @a-rustacean
Built with ❤️ using Next.js and modern web technologies.