CLI chat. [Go, GRPC, Cobra, Bubbletea, Mongo, Postgres]. 2 microservices and 1 tui-client in monorepo
Welcome to the GRPC CLI Chat Backend! This monorepo houses a powerful chat application comprised of three main services: auth
, chat
, and a cli
client. With a robust authentication system using access and refresh tokens, and independent databases for each service, this project is built to scale and impress. Let's dive into the details! 🌟
auth
: Handles user authentication and authorization.chat
: Manages chat messages and chat rooms.cli
: Command-line interface for interacting with the chat service.Ensure you have the following installed on your system:
git clone https://github.com/javascriptizer1/grpc-cli-chat.mono.git
cd grpc-cli-chat.mono
cp .env.example .env
docker-compose up -d
make vendor-proto
make install-deps
Our CLI client now supports various commands to interact with the backend services seamlessly using Cobra and Bubbletea. Here are a few:
gchat register
: Register a new user.gchat login
: Login with existing credentials.gchat list-user
: List all users.gchat create-chat
: Create a chat with the specified users.gchat list-chat
: List all user chats.gchat connect-chat
: Connect to a specific chat by chat ID.Example commands:
go run main.go register --name "John Doe" --email "[email protected]" --password "password" --password-confirm "password"
go run main.go login --login "[email protected]" --password "password"
go run main.go list-user
go run main.go create-chat --user-ids="<uuid>"
go run main.go list-chat
go run main.go connect-chat --chat-id "chat123"
The interaction with our application is now fully integrated with Bubbletea, providing a rich, interactive terminal user interface (TUI). This change enhances user experience and allows for more dynamic and responsive interactions.
Login
The login allows users to enter their credentials and access the chat service.
Registration
The registration enables users to create a new account by providing their name, email, and password.
Create Chat
The create chat allows users to initiate a new chat room by selecting participants and starting conversations.
Chat List Screen
The chat list shows a list of chat rooms the user is part of and allows seamless navigation between them.
Chat Interaction
The chat interaction provides a real-time chat interface where users can send and receive messages.
Our project is organized as a monorepository containing three main applications:
Access and Refresh Tokens: Secure authentication with token-based access control.
PostgreSQL and MongoDB: Two separate databases for different services to ensure scalability and maintainability.
Service Provider Pattern: A clean and modular approach to managing dependencies and service interactions.
Interceptors: Automatically handle token refresh to ensure seamless user experience.
make generate-api
make migrations-up
name=migration_name make migrations-generate
make lint
make build
The application is deployed in a Kubernetes cluster, ensuring high availability, scalability, and efficient resource management. The deployment process is automated using GitHub Actions.
In addition to Kubernetes, the application can also be deployed on a Virtual Private Server (VPS). This flexibility allows you to choose the deployment target that best fits your infrastructure and scaling needs. The deployment process, whether to Kubernetes or a VPS, is managed through GitHub Actions workflows.
I use GitHub Actions for continuous integration and deployment. The workflow includes:
golangci-lint
.Deployment setup exemplifies modern DevOps practices by:
Ensure that the following environment variables are set in your GitHub repository secrets:
DOCKER_HUB_USERNAME
: Your Docker Hub username.DOCKER_HUB_PASSWORD
: Your Docker Hub password.KUBE_CONFIG
: Your Kubernetes configuration file content.NAMESPACE
: Your Kubernetes namespace.VPS_SSH_KEY
: Your VPS SSH private key.VPS_USER
: Your VPS user.VPS_HOST
: Your VPS host address.I hope you enjoy using the CLI Chat as much as we enjoyed building it. If you find it useful, give us a ⭐ on GitHub!
Happy chatting! 🎉🚀