A real-time chat application with Go WebSocket server and React frontend.
- Real-time messaging
- Multiple channels
- Voice memos
- File attachments
- Typing indicators
- User list
- Copy message functionality
- Dark theme UI
- WebSocket server using Gorilla WebSocket
- Channel-based messaging
- User management
- CORS support
- Native WebSocket client (no Socket.IO)
- Modular architecture with services and hooks
- Vite for development and building
- Modern React with hooks
- Go 1.21+
- Node.js 18+
- npm or yarn
- Docker & Docker Compose (optional)
- Build and run everything:
make quick
# or
./docker-scripts.sh build && ./docker-scripts.sh http- Access the application:
- HTTP: http://localhost:8090
- HTTPS: http://localhost:8443 (with
./docker-scripts.sh https)
- Install Go dependencies:
go mod tidy- Run the server:
# HTTP mode
go run server.go
# HTTPS mode with auto-generated certificates
go run server.go -secure
# Custom port
go run server.go -port 3000
# HTTPS on custom port
go run server.go -port 8443 -secureThe server will start on the specified port (default: 8090).
- Install dependencies:
cd frontend
npm install- Start development server:
npm run devThe frontend will be available at http://localhost:5173
| Command | Description |
|---|---|
make build |
Build frontend and Docker image |
make run-http |
Run HTTP server (port 8090) |
make run-https |
Run HTTPS server (port 8443) |
make run-dev |
Run development server |
make stop |
Stop all services |
make logs |
Show logs |
make clean |
Remove all containers and images |
For more Docker options, see DOCKER.md.
Login:
{
"type": "login",
"nick": "username",
"channel": "channelname"
}Send Message:
{
"type": "message",
"data": "Hello world"
}Typing Indicator:
{
"type": "typing",
"typing": true
}New Message:
{
"type": "new-msg",
"message": {
"id": "msg_1",
"f": "username",
"t": 1640995200000,
"m": "Hello world"
}
}User List:
{
"type": "userlist",
"users": ["user1", "user2"]
}Typing:
{
"type": "typing",
"user": "username",
"typing": true
}chat/
├── server.go # Go WebSocket server
├── go.mod # Go dependencies
├── html/ # Static files
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom hooks
│ │ ├── services/ # Business logic
│ │ ├── utils/ # Utilities
│ │ └── types/ # TypeScript types
│ └── package.json
└── README.md
The application follows KISS (Keep It Simple, Stupid) principles:
- Simple WebSocket protocol
- Modular frontend architecture
- Minimal dependencies
- Clear separation of concerns
- Easy to understand and maintain