hermes

โญ 0 Stars
๐Ÿด 0 Forks
๐Ÿ›  Java
๐Ÿ•’ 1/3/2026

Hermes is a backend that manages a Minecraft player system, tracking their statistics and data in real time with Redis caching.

javamysqlredisspring

๐Ÿ›ก๏ธ Hermes โ€” Minecraft Backend with Spring Boot

Hermes is a RESTful backend developed in Java with Spring Boot for managing Minecraft player data (users, economy, statistics) and authenticating multiple Minecraft servers using JWT. It includes Redis caching, persistence with MySQL, and is fully dockerized for development and production.

๐Ÿง  What is Hermes?

Hermes is a backend system that:

  • Manages Minecraft player data.
  • Authenticates Minecraft servers with credentials and JWT.
  • Supports multiple server instances with synchronized data via Redis.
  • Provides secure token handling (access and refresh tokens).
  • Ready to run with Docker + Docker Compose.

This project is designed as a robust Minecraft backend foundation (economy, achievements, statistics, etc.).

๐Ÿš€ Technologies

| Component | Technology | | -------------- | ---------------------------- | | Backend | Java 17 + Spring Boot | | Persistence | MySQL | | Cache | Redis | | Authentication | JWT | | Build | Gradle (with Gradle Wrapper) | | Containers | Docker + Docker Compose |

๐Ÿงฑ Project Structure

hermes/
โ”œโ”€ src/
โ”‚  โ”œโ”€ main/java/...       # Main code
โ”‚  โ”œโ”€ main/resources      # Configs and startup SQL
โ”‚  โ””โ”€ test/               # Tests (if any)
โ”œโ”€ gradlew
โ”œโ”€ build.gradle.kts       # Gradle build
โ”œโ”€ settings.gradle.kts
โ”œโ”€ Dockerfile
โ”œโ”€ docker-compose.yml
โ”œโ”€ .env-template          # Example environment variables
โ””โ”€ README.md              # โ† This file

๐Ÿ› ๏ธ Requirements

  • Docker & Docker Compose (V2 integrated)
  • (Optional local) Java 17 + Gradle

๐Ÿš€ How to run Hermes with Docker

  1. Copy the environment template:
cp .env-template .env
  1. Edit .env with your secrets (JWT, MySQL, Redis, etc.)

  2. Start all services:

docker compose --env-file .env up --build

This will launch:

โœ”๏ธ MySQL โœ”๏ธ Redis โœ”๏ธ Hermes backend

  1. To run in detached mode:
docker compose --env-file .env up -d --build
  1. Check running containers:
docker compose ps
  1. View logs in real-time:
docker compose logs -f hermes
  1. Stop all containers:
docker compose down

โœจ Main Endpoints

๐Ÿ” Server Authentication

| Method | Endpoint | Description | | ------ | ---------------------- | ----------------------------------- | | POST | /api/v1/auth/login | Server login with credentials | | POST | /api/v1/auth/refresh | Refresh token to renew access token |

Returns accessToken and refreshToken.

๐Ÿ‘ค Users

| Method | Endpoint | Description | | ------ | -------------------- | ---------------------- | | GET | /api/v1/users | List users (paginated) | | GET | /api/v1/users/{id} | Get user by ID | | POST | /api/v1/users | Create a new user | | DELETE | /api/v1/users/{id} | Delete user |

๐Ÿ”’ JWT and Tokens

  • Access Token: expires in 1 day
  • Refresh Token: expires in 7 days
  • The client must handle automatic refresh if the access token expires.

This allows Minecraft servers to maintain sessions without resending sensitive credentials continuously.

๐Ÿ“ฆ Main Entities

| Entity | Key Fields | | --------------- | ----------------------------------- | | Server | id, password | | User | id, name | | UserEconomy | coins, gems | | UserStatistic | kills, deaths, wins, losses |

๐Ÿงช Data Initialization

Place a data.sql file in src/main/resources with initial inserts for:

  • Initial servers
  • Test users
  • Economy and statistics

Spring Boot will execute it automatically on startup (configurable with spring.jpa.hibernate.ddl-auto).

๐Ÿ“Œ Environment Variables Example

# MySQL
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=hermes
MYSQL_USER=hermesuser
MYSQL_PASSWORD=hermespass

# Redis
REDIS_PASSWORD=redispass

# Application
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/hermes
SPRING_DATASOURCE_USERNAME=hermesuser
SPRING_DATASOURCE_PASSWORD=hermespass

SPRING_REDIS_HOST=redis
SPRING_REDIS_PASSWORD=redispass

JWT_SECRET=yourSuperSecretJWT

๐Ÿงญ Tips

  • Use environment variables for secrets; do not hardcode sensitive values.
  • Set spring.jpa.hibernate.ddl-auto=update to let Spring create tables automatically.
  • Docker Compose volumes ensure MySQL data persists across container restarts.

๐Ÿ“š Documentation & References

For guidance on README structure and best practices: GitHub Docs

๐Ÿ“ License

This project is licensed under the MIT License. See the LICENSE file for details.

๐Ÿ‘ Contributions

  1. Fork the repo
  2. Create a new feature branch
  3. Submit a pull request with clear description