https://github.com/qwidex/go-chat
https://github.com/qwidex/go-chat
chat-application gin go jwt mongodb websockets
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/qwidex/go-chat
- Owner: QWIDEX
- Created: 2024-08-11T20:16:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-26T15:36:17.000Z (over 1 year ago)
- Last Synced: 2025-03-26T16:37:03.745Z (over 1 year ago)
- Topics: chat-application, gin, go, jwt, mongodb, websockets
- Language: Go
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-chat
A simple chat application built with Go, Gin, and MongoDB.
## Features
- User registration and authentication
- Create and join chat rooms
- Send and receive messages in real-time using WebSockets
- MongoDB integration for storing user and chat data
## Prerequisites
- Go 1.23 or later
- Docker (for running MongoDB)
- Make
## Setup
1. Clone the repository:
```bash
git clone https://github.com/yourusername/go-chat.git
cd go-chat
```
2. Copy the .env.default file to .env and update the environment variables as needed:
```bash
cp .env.default .env
```
3. Install dependencies:
```bash
go mod download
```
## Running the Application
### Using Docker
1. Build and run the Docker containers:
```bash
make docker-run
```
2. Build and run the application:
```bash
make build
make run
```
## Makefile Commands
- Build the application:
```bash
make build
```
- Run the application:
```bash
make run
```
- Live reload the application:
```bash
make watch
```
- Clean up binary from the last build:
```bash
make clean
```
## API Endpoints
### Authentication
- `POST /auth/register` - Register a new user
- `POST /auth/login` - Login a user
- `GET /auth/refresh-token` - Refresh access token
### Users
- `GET /users` - Get all users
- `GET /users/:uid` - Get user data by UID
### Chats
- `GET /chats` - Get all chat rooms for the authenticated user
- `POST /chats` - Create a new chat room
- `PATCH /chats` - Add a member to a chat room
- `GET /chats/:chatId` - Get chat history by chat ID
### WebSocket
- `GET /ws` - Connect to WebSocket for real-time messaging