- Maven version 3.9.6 or higher
Installing Maven on macOS using Homebrew:
- Open your terminal.
- Type the following command and press Enter to install Homebrew (if not installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Once Homebrew is installed, run the following command to install Maven: brew install maven
-
Wait for the installation process to complete.
-
Verify the Maven installation by typing: mvn -version
This should display information about the installed Maven version.
Installing Maven on Windows:
-
To install Maven on Windows, we head over to the Apache Maven site to download the latest version and select the Maven zip file, for example, apache-maven-3.9.6-bin.zip.
-
Adding Maven to the Environment Path We add both M2_HOME and MAVEN_HOME variables to the Windows environment using system properties and point them to our Maven folder.
-
Verify the Maven installation by typing: mvn -version
Then, we update the PATH variable by appending the Maven bin folder — %M2_HOME%\bin — so that we can run the Maven command everywhere.
Then, we unzip it to the folder where we want Maven to live.
- Java (version 17 or higher) Link
- Any text editor of your choice (Preferred - IntelliJ Community or Ultimate Edition).
- Docker Desktop: Installation steps
- MySQL Docker Image: Installation steps
-
Go to Docker Desktop
-
You'll see skill-tree-backed (If the process is running)
-
skill-tree-backend > skill-tree-backend-db-1 > open in terminal
To login to MySQL
mysql -u root -p
(in terminal) password : password
Reference Screenshots:
If the project is started with docker compose up
, this can be seen once you open Docker Desktop:
Terminal needs to be opened here:
Semicolon is important in the commands
Username: testuser Password: testpassword
CREATE DATABASE skilltree;
SHOW DATABASES;
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
GRANT ALL ON skilltree.* TO testuser;
- After creating the database project needs to be compiled.
- Open skill-tree-backend in intellij.
- Java_Home path needs to be added here.
- You can either add the existing path and JDK 17 can be downloaded inside intellij.
- If adding from the existing path, go to Settings > Project Structure > Choose the earlier installed Java 17 SDK.
- Install Lombok plug-in, if you see annotation errors
- Create a .env file inside the skill-tree folder with content mentioned in the Additional Configuration Steps below
- Click on "Edit Configurations" > Add new "Application" Configuration
- Choose "Java 17" and "skill-tree" folder in the dropdown
- Choose com.RDS.skilltree.SkillTreeApplication as the Main class
- Add the .env file you created in the first step for the environment variables and click "OK"
(Below steps are not required as of now.)
Refer to this link for detailed steps.
-
Create a database user with full access for table creation, deletion, and modification (for development only in local MySQL).
-
After creating the database user, enter the credentials in the Skill Tree Spring Boot application.
-
Attempt to connect to the database using the URL "jdbc:mysql://${MYSQL_HOST:localhost}:3306/${DB_NAME}".
-
Create a simple API to test the database connection and data retrieval. For example, create a
/test
route inskill-tree/src/main/java/com/RDS/skilltree/User/UserController.java
.package com.RDS.skilltree.User; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class UserController { @GetMapping("/test") public void test(){ System.out.println("test123"); } }
Steps to Generate a JWT Token (Similar to Website Backend Repo)
- If you've already generated the public and private keys during the website backend setup, you can proceed directly to step 5.
- Ensure the website-backend is running locally.
- Generate Public and Private keys using openssl with the following commands:
openssl genrsa -out ./private.key 4096
openssl rsa -in private.key -pubout -outform PEM -out public.key
- Obtain a user token (private and public key stored in
local.js
file). - After calling
localhost:3000/auth/github/login
, the backend will generate the JWT token. - Validate the token using jwt.io by entering the public and private keys stored in the website backend.
- Use the public key in the Skill Tree repo to decrypt the JWT token passed for authentication.
docker exec -it skill-tree-db-1 bin/bash
- bash-4.4#
mysql -u root -p -A
By default after deployment MySQL has following connection restrictions:
mysql> select host, user from mysql.user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | healthchecker |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
4 rows in set (0.00 sec)
Apparently, for security purposes, you will not be able to connect to it from outside of the docker container. If you need to change that to allow root to connect from any host (say, for development purposes), do the following:
- update mysql.user set host='%' where user='root';
- Quit the mysql client.
- Restart the docker container
Now you can connect to the mysql running in the docker container, also to connect to it on the terminal type mysql -utestuser -p -P3306 -h127.0.0.1
- Download the EnvFile plugin from the marketplace.
- Create a new Env file with the provided content and fill in the RDS public key value.
DB_NAME=${DB_NAME} MYSQL_DB_USERNAME=testuser MYSQL_DB_PASSWORD=testpassword MYSQL_ROOT_PASSWORD=password DB_DDL_POLICY=update RDS_PUBLIC_KEY="-----BEGIN PUBLIC KEY----- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -----END PUBLIC KEY-----"
Note : Publickey in both RDS backend and skilltree backend should be the same.
- Click "Edit Configurations" -> Create a new application.
- Give it a name instead of "Unnamed".
- In "Build and Run", select Java 17.
- In the class , check "Enable Env file" and "Substitute env var" checkboxes.
- Click "Apply" and "OK".
- Click "Build and Run".
- Retrieve the Bearer token by accessing
http://localhost:3000/auth/github/login
and locating the keyrds-session-development
in the application. The value associated with this key is theBearer token
. - Click the green "Run" button or "Shift + F10" to start the application
- After starting the Tomcat server on port
8080
, attempt to access the dummy routehttp://localhost:8080/test
using theGET
method in Postman or ThunderClient while providing thebearer token
. If the terminal displaystest123
, it indicates that the setup has been successful.
Using Website - backend
On Local - http://localhost:3000/auth/github/login?redirectURL=https://staging-skilltree.realdevsquad.com/tasks?v2=true
This will create a cookie in your browser rds-session-v2-development
On Staging - https://staging-api.realdevsquad.com/auth/github/login?redirectURL=https://staging-skilltree.realdevsquad.com/tasks?v2=true
This will create a cookie in your browser named rds-session-v2-staging
This repo uses https://github.com/diffplug/spotless/tree/main/plugin-maven#java for formatting files.
Please build using mvn compile
in local or run mvn spotless:apply
before pushing the code to fix any formatting errors.
To check if the codebase is formatted, you can explicitly use mvn spotless:check
The Continuous Integration build for pushed commits may fail when a Pull Request is created if your code doesn't follow project's formatting guideline.
- Port 8080 Conflict: Make sure there is no other process running on the 8080 port where we are going to run our server check this with lsof -p PID (PID - port id)
- Local MySQL Conflict: Make sure there is no local Mysql running on the local machine