Skip to content

MurilloMarquesSantos/marketApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Market System API

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.

Features

  • 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

Technologies

  • Spring Boot 3.3
  • Spring Security 6.3
  • Spring Data
  • Maven
  • Swagger
  • Prometheus
  • Grafana

Requirements

  • Java 17
  • Docker (recommended) or MySQL

Getting Started

You can run the application in two ways:

  1. Using Docker Compose: Run docker-compose up in the terminal.
  2. Manual MySQL Connection: Set up a local MySQL database and configure the connection details.

Initial Setup

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.

Running Tests

  • To run unit tests: mvn test
  • To run integration tests: mvn test -Pintegration-tests
  • To run all tests: mvn test -Pall-tests

Usage

Swagger API Documentation

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 Monitoring

Prometheus can be accessed at:
http://localhost:9090/

Grafana Dashboards

To view metrics in Grafana:

  1. Run the application.
  2. Navigate to http://localhost:3000 (default Grafana URL).
  3. Create a new data source using Prometheus with this URL: http://prometheus:9090.
  4. A recommended dashboard is JVM (Micrometer), which provides detailed JVM and application metrics.

Actuator Endpoints

  • /actuator/info – Basic application information
  • /actuator/metrics – Application metrics
  • /actuator/health – Health status
  • /actuator/prometheus – Prometheus metrics endpoint

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages