You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. To install maven type the following command in your terminal:
14
+
```bash
19
15
brew install maven
20
-
21
-
4. Wait for the installation process to complete.
22
-
23
-
5. Verify the Maven installation by typing:
16
+
```
17
+
2. Verify your installation using the following command:
18
+
```bash
24
19
mvn -version
20
+
```
21
+
If maven is installed correctly you should see the maven version in the terminal:
22
+
```bash
23
+
Apache Maven 3.9.7
24
+
```
25
25
26
-
This should display information about the installed Maven version.
27
-
28
-
Installing Maven on Windows:
29
-
26
+
#### Windows
30
27
1. 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.
31
-
32
28
2. Adding Maven to the Environment Path
33
29
We add both M2_HOME and MAVEN_HOME variables to the Windows environment using system properties and point them to our Maven folder.
34
-
35
30
3. Verify the Maven installation by typing:
36
31
mvn -version
32
+
4. Then, we update the PATH variable by appending the Maven bin folder — %M2_HOME%\bin — so that we can run the Maven command everywhere.
33
+
34
+
### Setup database and configure env
35
+
- To setup the database & create a `.env` file run the following command in your terminal:
36
+
```bash
37
+
make setup
38
+
```
39
+
- To edit your environment variables edit the `.env` file.
40
+
41
+
#### NOTE:
42
+
- If you do not have `make` installed, run the `docker-run` and `copy-env` commands from the `Makefile` manually.
43
+
44
+
### Install EnvFile Plugin in IntelliJ
45
+
- To read the values from your `.env` you will need install the `EnvFile` plugin.
46
+
- To Install the plugin to go `settings` > `Plugins` > `Marketplace` > EnvFile.
47
+

48
+
49
+
### Create a configuration in IntelliJ
50
+
- Press the Edit configurations button on the top right of your screen
51
+

52
+
- Create a new application
53
+

54
+
- Select `Java version 17`, `Skill tree` and `SkillTreeApplication`
- Check `EnvFile` and `Substitute Environment Variables`
57
+

58
+
- Add path to the `.env` file you created above
59
+

60
+
- You should a new entry like so:
61
+

62
+
- Click on `Apply` and then `Ok`
63
+
64
+
### Running your application
65
+
- Press the `Run` button on the top right of your screen to run the application.
66
+

67
+
68
+
## Steps to authenticate a user during development
69
+
- Run RDS backend on your local machine
70
+
- Copy the `public key` from `local.js` (if not in `local.js` copy it from `development.js`) and add it in your `.env` file.
71
+
- Run skill tree frontend, click on `signin with github` button
72
+
- Once authenticated you will be redirected to `localhost:4000` (skill tree frontend homepage) and a `rds-session-v2-development` cookie will be set in the browser which will be used for authentication when making API calls.
73
+
- NOTE:
74
+
- make sure that `incompleteUserDetails` is false for the user in firestore, else the redirect will not work as intended.
37
75
38
-
Then, we update the PATH variable by appending the Maven bin folder — %M2_HOME%\bin — so that we can run the Maven command everywhere.
39
-
40
-
Then, we unzip it to the folder where we want Maven to live.
41
-
42
-
- Java (version 17 or higher) [Link](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
43
-
- Any text editor of your choice (Preferred - IntelliJ Community or Ultimate Edition).
## Steps for Creating the Database (To be executed in order)
75
-
76
-
Semicolon is important in the commands
77
-
78
-
Username: testuser
79
-
Password: testpassword
80
-
81
-
```
82
-
CREATE DATABASE skilltree;
83
-
SHOW DATABASES;
84
-
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
85
-
GRANT ALL ON skilltree.* TO testuser;
86
-
```
87
-
88
-
## Steps for setting up skill-tree in Intellij
89
-
90
-
1. After creating the database project needs to be compiled.
91
-
2. Open skill-tree-backend in intellij.
92
-
3. Java_Home path needs to be added here.
93
-
4. You can either add the existing path and JDK 17 can be downloaded inside intellij.
94
-
5. If adding from the existing path, go to Settings > Project Structure > Choose the earlier installed Java 17 SDK.
95
-
6. Install Lombok plug-in, if you see annotation errors
96
-
97
-
## Creating Run/Debug Configuration
98
-
99
-
1. Create a .env file inside the skill-tree folder with content mentioned in the Additional Configuration Steps below
100
-
2. Click on "Edit Configurations" > Add new "Application" Configuration
101
-
3. Choose "Java 17" and "skill-tree" folder in the dropdown
102
-
4. Choose com.RDS.skilltree.SkillTreeApplication as the Main class
103
-
5. Add the .env file you created in the first step for the environment variables and click "OK"
104
-
105
-
(Below steps are not required as of now.)
106
-
107
-
### Steps to Connect the Service to MySQL Running in Docker
108
-
109
-
Refer to this [link](https://find10archived.medium.com/how-to-connect-a-mysql-docker-container-with-a-local-spring-boot-application-9366707dce0d) for detailed steps.
110
-
111
-
1. Create a database user with full access for table creation, deletion, and modification (for development only in local MySQL).
112
-
2. After creating the database user, enter the credentials in the Skill Tree Spring Boot application.
113
-
3. Attempt to connect to the database using the URL "jdbc:mysql://${MYSQL_HOST:localhost}:3306/${DB_NAME}".
114
-
4. Create a simple API to test the database connection and data retrieval. For example, create a `/test` route in `skill-tree/src/main/java/com/RDS/skilltree/User/UserController.java`.
4. Obtain a user token (private and public key stored in `local.js` file).
139
-
5. After calling `localhost:3000/auth/github/login`, the backend will generate the JWT token.
140
-
6. Validate the token using [jwt.io](https://jwt.io/) by entering the public and private keys stored in the website backend.
141
-
7. Use the public key in the Skill Tree repo to decrypt the JWT token passed for authentication.
142
-
143
-
## Steps for connecting mysql workbench to run mysql inside docker
144
-
145
-
1.`docker exec -it skill-tree-db-1 bin/bash`
146
-
2. bash-4.4# `mysql -u root -p -A`
147
-
148
-
By default after deployment MySQL has following connection restrictions:
149
-
150
-
```
151
-
mysql> select host, user from mysql.user;
152
-
+-----------+---------------+
153
-
| host | user |
154
-
+-----------+---------------+
155
-
| localhost | healthchecker |
156
-
| localhost | mysql.session |
157
-
| localhost | mysql.sys |
158
-
| localhost | root |
159
-
+-----------+---------------+
160
-
4 rows in set (0.00 sec)
161
-
```
162
-
163
-
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:
164
-
165
-
3. update mysql.user set host='%' where user='root';
166
-
4. Quit the mysql client.
167
-
5. Restart the docker container
168
-
169
-
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`
170
-
171
-
## Additional Configuration Steps
172
-
173
-
1. Download the EnvFile plugin from the marketplace.
174
-
2. Create a new Env file with the provided content and fill in the RDS public key value.
175
-
```env
176
-
DB_NAME=${DB_NAME}
177
-
MYSQL_DB_USERNAME=testuser
178
-
MYSQL_DB_PASSWORD=testpassword
179
-
MYSQL_ROOT_PASSWORD=password
180
-
DB_DDL_POLICY=update
181
-
RDS_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
182
-
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
183
-
-----END PUBLIC KEY-----"
184
-
```
185
-
> Note : Publickey in both [RDS backend](https://github.com/Real-Dev-Squad/website-backend) and skilltree backend should be the same.
186
-
3. Click "Edit Configurations" -> Create a new application.
187
-
4. Give it a name instead of "Unnamed".
188
-
5. In "Build and Run", select Java 17.
189
-
6. In the class , check "Enable Env file" and "Substitute env var" checkboxes.
190
-
7. Click "Apply" and "OK".
191
-
8. Click "Build and Run".
192
-
9. Retrieve the Bearer token by accessing `http://localhost:3000/auth/github/login` and locating the key `rds-session-development` in the application. The value associated with this key is the `Bearer token`.
193
-
10. Click the green "Run" button or "Shift + F10" to start the application
194
-
11. After starting the Tomcat server on port `8080`, attempt to access the dummy route `http://localhost:8080/test` using the `GET` method in Postman or ThunderClient while providing the `bearer token`. If the terminal displays `test123`, it indicates that the setup has been successful.
195
76
196
77
## To Authenticate Yourself
197
78
@@ -212,10 +93,3 @@ Please build using `mvn compile` in local or run `mvn spotless:apply` before pus
212
93
To check if the codebase is formatted, you can explicitly use `mvn spotless:check`
213
94
214
95
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.
215
-
216
-
## Known Issues Faced by Other Developers
217
-
218
-
1. 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)
219
-
2. Local MySQL Conflict: Make sure there is no local Mysql running on the local machine
0 commit comments