This project is a simple example of a CRUD-based microservices application. It demonstrates how to handle basic operations in a distributed architecture using various technologies. The application requires user authentication, and access to the API endpoints is secured via JWT tokens.
This application consists of three microservices:
- Authentication - Handles user authentication using JWT and stores user information in a MongoDB database.
- Search - Allows for searching quotes using Elasticsearch.
- Quotes - Manages CRUD operations for quotes, storing them in MongoDB.
- Elasticsearch: For advanced search capabilities
- MongoDB: As the primary database for storing user and other application data
- RabbitMQ: For message brokering and asynchronous communication between microservices
-
Authentication Flow:
To access theSearch
andQuotes
services, users must authenticate via theAuthentication
service to receive a JWT. This JWT is included in the headers of each request to access these services. When a request reaches theSearch
orQuotes
services, they first validate the JWT by sending it to theAuthentication
service via anauth
queue in RabbitMQ. Only if authentication is successful will the request proceed; otherwise, access is denied. -
Data Synchronization:
When theQuotes
service stores a quote in the database, it also sends the quote to theSearch
service through asearch
queue in RabbitMQ, allowing it to be indexed in Elasticsearch for efficient searching.
You can run this application using either Docker or Kubernetes:
- Docker: A
docker-compose.yml
file is provided in the repository, an NGINX service will function as the API gateway for the application. Please adjust the values in the file to match your requirements before running the application. - Kubernetes (K8s): For guidance on running the application in a Kubernetes cluster, refer to the following link, all services will be placed behind an Ingress controller, acting as an API gateway.
Additionally, the process of building Docker images and pushing them to Docker Hub is automated using GitHub Actions. This ensures that a Docker image in sync with the current source code is always available. You can easily pull the latest version of the Docker image from Docker Hub and deploy it in your environment.