Pulse is a real-time chat application built using Next.js, Typescript, React.js, Socket.io, Kafka, Redis, stream adapters, Supabase for user data storage, NextAuth for secure authentication, and Prisma ORM. It is designed to be scalable and fault-tolerant, with a focus on high performance and low latency.
demo_insta.mp4
The application is divided into three main components: the frontend, the backend, and the message queue.
The frontend is built using React.js and Next.js. It is responsible for rendering the user interface and handling user input. The frontend communicates with the backend using REST API endpoints.
The backend is built using Node.js and Next.js. It is responsible for handling requests from the frontend, authenticating users, and storing data in Supabase. The backend communicates with the message queue using Kafka producers and consumers.
The message queue is built using Kafka and Redis. Kafka is used for message persistence and Redis is used for message caching. The message queue is responsible for handling message delivery between users.
NextAuth is used for secure authentication and easy login and signup. Users can login with their Google account or signup with their email address.
The application uses Socket.io to establish a real-time connection between users. When a user sends a message, the message is sent to the message queue, which then delivers the message to the recipient's Socket.io connection.
Supabase is used to store user data. The backend uses Prisma ORM to interact with the Supabase database.
The application is designed to be scalable. The frontend and backend are stateless, allowing them to be easily scaled up or down. The message queue is designed to handle high volumes of messages, and can be scaled up or down as needed.
The application has the following API endpoints:
POST /auth/login
: Login with email and password.POST /auth/signup
: Signup with email and password.POST /auth/google
: Login with Google account.GET /auth/session
: Get the current user session.POST /auth/logout
: Logout the current user.
POST /messages
: Send a message to the message queue.GET /messages
: Get all messages from the message queue.GET /messages/:id
: Get a specific message from the message queue.
POST /users
: Create a new user.GET /users
: Get all users.GET /users/:id
: Get a specific user.PUT /users/:id
: Update a specific user.DELETE /users/:id
: Delete a specific user.
The application uses the following Kafka topics:
chat.messages
: All messages sent to the message queue.chat.users
: All users created or updated.