This is a simple Spring Boot app that shows how a modern Java web app works. It handles user data, caching, file uploads, and runs inside Docker containers.
- Lets you create and list users
- Handles avatar image uploads
- Stores data in PostgreSQL
- Caches user info using Redis
- Runs everything in Docker
- Java + Spring Boot 3.x
- JPA/Hibernate for database mapping
- PostgreSQL 14
- Redis 7
- Docker + Docker Compose
- Thymeleaf for HTML templates
- Maven for managing dependencies
model/User.java
: defines the user structureservice/UserService.java
: contains business logic and cachingcontroller/UserController.java
: handles HTTP routesservice/FileStorageService.java
: deals with file uploadsconfig/RedisCacheConfig.java
: sets up RedisDockerfile
: builds the Java app imagedocker-compose.yml
: runs everything together
- Uses AOP (Aspect-Oriented Programming) to track caching
- Generates unique filenames using UUIDs
- Stores all data in volumes so nothing gets lost
To start everything locally:
docker-compose up --build
This spins up:
- The Spring Boot web app
- A PostgreSQL database
- A Redis cache
It uses volumes to keep the data:
postgres-data
: for databaseredis-data
: for Redis cacheupload-data
: for uploaded avatars
Once it's running, open http://localhost:8080 in your browser.
This app is also set up for easy deployment on Hostim.dev. It shows how to spin up a full stack app with a database and cache inside containers. For detailed steps on hosting this on Hostim.dev, check out the Hostim.dev deployment guide.