https://github.com/harshshah6/go-websocket
A simple websocket server written in go for blazing fast communication in the connected channels.
https://github.com/harshshah6/go-websocket
chat-application docker docker-compose dockerfile go go-websocket go-websocket-client go-websocket-server golang websocket websocket-client websocket-server
Last synced: about 2 months ago
JSON representation
A simple websocket server written in go for blazing fast communication in the connected channels.
- Host: GitHub
- URL: https://github.com/harshshah6/go-websocket
- Owner: Harshshah6
- Created: 2025-10-02T12:49:07.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-10-02T13:43:51.000Z (9 months ago)
- Last Synced: 2025-10-02T15:27:17.194Z (9 months ago)
- Topics: chat-application, docker, docker-compose, dockerfile, go, go-websocket, go-websocket-client, go-websocket-server, golang, websocket, websocket-client, websocket-server
- Language: HTML
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Chat (Structured Go Project)
A real-time **chat application** built with **Go** and [Gorilla WebSocket](https://github.com/gorilla/websocket).
This version is structured for **scalability** and **maintainability** using a layered architecture.
---
## Features
* 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
---
## Project Structure
```
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
```
---
## Requirements
* Go 1.18+
* Gorilla WebSocket package
Install dependencies:
```bash
go mod tidy
```
---
## Running Locally
Start the app:
```bash
go run ./cmd/server
```
Visit in your browser:
```
http://localhost:8080
```
---
## Running with Docker
1. Build the image:
```bash
docker build -t go-chat .
```
2. Run the container:
```bash
docker run -p 8080:8080 go-chat
```
Open in browser:
```
http://localhost:8080
```
---
## Running with Docker Compose
```bash
docker compose up --build
```
To scale:
```bash
docker compose up --scale go-chat=3
```
*(requires sticky sessions for WebSockets when load balancing)*
---
## License
MIT License.
Free to use, modify, and distribute.