A full-stack real-time chat application featuring a Go backend with WebSockets, MongoDB for persistent storage, Redis for pub/sub functionality, and a React/Next.js frontend.
- Real-time messaging using WebSocket
- Room-based chat functionality
- User authentication and authorization
- Message persistence with MongoDB
- Session management with Redis
- UI with React/Next.js with Shadcn
- API documentation with Swagger
- Go
- Node.js
- MongoDB
- Redis
- pnpm (preferred)
git clone https://github.com/vit0rr/chat.git
cd chat
- Install dependencies:
go mod tidy
- Set up environment variables:
cp .env.example .env
- Run the server:
go run cmd/api/main.go
- Navigate to the frontend directory:
cd front
- Install dependencies:
pnpm install
- Run the development server:
pnpm run dev
This project uses Swagger to document the API. The code generation was made using Swag. After updating the documentation - by adding/editing comments in the code - you can run the following command to generate the documentation:
swag init -d ./cmd/api/,./
It will update the docs
folder with the new documentation. You can access the documentation by running the project and accessing the /swagger/index.html
endpoint at http://localhost:8080/swagger/index.html.
You can check the environment variables needed to run this project in the .env.example
file. Run the following command to create a .env
file:
cp .env.example .env
The project includes Docker support for easy deployment. To run the entire stack:
docker-compose up
This will start:
- MongoDB on port 27017
- Redis on port 6379
- Backend API on port 8080
- Frontend on port 3000
The backend is configured for deployment on Fly.io. Configuration can be found in fly.toml
.
The frontend can be deployed to Vercel or any other Next.js-compatible hosting platform.
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request