The final project for Ironhack Web Dev Bootcamp.
This project was created as the final project for the Ironhack Web Dev Bootcamp. It's a web application game based on one of my first java group projects and inspired by games like pokemon and RPG games with some roguelike elements.
The project is divided into multiple microservices and a client application:
- Graveyard-Builder-Game-Client
- Graveyard-Builder-Game-Discovery-Service
- Graveyard-Builder-Game-Gateway-Service
- Graveyard-Builder-Game-User-Model-Service
- Graveyard-Builder-Game-Character-Model-Service
- Graveyard-Builder-Game-Opponent-Selection-Service
- Graveyard-Builder-Game-Battle-Service
- Graveyard-Builder-Game-Party-Manager-Service
- Graveyard-Builder-Game-Profile-Service
- Graveyard-Builder-Game-SignIn-Service
- Graveyard-Builder-Game-Auth-Service
Your project must meet all of the requirements below:
- Include a microservices Java/Spring Boot backend and an Angular frontend.
- Include at least 2 SQL database tables.
- Include at least 4 services plus at least 1 edge service.
- Include at least 1 GET, POST, PUT/PATCH, and DELETE route.
- Include adequate and complete documentation.
Graveyard Builder Game consists of a single-player browser game. The players must build their party of warriors, archers, and mages, defeat other players, gain gold, and level up. Each character type has its unique stats and abilities. When characters die, they will be moved to the graveyard. To add them back to the party, the player must revive them with gold.
The game is temporarily available at http://graveyardbuildergame.site
- 3 classes of characters: Warrior, Archer, Mage
- Automatic opponent generation
- Random option on character creation
- Customizable characters and user pictures
- Battle other players' teams
- Help page
- Mobile-friendly interface
- JWT authentication
Technologies used in this project:
The project contains separate microservices for the backend and a client frontend part. To locally run the web application all parts must be operational.
- Clone the frontend repository: https://github.com/Joaodss/Graveyard-Builder-Game-Client
- Install the dependencies:
npm i
- Run the following command to start the frontend application:
npm start
- The application will be available at http://localhost:4200/
-
Clone the backend repositories:
- https://github.com/Joaodss/Graveyard-Builder-Game-Discovery-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Gateway-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-User-Model-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Character-Model-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Opponent-Selection-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Battle-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Party-Manager-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Profile-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-SignIn-Service
- https://github.com/Joaodss/Graveyard-Builder-Game-Auth-Service
- https://github.com/EN-IH-WDPT-JUN21/CSharks-BackEndHomework
-
Setup the following database name and user, or set up your database by changing the values in the
application.properties
file
CREATE DATABASE GraveyardBuilder;
CREATE USER 'ironhacker'@'localhost' IDENTIFIED BY '1r0n-H4ck3r';
GRANT ALL PRIVILEGES ON GraveyardBuilder.* TO 'ironhacker'@'localhost';
FLUSH PRIVILEGES;
- Run the following command to start each spring application:
mvn spring-boot:run
, or by using an IDE like IntelliJ IDEA - The application will be available by using the gateway service at http://localhost:8000/
Home page | Home page mobile |
---|---|
Menu page | Menu page mobile |
---|---|
Party page | Party page mobile grid | Party page mobile details |
---|---|---|
Graveyard page | Graveyard page mobile |
---|---|
Battle selection page | Battle selection page mobile |
---|---|
Battle page | Battle page mobile |
---|---|
There is an admin pre-generated profile that can be used for managing the users and fixing possible user problems.
Admin:
username: admin;
password: ironhack - admin;
This project implements a JWT authentication mechanism. The JWT is generated by the backend and sent to the frontend. The frontend uses the JWT to authenticate the user and retrieve information.
To authenticate the user/admin manually (with Postman or another tool) you must follow these steps:
-
To log in with the pretended profile send a post request to the login page: http://localhost:8000/login;
-
In the body of the request add the
x-www-form-urlencoded
format and add the following values:key value username
<username here>
password
<password here>
-
The response will contain a JWT token and an expiration date.
-
To access the protected routes you must add the JWT token to the
Authorization
header of the request with the following format:key value Authorization
Bearer <token here>
All routes available are managed by the Gateway Service on port 8000. For more information on the specific microservices routes, please refer to the documentation of the microservice.
SignIn service:
Route Type | Route | Description |
---|---|---|
POST | /api/v1/signIn/validate/username | Registers a new user, returns UserDTO. Requires body: RegisterUserDTO |
POST | /api/v1/signIn/validate/email | Checks if username is valid (does not exist), returns boolean. Requires body: UsernameDTO |
POST | /api/v1/signIn/register | Checks if email is valid (does not exist), returns boolean. Requires body: EmailDTO |
Auth service:
Route Type | Route | Description |
---|---|---|
POST | /login | User login. Check Security for more information. |
Profile service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/profiles/user | Returns UserDTO of authenticated user. |
GET | /api/v1/profiles/experience | Returns ExperienceDTO of authenticated user. |
GET | /api/v1/profiles/gold | Returns GoldDTO of authenticated user. |
POST | /api/v1/profiles/update/all | Updates user information of authenticated user, returns UserDTO. Requires body: UserDTO. |
POST | /api/v1/profiles/update/password | Updates user password of authenticated user. Requires body: PasswordChangeDTO. |
Party Manager service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/party-manager/party | Returns party (CharacterDTO[]) of authenticated user. |
GET | /api/v1/party-manager/graveyard | Returns graveyard (CharacterDTO[]) of authenticated user. |
GET | /api/v1/party-manager/id/{{id}} | Returns CharacterDTO of authenticated user by character id. Requires id: long. |
POST | /api/v1/party-manager/create | Creates new character for authenticated user, returns CharacterDTO. Requires body: NewCharacterDTO. |
PUT | /api/v1/party-manager/level-up | Levels up a character, returns CharacterDTO. Requires body: LevelUpDTO. |
PUT | /api/v1/party-manager/heal/{{id}} | Heals a character of authenticated user by character id, returns CharacterDTO. Requires id: long. Request parameters: healAmount: int. |
PUT | /api/v1/party-manager/revive/{{id}} | Revives a character of authenticated user by character id, returns CharacterDTO. Requires id: long. |
DELETE | /api/v1/party-manager/delete/{{id}} | Deletes a character of authenticated user by character id. Requires id: long. |
Battle service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/battle/opponents | Retrieves an opponent team to battle, returns OpponentDTO. |
PUT | /api/v1/battle/updateHealth/{{id}} | Update character health by id, returns CharacterDTO. Requires id: long. Request parameters: health: int. |
PUT | /api/v1/battle/addExperience/{{id}} | Add experience to character by id, returns CharacterDTO. Requires id: long. Request parameters: experience: long. |
PUT | /api/v1/battle/addUserExperienceAndGold | Add experience and gold to the authenticated user, returns UserDTO. Request parameters: experience(optional): long, gold(optional): long. |
User Model service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/users/all | Returns all users' details UserDTO. |
GET | /api/v1/users/id/{{id}} | Returns UserDTO by id. Requires id: long. |
GET | /api/v1/users/auth/{{username}} | Returns UserAuthDTO by username. Requires username: string. |
GET | /api/v1/users/username/{{username}} | Returns UserDTO by username. Requires username: string. |
GET | /api/v1/users/email/{{email}} | Returns UserDTO by email. Requires email: string. |
GET | /api/v1/users/partyLevel | Returns list of usernames between min and max party level. Request parameters: min(optional): int, max(optional): int. |
POST | /api/v1/users/register | Registers new user, returns UserDTO. Requires body: RegisterUserDTO. |
PUT | /api/v1/users/update/{{username}} | Updates user information by username, returns UserDTO. Requires username: string. Requires body: UserDTO. |
PUT | /api/v1/users/update/{{username}}/password | Updates user password by username. Requires username: string. Requires body: NewPasswordDTO . |
DELETE | /api/v1/users/delete/{{username}} | Deletes user by username. Requires username: string. |
Character Model service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/characters/all | Return all characters (CharacterDTO[]). |
GET | /api/v1/characters/id/{{id}} | Return character by id. Requires id: long. |
GET | /api/v1/characters/party/{{username}} | Return party (CharacterDTO[]) by user username. Requires username: string. |
GET | /api/v1/characters/graveyard/{{username}} | Return graveyard (CharacterDTO[]) by user username. Requires username: string. |
POST | /api/v1/characters/create | Creates new character, returns CharacterDTO. Requires body: NewCharacterDTO. |
PUT | /api/v1/characters/update | Updates a character information, returns CharacterDTO. Requires body: CharacterDTO. |
PUT | /api/v1/characters/update/levelUp | Levels up a character, returns CharacterDTO. Requires body: LevelUpDTO. |
DELETE | /api/v1/characters/delete/{{id}} | Deletes a character by id. Requires id: long. |
Opponent Selection service:
Route Type | Route | Description |
---|---|---|
GET | /api/v1/opponent/random/{level} | Retrieves an opponent team of a given level, returns CharacterDTO[]. Request parameters: partyLevel: int. |
{
"username": string,
"email": string,
"password": string
}
{
"username": string,
}
{
"email": string,
}
{
"username": string,
"email": string,
"roles": string[],
"profilePictureUrl": string,
"experience": long,
"gold": long,
"partyLevel": int
}
{
"username": string,
"password": string,
"roles": string[]
}
{
"experience": long,
}
{
"gold": long,
}
{
"oldPassword": string,
"newPassword": string
}
{
"newPassword": string
}
{
"userUsername": string,
"type": string,
"name": string,
"pictureURL": string
}
{
"id": long,
"userUsername": string,
"type": string,
"isAlive": boolean,
"deathTime": string,
"name": string,
"pictureURL": string,
"level": int,
"experience": long,
"maxHealth": int,
"currentHealth": int,
"passiveChance": double,
"maxStamina": int,
"currentStamina": int,
"strength": int,
"accuracy": int,
"maxMana": int,
"currentMana": int,
"intelligence": int
}
{
"id": long,
"healthPoints": int,
"energyPoints": int,
"attackPoints": int
}
{
"username": string,
"profilePictureUrl": string,
"opponents": CharacterDTO[]
}
- Complete backend testing;
- Refactor JWT security in microservices;
- Optimize opponent AI actions;
- Animate battle;
- Enhance design;
- Deploy to AWS;
- Add Facebook login and friends integration;
- Online P2P battles
- João Afonso Silva - GitHub