โ† Projects
06 / 06 - Java ยท Spring Boot ยท Backend

Java Spring
Messenger

Educational backend project implementing a messaging system with Spring Boot. REST API, user management, message threading and standard Spring layered architecture.

JavaSpring Boot Spring SecuritySpring Data JPA REST APIPostgreSQL

What it does

A backend-only messaging service built to explore Spring Boot architecture. Covers the full request lifecycle from REST controller through service layer to JPA repository, with Spring Security for auth.

Designed as a learning project, the codebase demonstrates idiomatic Spring patterns: dependency injection, transaction management, DTO mapping and integration testing with MockMvc.

Key capabilities

01
User management
Registration, login, profile CRUD. Password hashing with BCrypt. JWT-based stateless authentication.
02
Messaging logic
Send and receive messages. Conversation threading by participants. Paginated message history.
03
REST API
Standard HTTP methods and status codes. JSON request/response. Input validation with Spring Validator.
04
Spring architecture
Clean Controller โ†’ Service โ†’ Repository layering. Spring Data JPA with H2 (dev) and PostgreSQL (prod).

Project structure

tree
src/main/java/
โ””โ”€โ”€ messenger/
    โ”œโ”€โ”€ controller/
    โ”‚   โ”œโ”€โ”€ AuthController.java      # /api/auth/*
    โ”‚   โ”œโ”€โ”€ UserController.java      # /api/users/*
    โ”‚   โ””โ”€โ”€ MessageController.java   # /api/messages/*
    โ”œโ”€โ”€ service/
    โ”‚   โ”œโ”€โ”€ AuthService.java
    โ”‚   โ”œโ”€โ”€ UserService.java
    โ”‚   โ””โ”€โ”€ MessageService.java
    โ”œโ”€โ”€ repository/
    โ”‚   โ”œโ”€โ”€ UserRepository.java
    โ”‚   โ””โ”€โ”€ MessageRepository.java
    โ”œโ”€โ”€ model/
    โ”‚   โ”œโ”€โ”€ User.java
    โ”‚   โ””โ”€โ”€ Message.java
    โ”œโ”€โ”€ dto/                         # Request/response DTOs
    โ”œโ”€โ”€ security/                    # JWT filter, Spring Security config
    โ””โ”€โ”€ config/

REST endpoints

http
# Auth
POST  /api/auth/register   # { username, email, password }
POST  /api/auth/login      # { email, password } โ†’ JWT

# Users
GET   /api/users/me        # current user profile
PUT   /api/users/me        # update profile

# Messages
GET   /api/messages        # ?with=userId&page=0&size=20
POST  /api/messages        # { recipientId, content }
GET   /api/conversations   # list all conversations

Running locally

bash
# Requires Java 17+ and Maven
mvn spring-boot:run

# Runs on http://localhost:8080
# H2 console: http://localhost:8080/h2-console