A RESTful API etude, using Spring 6.* , Spring Boot 3.* to find solutions and build tests as example code and to store contacts of your superheroes.
π Start with bin/start.sh (see below)
You could get data calling e.g. /api/v1/superheroes and other endpoints. Prior get a JWT token.
You can run unit, functional and integrative tests using oci container solution ("Testcontainers"
feature of spring boot).
- JWT auth, user roles
- Refresh token
- Tests (using testcontainers, liquibase)
- Database postgres + docker
- Pagination on listing
- Soft delete for superhero and user, cleaning database scheduler (to be discussed)
- Deployment for static websites inside Springs Webserver, SPA
- Optimized method security and project structure
- AI search for similar skills and team recommendations
π You will need π docker/ docker compose V2 installed on your OS.
Start with bin/start.sh
This will generate keys, make an image of Java project, start it in a docker container, initialize a postgres database as container, start a ollama container for semantic search and provide localhost, TLS at port 8443.
(Java will be installed inside the container, you do not need it in your OS).
-
Use some rest client:
GET https://localhost:8443/api/v1/superheroes/ HTTP/1.1(Please use JWT). -
See OpenAPI definition at https://localhost:8443/swagger-ui/index.html. (Please write
index.html, there is no redirect) -
See a chart of superhero skills (id: 1 - 16) https://localhost:8443/chart.html?id=1
-
Use AI semantic search
GET /api/v1/superheroes/team?task=hack an AI overlord steering evil robots&teamSize=5 -
Use AI similarity search
GET /api/v1/superheroes/search?query=wise peaceful hero who resolves conflicts calmly&quantity=5 -
Use AI contextual explained research
GET /api/v1/superheroes/team/contextual?task=clean up city from bad police officers&teamSize=5
-
Get a token by authentication
GET https://localhost:8443/api/v1/login HTTP/1.1 Authorization: Basic admin@example.com foobar -
You will receive an authorization as JWT in payload of response body.
-
Use JWT
GET https://localhost:8443/api/v1/superheroes HTTP/1.1 Authorization: Bearer {{your-jwt-token}}
- Administrator role:
- user: admin@example.com
- password: foobar
- User role:
- user: chris@example.com
- password: foobar
π You will need docker/ docker compose V2 installed on your OS and Java 17
-
Start application:
./bin/dev/start.sh- Postgres database will be started and fully initialized in a docker container.
- Spring-boot will be started.
-
Run test by
bin/test.sh. -
Open database client on
psql postgresql://db:db@localhost:25432/db.
- GET /api/v1/auth/login
- GET /api/v1/auth/refresh-token
- GET /api/v1/superheroes
- GET /api/v1/superheroes/{id}
- POST /api/v1/superheroes
- PATCH /api/v1/superheroes/{id}
- DELETE /api/v1/superheroes/{id}
- GET /api/v1/skills
- GET /api/v1/skills/{id}
- GET /api/v1/superheroes/{superheroId}/skill-profiles
- GET /api/v1/superheroes/{superheroId}/skill-profiles/{skillId}
- POST /api/v1/superheroes/{superheroId}/skill-profiles
- PATCH /api/v1/superheroes/{superheroId}/skill-profiles/{skillId}
- DELETE /api/v1/superheroes/{superheroId}/skill-profiles/{skillId}
- GET /api/v1/superheroes/team
- GET /api/v1/superheroes/search
- GET /api/v1/superheroes/team/contextual
