This workspace runs two Spring Boot services (ProjectA and ProjectB) plus a Postgres database. ProjectA exposes the public API for registering/logging-in users and processing text; ProjectB performs the text transformation and is protected by an internal token.
- Docker Desktop (or Docker Engine + Docker Compose plugin)
- Java 21 and Maven if you want to build locally outside of Docker
- macOS only: make sure Docker Desktop can access init.sql file. Run:
This adds path to init.sql to Docker Desktop’s file-sharing list so Postgres can mount the init script. (Reopen Docker Desktop if it restarts.)
defaults write com.docker.docker FilesharingDirectories -array-add "path/to/init.sql" \ && killall Docker || true \ && open -a Docker
docker compose up -d --build
The Maven steps compile each service so the Docker builds can reuse the pre-built JARs from target/
. The compose command starts ProjectA on http://localhost:8080
, ProjectB on http://localhost:8081
, and Postgres on localhost:5432
.
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"a@a.com","password":"longpassword1234"}'
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"a@a.com","password":"longpassword1234"}'
The login response returns { "token": "<jwt>" }
. Save that JWT for the next step.
TOKEN=<paste-jwt-here>
curl -X POST http://localhost:8080/api/process \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{"text":"hello"}'
Expected response:
{"processedText":"OLLEH"}
You should also see a new row in the tb_process_logs
table:
docker exec -it postgres psql -U projecta -d projecta \
-c "SELECT id, input_text, output_text, result_code FROM tb_process_logs ORDER BY created_at DESC LIMIT 1;"
docker compose down
Add -v
if you want to remove the Postgres volume.