A modern, scalable chat application built with Next.js, Express, Redis, and Apache Kafka. This application demonstrates real-time messaging capabilities with distributed system architecture.
- 🔐 Secure authentication with Google OAuth
- 💬 Real-time messaging using Socket.IO
- 📡 Message queueing with Apache Kafka
- 🔄 Redis for session management and caching
- 🎯 TypeScript for type safety
- 🎨 Modern UI with Tailwind CSS
- 🔍 Message persistence with PostgreSQL
- 🌐 Scalable architecture
graph LR
Client[Next.js Client] --> API[Express API]
API --> Redis[Redis Cache]
API --> Kafka[Apache Kafka]
API --> DB[(PostgreSQL)]
Kafka --> Consumer[Kafka Consumer]
Consumer --> DB
- Next.js 14
- TypeScript
- Tailwind CSS
- Socket.IO Client
- Next-Auth
- Radix UI Components
- Express.js
- Node-rdkafka
- Socket.IO
- Redis Streams
- Prisma ORM
- PostgreSQL
- Node.js >= 18
- Redis Server
- Apache Kafka
- PostgreSQL
- Aiven Account (for Kafka service)
- Clone the repository
git clone https://github.com/yourusername/kafka-redis-chat-app.git
cd kafka-redis-chat-app- Install dependencies
# Install server dependencies
cd server
pnpm install
# Install client dependencies
cd ../client
pnpm install- Configure Environment Variables
Server (.env):
PORT=8000
CLIENT_APP_URL=http://localhost:3001
APP_URL=http://localhost:8000
JWT_SECRET=your_jwt_secret
# Database
DATABASE_URL=your_postgresql_url
# Kafka Configuration
KAFKA_BROKER=your_kafka_broker
KAFKA_USERNAME=your_username
KAFKA_PASSWORD=your_password
KAFKA_TOPIC=chats
KAFKA_SSL_ENABLED=true
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379Client (.env.local):
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret- Set up the Database
cd server
npx prisma migrate dev- Start the Development Servers
# Start the backend server
cd server
pnpm dev
# Start the frontend application
cd client
pnpm dev├── client/ # Next.js frontend
│ ├── src/
│ │ ├── app/ # Next.js app router
│ │ ├── components/ # React components
│ │ ├── lib/ # Utilities and configs
│ │ └── validations/ # Schema validations
│ └── public/ # Static assets
│
├── server/ # Express backend
│ ├── src/
│ │ ├── config/ # Configuration files
│ │ ├── controllers/ # Route controllers
│ │ ├── middleware/ # Express middleware
│ │ └── routes/ # API routes
│ └── prisma/ # Database schema
- SSL/TLS encryption for Kafka connections
- JWT authentication for API routes
- Google OAuth2.0 integration
- Secure session management with Redis
- Input validation and sanitization
- Socket.IO Admin UI for real-time monitoring
- Kafka Consumer lag monitoring
- Redis metrics tracking
- API endpoint monitoring
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details
Your Name - @Nobody_crypto_H Project Link: https://github.com/Harmeet10000/kafka-redis-chat-app