SpringBoot3 REST api for registering synonyms using MySQL db for storage and Keycloak for authentication.
- The register stores words with their synonyms.
- Every word could be a synonym to another word. For example, If "wash" is a synonym to "clean", then the api should return “clean” as result when we ask for the “wash” synonyms and vice versa.
- A word may have multiple synonyms.
- The register should support something we call a transitive rule. It assumes the following implementation, i.e. if "B" is a synonym to "A" and "C" a synonym to "B", then "C" should automatically, by transitive rule, also be the synonym for "A".
- Clone the project and navigate to synonyms-register project folder in terminal
- Make sure you have docker set up on your local machine
- Run
docker-compose up -d
(this will start keycloak container, import realm and start db container) - Run
docker exec -it mysqldb mysql -uroot -proot
to access mysql shell - Run
UPDATE mysql.user SET host='%' WHERE user='root';
andFLUSH PRIVILEGES;
(this is to enable connection to mysql db from any host, obviously it should be used only in local setup) - Create two users,
userreader
anduserwriter
in keycloak admin console. If you call users differently, make sure to update postman collection.
- Open http://localhost:8080/admin in your browser and login with username
admin
and passwordadmin
- Select
ree_dzenan
realm in left upper dropdown - Navigate to
Users
inManage
menu section - Clic on
Add User
button and enteruserreader
asUsername
and clickCreate
- Go to
Credentials
tab andSet Password
topassword
, turn offTemporary
flag (or in case of different password make sure to update postman collection later) - Go to
Role mapping
tab and selectapp_reader
role inAssign Role
modal - Do the same steps for
userwriter
and assignapp_writer
role to it
- Run
mvn clean package
- Run
java -jar target/synonyms-register-1.0.0-SNAPSHOT.jar
- Import
ree_dzenan.postman_collection.json
into postman, generate token for both users and test endpoints