- Register: Users can create an account with a unique
usernameandpassword. - Login: Users can authenticate with
usernameandpasswordand receive a JWT authentication token. - Send message: Authenticated users can send a single message to another user.
- Retrieve recent messages: Get recent messages from a specific sender, with pagination:
- Limit the number of returned messages
- Fetch messages before a specified message
- Tested on: Ubuntu 24.04
- Required
- Java 25 (JDK). Verify:
java -version - Docker and docker-compose
- Java 25 (JDK). Verify:
- Optional
- Makefile
- Start the PostgresSQL database: Verify:
docker compose up -d
docker compose ps - Build and run with the Maven Wrapper: Or build a runnable jar:
./mvnw spring-boot:run
To build the package from scratch:./mvnw package java -jar target/smessenger.jar
./mvnw clean install - Stop the database:
docker compose down
Convenience: all of the above commands are also available via make (see Makefile). Common targets:
make pg_up: start PostgreSQL containermake pg_down: stop PostgreSQL containermake run: run app inprodprofilemake dev: run app indevprofilemake packageandmake run_jar: produce and runsmessenger.jar
If you want to run the application using an in-memory H2 database for local development, start the app with the dev Spring profile. This will load application-dev.properties which configures H2.
./mvnw spring-boot:run -Dspring-boot.run.profiles=devThe H2 web console is enabled in the dev profile at:
http://localhost:8080/h2-console
-
JDBC URL:
jdbc:h2:mem:testdb -
Username:
sa -
Password: (leave blank)
-
Notes
- If you prefer system Maven, replace
./mvnwwithmvn. - Application listens on localhost port 8080 by default
- Ensure the database container is healthy before starting the app (check
docker logsordocker compose ps).
- If you prefer system Maven, replace
- http://localhost:8080/swagger-ui/index.html
- Login, retrieve
jwttoken and enter it in the global "Authorize" field (top-right)
- Login, retrieve
- Postman collection
- Two test users are preloaded in the database:
user1anduser2(password:pass). Sample messages fromuser2touser1are included. Use these accounts to start testing.
flowchart TD A["Client"] <--> F["DTO (Data transfer objects)"] F <--> B["Controller (HTTP req/resp)"] B --> C["Service (Business logic)"] C --> D["Repository (Data access)"] D --> E["Model (Core business objects)"] D --> DB["Database server"]