Skip to content

vit0rr/chat

Repository files navigation

Chat Service

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.

print showing the chat landing page

🌟 Features

  • 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

πŸ› οΈ Tech Stack

Backend

Frontend

Prerequisites

  • Go
  • Node.js
  • MongoDB
  • Redis
  • pnpm (preferred)

πŸš€ Getting Started

Clone the Repository

git clone https://github.com/vit0rr/chat.git
cd chat

Backend Setup

  1. Install dependencies:
go mod tidy
  1. Set up environment variables:
cp .env.example .env
  1. Run the server:
go run cmd/api/main.go

Frontend Setup

  1. Navigate to the frontend directory:
cd front
  1. Install dependencies:
pnpm install
  1. Run the development server:
pnpm run dev

πŸ“š API Documentation

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.

Environment Variables

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

🐳 Docker Support

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

🚒 Deployment

Backend

The backend is configured for deployment on Fly.io. Configuration can be found in fly.toml.

Frontend

The frontend can be deployed to Vercel or any other Next.js-compatible hosting platform.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request