Introduction • Installation Guide • API Reference • Database ER • License • Contributors
- This is a CRUD API project in microservice architecture, using Spring Boot, Hibernate and PostgreSQL.
- Project started with spring initializr.
- The project:
- uses Maven as a build tool.
- uses PostgreSQL as a database.
- uses Hibernate as an ORM tool.
- uses Spring Security, Keycloak and JWT Bearer for authentication.
Tip
For client side, please refer to following project: Spring Boot Microservice React
-
To clone and run this application, you'll need Git, Java, Docker and PostgreSQL (optional) installed on your computer. From your command line:
# Clone this repository $ git clone https://github.com/Ctere1/spring-boot-microservice # Go into the repository $ cd spring-boot-microservice # Install the dependencies $ bash service_install.bash # Run the app with docker $ docker-compose up
Tip
If you want to make changes for each service-server, you need to run mvn clean install
for each one. You can use the bash script instead. (bash service_install.bash
)
Important
Before starting, make sure that the ports do not conflict in your local machine. For detailed information, see the docker_compose.yaml
file.
Note
You can add 127.0.0.1 keycloak
to the host file in your local machine for debugging "http://keycloak:8080" endpoint. (C:\Windows\System32\drivers\etc)
Note that it is not mandatory to add. If you do not the server will work without errors, there is no need to be afraid.
- After these steps, you can use the API with Postman or any other API testing tool:
- Signup and create user,
- Login and get access,
- Test the server.
-
You can check the swagger documentation after running the server. The swagger documentations are available at:
- Product:
http://localhost:5861/swagger-ui/index.html#/
- Cart:
http://localhost:5863/swagger-ui/index.html#/
- User:
http://localhost:5865/swagger-ui/index.html#/
- Product:
-
You can perform CRUD operations with authentication in the swagger ui.
- You need to get access before testing the API, first step do post request to
signup
enpoint. Below is a sample response of the user endpoint.
HTTP Verb | Endpoint | Description | Parameters | Body (JSON) |
---|---|---|---|---|
POST |
/api/user/signup |
Creates new user for login | - | username , email , password |
POST |
/api/user/signin |
Returns the user and accessToken | - | username , password |
http://localhost:5860/api/user/signin | JSON Body: {"username": "cemil","password": "123456"}
{
"id": 2,
"username": "cemil",
"email": "test@email.com",
"tokenType": "Bearer",
"accessToken": "*********************"
}
Tip
See postman collection for details
Product Table | Cart Table | User Table |
---|---|---|