This project consists of a microservice with basic CRUD operations that demonstrates the hexagonal architecture structure using Domain Driven Design software design patterns.
- Language: Java 17
- Framework: Spring Boot 3+
- Persistence: JPA/Hibernate with MySQL
- Architecture: Hexagonal (Ports & Adapters)
- Service Exposure: RESTFUL APIs
- Documentation: Swagger (OpenAPI)
- Testing: JUnit5 & Mockito
- Password Encryption: Using BCryptPasswordEncoder for Secure Storage.
The system is designed following the principles of hexagonal architecture to decouple business logic from frameworks and infrastructure.
- Domain: Contains pure business logic (domain entities, rules, and services).
- Application: Defines use cases and exposes ports for interacting with the infrastructure layer.
- Infrastructure: Implements adapters for the database and APIs.
This project uses Swagger for API documentation and testing. Once you run the application, you can access the Swagger UI using the following URL:
http://localhost:8080/swagger-ui/index.html
Swagger automatically generates and displays the available endpoints along with request/response models, improving the developer experience and enhancing the API usability.
POST /users- Create a user.GET /users/{userId}- Get user by ID.GET /users/email/{email}- Get user by email.GET /users- Get all users.PUT /users/{userId}- Update user.PUT /users/{userId}/password- Update user password.DELETE /users/{userId}- Delete a user.
You can run this application of 2 ways:
- JDK 17
- Maven
- MySQL Workbench installed on your system (for MySQL)
-
https://github.com/john-almaraz/arquitectura-hexagonal -
url: jdbc:mysql://
localhost:3306/user_db?createDatabaseIfNotExist=true -
You can import the collection of methods
docs/postman_collection.jsoninto your Postman and start testing the methods.
- Docker installed on your system (for MySQL and user-service)
- Docker Compose installed (often included with Docker Desktop)
-
https://github.com/john-almaraz/arquitectura-hexagonal -
To setup app and MySQL with Docker services using the provided file:
docker-compose.ymldocker-compose up -d -
- Ensure the App and MySQL is running by checking the Docker containers:
docker ps- You should see containers named user-service and mysql-user.
-
You can import the collection of methods
docs/postman_collection.jsoninto your Postman and start testing the endpoints.With the updated Swagger documentation, you now have a friendly interface at
http://localhost:8080/swagger-ui/index.htmlto explore and test the API endpoints.You can import the collection of methods
docs/postman_collection.jsoninto your Postman and start testing the methods.