Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Chat Server

A production-ready, real-time chat server built with Go, demonstrating concurrent programming, WebSocket communication, and clean architecture patterns.

Table of Contents

Overview

This project is a real-time chat server that showcases Go's strengths in concurrent programming and network communication. It implements a WebSocket-based messaging system with multiple chat rooms, user presence tracking, and message history persistence.

The application demonstrates:

  • Goroutine management and channel-based communication
  • WebSocket protocol implementation
  • Real-time message broadcasting
  • Clean architecture with separation of concerns
  • Production-ready error handling and logging

Features

Core Functionality

  • Real-time messaging with WebSocket support
  • Multiple chat rooms (general, technology, random)
  • User presence indicators
  • Message history (last 100 messages per room)
  • Persistent message storage in memory

User Features

  • Custom username on join
  • Room switching with /join command
  • User list display with /users command
  • Help system with /help command
  • Current room display with /room command

Technical Features

  • Concurrent client handling with goroutines
  • Graceful shutdown handling
  • Cross-origin resource sharing (CORS) enabled
  • Mobile-responsive web interface
  • Network-wide accessibility

Architecture

┌─────────────────────────────────────────────────────────────┐ │ Client Browser │ │ (WebSocket Connection) │ └──────────────────────────┬──────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ Go Server │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │ │ │ Hub │ │ Client │ │ Message Protocol │ │ │ │ - Registry │ │ - Read Pump │ │ - Chat Messages │ │ │ │ - Rooms │ │ - Write Pump│ │ - System Messages │ │ │ │ - Broadcast │ │ - Commands │ │ - Command Handling │ │ │ └─────────────┘ └─────────────┘ └─────────────────────┘ │ └─────────────────────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ In-Memory Storage │ │ (Message History per Room) │ └─────────────────────────────────────────────────────────────┘

Design Patterns Used

  • Hub Pattern: Centralized client and room management
  • Observer Pattern: Message broadcasting to multiple clients
  • Command Pattern: Chat command processing
  • Factory Pattern: Message creation and validation

Requirements

Tool Version Verification Command
Go 1.21+ go version
Git Latest git --version
Make 3.81+ make --version

About

A production-ready, real-time chat server built with Go, demonstrating concurrent programming, WebSocket communication, and clean architecture patterns.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages