Skip to content

priyanshusinha11/chat-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Application Monorepo

This repository is a monorepo for a scalable chat application built with Turborepo and utilizes multiple technologies to ensure scalability, efficiency, and real-time communication.

Overview

This chat application is built using:

  • Frontend: Next.js for the web client.
  • Backend: Node.js for the server-side logic.
  • Message Channeling: Redis is used for pub/sub messaging.
  • Data Storage: PostgreSQL with Prisma for database ORM.
  • Message Queue: Kafka is utilized for distributed messaging and scalability.

Architectural Flow

  1. When a message is sent from the client, it is first sent to Redis for quick pub/sub handling.
  2. The message is then pushed to Kafka to handle distribution to multiple servers.
  3. The message is stored in PostgreSQL via Prisma for persistence.
  4. Finally, the message is distributed to all servers running the application to ensure all clients receive the message in real-time.

Architecture Diagram

Architecture Diagram

Getting Started

Prerequisites

Ensure you have the following installed on your local development machine:

Installation

  1. Clone this repository:

    git clone https://github.com/priyanshusinha11/chat-app.git
    cd chat-app
  2. Install all dependencies:

    yarn install
  3. Set up the database:

    Create a .env file in the root directory with your PostgreSQL connection details:

    DATABASE_URL="postgresql://user:password@localhost:5432/chatdb"

    Then run the following command to set up the database schema:

    yarn prisma migrate dev

Running the Application

To start both the client and server applications:

yarn dev

## Building the Application

This command will run both the Next.js frontend and the Node.js backend simultaneously.

### To build all apps and packages, run:

```bash
yarn build

Technology used

  • Next.js: Framework for building the web client.
  • Node.js: Server-side runtime for handling backend logic.
  • Redis: In-memory data structure store for pub/sub messaging.
  • PostgreSQL: Relational database for message persistence.
  • Prisma: ORM for PostgreSQL to handle database operations.
  • Kafka: Distributed event streaming platform for message queueing.
  • Turborepo: Tool for managing monorepos, build optimization, and remote caching.
  • Yarn: Package manager for managing project dependencies.

Useful Commands

  • Start Development: yarn dev - Starts both frontend and backend servers.
  • Build Application: yarn build - Builds all apps and packages.
  • Database Migration: yarn prisma migrate dev - Runs the Prisma migrations.

About

A scalable, real-time chat application built with Next.js, Node.js, Redis, PostgreSQL, Kafka, and Prisma. This Turborepo project provides a robust and efficient architecture for handling large-scale chat communication, leveraging the power of distributed systems and modern technologies.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages