A real-time chat application built with Go and Gorilla WebSocket. This version is structured for scalability and maintainability using a layered architecture.
- Real-time chat with WebSockets
- User join/leave notifications
- Markdown support (
**bold**,*italic*,`code`) - Multiline messages (Shift+Enter for new line)
- Clean project structure (
internal/,pkg/,cmd/) - Custom logger
go-chat/
├── cmd/
│ └── server/
│ └── main.go # Entry point
│
├── internal/
│ ├── app/
│ │ └── app.go # Wire dependencies + run server
│ ├── config/ # (future) env/config loader
│ ├── handlers/
│ │ └── chat.go # WebSocket handler
│ ├── models/
│ │ └── message.go # Data models
│ ├── services/
│ │ └── chat_service.go
│ └── store/
│ └── memory_store.go
│
├── pkg/
│ └── logger/
│ └── logger.go # Custom logger wrapper
│
├── static/
│ └── index.html # Frontend chat UI
│
├── Dockerfile
├── docker-compose.yml
├── go.mod
└── README.md
- Go 1.18+
- Gorilla WebSocket package
Install dependencies:
go mod tidyStart the app:
go run ./cmd/serverVisit in your browser:
http://localhost:8080
- Build the image:
docker build -t go-chat .- Run the container:
docker run -p 8080:8080 go-chatOpen in browser:
http://localhost:8080
docker compose up --buildTo scale:
docker compose up --scale go-chat=3(requires sticky sessions for WebSockets when load balancing)
MIT License. Free to use, modify, and distribute.