This project is a simplified chat platform built using Go. It handles user authentication, message sending, and message retrieval. The backend uses Cassandra for data storage, Redis for caching, Prometheus for metrics, Grafana for visualization, and Loki for log aggregation.
- User Registration and Login
- Send and Retrieve Messages
- Distributed Data Storage with Cassandra
- Caching with Redis
- Monitoring with Prometheus
- Visualization with Grafana
- Log Aggregation with Loki
- Docker
- Docker Compose
Create a .env
file in the root directory with the following command:
cp .env.example .env
Build and start all services using Docker Compose:
docker-compose down --rmi all
docker-compose up --build
- Grafana: http://localhost:3000
- Default credentials: admin / admin
- Prometheus: http://localhost:9090
- Loki: http://localhost:3100
- Nginx (API Gateway): http://localhost:5050
- Access Swagger documentation at http://localhost:5050/swagger
Prometheus is set up to collect metrics from your Go application.
Access it at http://localhost:9090.
Grafana is configured with dashboards to visualize metrics and logs.
Access it at http://localhost:3000.
Default credentials:
admin / admin
Loki is used for log aggregation and can be queried within Grafana.
Ensure Loki data source is configured in Grafana.
The docker-compose.yml
file sets up the entire stack including Cassandra, Redis, Prometheus, Grafana, Loki, and the Go
application. It also includes health checks and volume mounts to ensure data persistence.
Loki's configuration is specified in /docker/loki/local-config.yaml
and mounted in the Docker Compose setup.
Grafana is provisioned with data sources and dashboards via configuration files in grafana/provisioning/
- Microservices Architecture: The chat application is built as a set of microservices to ensure scalability and maintainability.
- Cassandra for Data Storage: Cassandra is chosen for its distributed nature, providing high availability and scalability.
- Redis for Caching: Redis is used as an in-memory cache to improve the performance of frequently accessed data.
- Docker and Docker Compose: Docker is used to containerize the application, and Docker Compose is used to manage multi-container deployments.
- Prometheus for Monitoring: Prometheus is used for monitoring system metrics and alerting.
- Grafana for Visualization: Grafana is used for visualizing metrics and logs collected by Prometheus and Loki.
- Loki for Log Aggregation: Loki is used to aggregate logs from the application, making it easier to search and analyze logs.
Reflex is used for watching file changes and triggering rebuilds during development. This helps streamline the development workflow by automatically recompiling the Go application when changes are detected. To learn more about Reflex, refer to the Reflex Documentation.
- Single Node Deployment: The setup assumes a single node deployment for simplicity. In a production environment, Cassandra and other services should be deployed in a distributed manner.
- Basic Authentication: The application uses basic username-password authentication. In a real-world application, OAuth or other advanced authentication mechanisms might be used.
- Default Credentials for Grafana: The default credentials for Grafana are set to admin / admin. It's recommended to change these credentials in a production setup.
- Development Environment: The setup is intended for a development environment. Additional security and performance optimizations would be needed for production.