This Spring Boot backend powers the Surword text-based RPG by handling game state, player progression, combat, inventory, and backend API logic. The frontend is implemented in a separate repository:
- user authentication and JWT-based security
- game persistence with MongoDB
- turn-based combat and battle reports
- character creation, mercenary management, and item equipment
- skirmishes, dungeons, and loot handling
- integration with a frontend through REST APIs and Swagger
- Java 17
- Spring Boot 3.2
- Spring Web
- Spring Security
- Spring Data MongoDB
- Morphia for MongoDB mapping
- jjwt for JWT authentication
- springdoc-openapi for Swagger UI
- Gradle
- Email/password registration and JWT login
- Secure API endpoints for authenticated gameplay
- Main character creation, mercenary creation, and character management
- Consumable and wearable item handling with equipment slots
- Skirmishes and dungeon fights with reward processing
- Leaderboards, merchant shop actions, and inventory endpoints
- Centralized error handling and debug endpoints for development
The repository is organized into backend modules such as:
auth- authentication, JWT generation, security configurationusers- user profile, token info, user managementcharacters- character creation, equip/un-equip, consumablesitems- item service, inventory handling, item generationskirmishes- challenge management, dungeon fights, async reward applicationmerchants- buy/sell item flow and merchant inventoriesleaderboards- ranking and refresh schedulingsettings- game configuration, limits, and balance valuesbattle- combat engine, fight reports, attack/defense calculations
Swagger UI is available after startup at:
http://localhost:8080/swagger-ui/index.html
Important endpoint groups:
/auth/login,/auth/register/users,/users/profile,/users/token-info/characters/*for character and equipment actions/skirmishes/*for skirmish and dungeon gameplay/merchants/*for buy/sell actions/leaderboards/*for ranking data
Note: paths under
/admin/**require admin role, and most other routes require an authenticated JWT token.
- Install Java 17.
- Configure environment variables in a
.envfile or your environment. - Run the backend:
./gradlew bootRunor use your Java IDE to run TextBasedGameApplication.
Once running, open Swagger at http://localhost:8080/swagger-ui/index.html.
This application loads runtime settings from .env via java-dotenv.
Required values include:
CORS_ORIGINS- allowed frontend origins for CORSMONGODB_URI- connection URI for MongoDBMONGODB_NAME- target MongoDB database nameJWT_SECRET_KEY- secret key for JWT signingJWT_TOKEN_VALIDITY_MS- JWT token validity in milliseconds
- add full integration tests for API flows
- support additional item types and enemy AI
- implement multiplayer sessions or real-time updates
- improve admin tooling and deployment scripts
Darosss - darosss12@proton.me