Skip to content

uttam-on-git/synctalk-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SyncTalk - Real-Time Chat Backend

License: MIT TypeScript Node.js Socket.IO PostgreSQL Prisma

This repository contains the backend server for SyncTalk, a full-stack, real-time chat application. It provides a hybrid architecture with a secure REST API for authentication and a real-time WebSocket server for instant messaging.


✨ Features

  • Real-Time Communication: Utilizes WebSockets via Socket.IO to push messages and updates to all connected clients instantly.
  • Secure User Authentication: Implements a complete email/password registration and login system from scratch, featuring secure password hashing with Argon2.
  • JWT-Based Authorization: Uses JSON Web Tokens to secure all private API endpoints and WebSocket events.
  • Multi-Room Chat: Includes API endpoints for creating and listing chat rooms, with WebSocket logic to manage users joining and leaving rooms.
  • Robust & Type-Safe: Built with TypeScript and uses Zod for strict, schema-based input validation on all critical API routes.
  • Persistent Database: Comes with a pre-configured Docker Compose file for a consistent and persistent local PostgreSQL database, managed by the Prisma ORM.

🛠️ Tech Stack


🚀 Getting Started

Follow these instructions to get a local copy of the backend up and running.

Prerequisites

Installation & Setup

  1. Clone the repository:

    git clone [https://github.com/your-username/synctalk-backend.git](https://github.com/your-username/synctalk-backend.git)
    cd synctalk-backend
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    • Make a copy of the example environment file: cp .env.example .env
    • Open the .env file and fill in your database password and a strong JWT_SECRET.
  4. Start the database:

    • Make sure Docker is running.
    • Run docker-compose up -d to start the PostgreSQL container.
  5. Run database migrations:

    • This will create the User, Room, and Message tables.
      npx prisma migrate dev

Running the Application

  • To start the development server with hot-reloading:
    npm run dev
  • The server will be running at http://localhost:3001.

⚙️ API Endpoints

Method Route Protection Description
POST /api/auth/register Public Creates a new user account.
POST /api/auth/login Public Logs in a user and returns a JWT.
POST /api/rooms Private Creates a new chat room.
GET /api/rooms Private Retrieves a list of all available rooms.
GET /api/rooms/:roomId/messages Private Retrieves message history for a room.
</markdo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published