Skip to content

About

πŸš€ A simple, real-time chat application built with Go and WebSockets, featuring a clean web interface for instant messaging. Perfect for learning WebSocket implementation and real-time communication patterns.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Go Real-time Chat App

A simple, real-time chat application built with Go and WebSockets, featuring a clean web interface for instant messaging.

Go Version License: MIT WebSocket PRs Welcome

✨ Features

  • πŸ”„ Real-time messaging - Instant message delivery using WebSockets
  • πŸ‘₯ Multi-user support - Multiple users can chat simultaneously
  • 🌐 Web-based interface - Clean, responsive HTML/CSS/JavaScript client
  • ⚑ Lightweight - Minimal dependencies, fast performance
  • 🎯 Simple setup - Get up and running in minutes
  • 🌍 Cross-platform - Works on Linux, macOS, and Windows
  • πŸ“± Mobile-friendly - Responsive design for mobile devices

🎯 Demo

🌐 Live Demo: https://github.com/yuis-ice/go-chatapp-ai

Screenshot

Chat Application Screenshot

πŸš€ Quick Start

Prerequisites

  • Go 1.21+ - Download Go
  • Modern web browser - Chrome, Firefox, Safari, or Edge

Installation & Setup

  1. Clone the repository

    git clone https://github.com/yuis-ice/go-chatapp-ai.git
    cd go-chatapp-ai
  2. Install dependencies

    go mod download
  3. Run the server

    go run main.go
  4. Open your browser

    http://localhost:8080
    
  5. Start chatting!

    • Enter a username
    • Join the chat room
    • Send messages in real-time

πŸ“ Project Structure

go-chatapp-ai/
β”œβ”€β”€ main.go              # WebSocket server implementation
β”œβ”€β”€ go.mod               # Go module dependencies
β”œβ”€β”€ go.sum               # Dependency checksums
β”œβ”€β”€ static/
β”‚   └── index.html       # Web client interface
β”œβ”€β”€ .github/             # GitHub templates and workflows
β”œβ”€β”€ CONTRIBUTING.md      # Contribution guidelines
β”œβ”€β”€ LICENSE             # MIT license
└── README.md           # This file

πŸ—οΈ Architecture

Backend (Go)

  • WebSocket Server: Built with Gorilla WebSocket
  • Connection Hub: Manages client connections and message broadcasting
  • Static File Server: Serves the web interface
  • Real-time Communication: Handles user connections, disconnections, and message relay

Frontend (HTML/CSS/JavaScript)

  • Responsive Design: Mobile-first, clean interface
  • WebSocket Client: Establishes and maintains server connection
  • Real-time Updates: Instant message display and user notifications
  • Input Validation: Client-side message validation and sanitization

Communication Flow

Client A ←→ WebSocket ←→ Go Server ←→ WebSocket ←→ Client B
                            ↓
                      Message Broadcast Hub
                            ↓
                    All Connected Clients

βš™οΈ Configuration

Server Configuration

  • Port: 8080 (default)
  • Static Files: Served from ./static/
  • WebSocket Endpoint: /ws
  • CORS: Allowed for all origins (development mode)

Customization Options

// In main.go - modify these constants
const (
    ServerPort = ":8080"
    StaticDir  = "./static/"
    WSEndpoint = "/ws"
)

πŸ”§ Development

Running in Development Mode

# Run with live reload (if using air)
go install github.com/cosmtrek/air@latest
air

# Or run normally
go run main.go

Building for Production

# Build binary
go build -o chat-server main.go

# Run binary
./chat-server

Testing

# Run tests
go test ./...

# Run with coverage
go test -cover ./...

πŸš€ Deployment

Docker (Coming Soon)

# Dockerfile example
FROM golang:1.21-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o chat-server main.go

FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /app/chat-server .
COPY --from=builder /app/static ./static
EXPOSE 8080
CMD ["./chat-server"]

Cloud Deployment

  • Heroku: Ready for deployment with Procfile
  • DigitalOcean: Works with App Platform
  • AWS: Compatible with EC2, ECS, or Lambda
  • Vercel/Netlify: Static files can be hosted separately

πŸ›‘οΈ Security Considerations

⚠️ Important: This is a demonstration application and should not be used in production without additional security measures.

Current Limitations

  • No Authentication: Anyone can join with any username
  • No HTTPS/WSS: Communication is not encrypted
  • No Rate Limiting: Vulnerable to spam attacks
  • CORS Wide Open: Accepts connections from any origin
  • No Input Sanitization: Basic XSS protection only

For Production Use

  • Implement user authentication
  • Add HTTPS/WSS encryption
  • Implement rate limiting
  • Add proper input validation
  • Configure CORS restrictions
  • Add logging and monitoring
  • Implement message persistence
  • Add moderation features

🀝 Contributing

We welcome contributions from the community! Please read our Contributing Guidelines for details on:

  • πŸ› Reporting bugs
  • πŸš€ Requesting features
  • πŸ”§ Setting up development environment
  • πŸ“ Code style guidelines
  • πŸ”„ Pull request process

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Gorilla WebSocket - Excellent WebSocket library for Go
  • Go Community - For the amazing ecosystem and resources
  • Contributors - Thank you to everyone who contributes to this project

πŸ“ž Support

πŸ”— Related Projects

πŸ“ˆ Roadmap

Version 1.1 (Planned)

  • User authentication system
  • Message history persistence
  • Private messaging
  • Chat rooms/channels
  • File sharing support

Version 1.2 (Future)

  • Mobile app (React Native/Flutter)
  • Voice/video calling
  • Message encryption
  • Bot integration
  • Emoji reactions

⭐ Star this repository if you found it helpful!

Built with ❀️ using Go and WebSockets

About

πŸš€ A simple, real-time chat application built with Go and WebSockets, featuring a clean web interface for instant messaging. Perfect for learning WebSocket implementation and real-time communication patterns.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages