This project was built to facilitate the management of market products and users. It provides functionalities for querying market products, managing users, and monitoring system health and metrics.
- User registration and login with Spring Security
- Password encryption using BCrypt
- Role-based authorization with Spring Security
- Exception handling for cleaner error responses
- API documentation with Swagger
- Dashboards with Grafana and Prometheus for monitoring
- Actuator endpoints for info, metrics, health, and Prometheus integration
- Spring Boot 3.3
- Spring Security 6.3
- Spring Data
- Maven
- Swagger
- Prometheus
- Grafana
- Java 17
- Docker (recommended) or MySQL
You can run the application in two ways:
- Using Docker Compose: Run
docker-compose upin the terminal. - Manual MySQL Connection: Set up a local MySQL database and configure the connection details.
After running the API, you'll need to add users and roles to the database for the integration tests to work. Below is a suggested setup:
Roles Table:
- ID: 1, name: ROLE_ADMIN
- ID: 2, name: ROLE_USER
Users Table:
- ID: 1, name: Murillo, username: Murillo, password: marques
- ID: 2, name: Fabiano, username: Fabiano, password: Santos
User_Role Table:
- role_id: 1, user_id: 1 (Assigns Murillo the ADMIN role)
- role_id: 2, user_id: 2 (Assigns Fabiano the USER role)
With this configuration, the integration tests should pass successfully.
- To run unit tests:
mvn test - To run integration tests:
mvn test -Pintegration-tests - To run all tests:
mvn test -Pall-tests
To view the API documentation, add a user to database, run the application and navigate to: http://localhost:8080/swagger-ui.html
All endpoints include detailed summaries and descriptions.
Prometheus can be accessed at: http://localhost:9090/
To view metrics in Grafana:
- Run the application.
- Navigate to
http://localhost:3000(default Grafana URL). - Create a new data source using Prometheus with this URL:
http://prometheus:9090. - A recommended dashboard is JVM (Micrometer), which provides detailed JVM and application metrics.
/actuator/info– Basic application information/actuator/metrics– Application metrics/actuator/health– Health status/actuator/prometheus– Prometheus metrics endpoint