This project consists of two microservices, "users" and "notifications", communicating via a message bus. The services are orchestrated using Docker Compose.
The microservices architecture allows for scalable, decoupled, and independently deployable components, enabling efficient development and maintenance of complex systems. In this setup, the "users" service handles user data submission, while the "notifications" service processes and logs the received data.
Symfony is a PHP web application framework used for building the microservices in this project. It provides a robust set of tools and features for developing scalable and maintainable applications.
The docker-compose.yml
file defines the services and their configurations:
- Redis: Acts as the message broker for communication between microservices.
- Users Service: Handles user data submission via POST requests and dispatches events to the message broker.
- Notifications Service: Consumes events from the message broker and logs the received data.
- Users Service: Exposed on port 8000.
- Notifications Service: Exposed on port 8001.
- Both services mount volumes for log storage to persist logs outside the containers.
The microservices application follows these requirements:
-
User Service:
- Exposes an endpoint
POST /users
to receive user data ({"email","firstName","lastName"}
) and stores it in the database. - Upon data submission, generates an event and sends it through the message broker to the "notifications" service.
- Exposes an endpoint
-
Notifications Service:
- Consumes events from the message broker.
- Logs the received data in a log file.
-
Test Coverage:
- The codebase is covered with unit, integration, and functional tests to ensure reliability and correctness.
- Clone the Repository:
git clone https://github.com/Tope19/microservices-with-symfony
- Navigate to the Project Directory:
cd microservices
docker-compose build docker-compose up -d
docker-compose exec users php bin/phpunit test
docker-compose down