Skip to content

MeleshkoDmitriy/websocket-chat-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WebSocket Chat Application

A real-time chat application built with React and Node.js using WebSocket technology for instant messaging.

πŸš€ Features

  • Real-time messaging - Instant message delivery using WebSocket connections
  • Room-based chat - Join different chat rooms with multiple users
  • User management - Track users in each room with live updates
  • Emoji support - Built-in emoji picker for expressive messaging
  • Responsive design - Modern UI with custom components and styling
  • Message types - Different styling for own messages, others, and bot notifications

πŸ—οΈ Architecture

Backend (/backend)

  • Express.js server with Socket.IO for WebSocket connections
  • Modular structure with separated handlers, services, and utilities
  • In-memory user management for active chat sessions
  • CORS enabled for cross-origin requests

Frontend (/frontend)

  • React 19 with TypeScript for type safety
  • React Router for navigation between pages
  • Less with CSS modules for styling
  • Socket.IO Client for real-time communication

πŸ› οΈ Tech Stack

Backend Technologies

  • Node.js - Runtime environment
  • Express.js - Web framework
  • Socket.IO - WebSocket library for real-time communication
  • CORS - Cross-origin resource sharing
  • dotenv - Environment variable management

Frontend Technologies

  • React 19 - UI library
  • TypeScript - Type-safe JavaScript
  • Socket.IO Client - WebSocket client
  • React Router DOM - Client-side routing
  • Less - CSS preprocessor
  • Emoji Picker React - Emoji selection component
  • React Icons - Icon library
  • Vite - Build tool and dev server

πŸ“ Project Structure

websocket-chat-app/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ config/          # Configuration files
β”‚   β”œβ”€β”€ constants/        # Application constants
β”‚   β”œβ”€β”€ database/         # User management logic
β”‚   β”œβ”€β”€ routes/          # Express routes
β”‚   β”œβ”€β”€ socket/          # WebSocket handlers
β”‚   β”‚   β”œβ”€β”€ handlers/    # Event handlers
β”‚   β”‚   β”œβ”€β”€ events.js    # Socket event constants
β”‚   β”‚   └── socketManager.js
β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   └── index.js         # Main server file
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/  # Reusable UI components
    β”‚   β”œβ”€β”€ pages/       # Application pages
    β”‚   β”œβ”€β”€ styles/      # Global styles and variables
    β”‚   β”œβ”€β”€ types/       # TypeScript type definitions
    β”‚   └── constants/   # Frontend constants
    └── public/          # Static assets

Real-time Communication

  • Uses WebSocket connections for instant message delivery
  • No page refresh needed for new messages
  • Live user count updates in each room

Message Types

  • Own messages - Light purple background, dark text
  • Other users - Dark background, light text
  • Bot messages - Blue background, white text (for join/leave notifications)

Room System

  • Multiple users can join the same room
  • Users are tracked per room
  • Automatic notifications when users join or leave

About

πŸ”Œ [Backend]: Socket.IO, Node.js, Express; [Frontend]: React, Less

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published