Website URL: https://github.com/YCPRadioTelescope/RT-Contracts
Clone command (https): git clone https://github.com/YCPRadioTelescope/RT-Contracts
Clone command (git): git@github.com:YCPRadioTelescope/RT-Contracts
Name: YCPRadioTelescope
GitHub Account: https://github.com/YCPRadioTelescope
Email Address: jhorne@ycp.edu
Name: Joel Horne
Email Address: jhorne@ycp.edu
The following technologies are used in the development of the back-end application:
- MySQL Database (SQL Database/Dialect)
- Gradle (Build Management/Task Execution)
- Spring (Application Framework)
- IntelliJ IDEA Ultimate Edition (IDE)
- Kotlin (Programming Language)
- Liquibase (Database Migrations)
- Travis CI (Continuous Integration Service)
- GitHub (Version Control)
You can clone the repository using either the https or the git commands supplied above, but in order to contribute to the repository, you must be added as a contributor. To achieve this, contact the repository owner (mentioned above), and they will handle this.
IntelliJ IDEA Ultimate Edition is free for anyone with a student license, which thankfully, applies to anyone with an ".edu" email address. All you need to do is create an account on their website, and from there, you can access all software that applies to you via the student license. It is important to note that the student license can only be used for student projects, which this project falls under.
The process on windows is rather straightforward, and is primarily handled through an installer/setup wizard.
The steps needed to install via Linux are as follows:
- Download the latest version IntelliJ IDEA Ultimate Edition
- Extract the tar file using (tar -xvf )
- Move the newly extracted folder to the /opt folder (sudo mv /opt/)
- Go to the folder location in the opt folder (cd /opt/)
- Go inside of the IntelliJ IDEA bin folder (cd bin)
- Run the idea.sh script. This will run the initial setup for IntelliJ IDEA (./idea.sh)
- You will then be prompted by IntelliJ to enter some user-specific preferences for IntelliJ IDEA.
- After choosing your preferences, verify your installation using your JetBrains account
- Download the disk image (DMG)
- Mount the disk image and follow the installation instructions
For Windows users, you should be able to follow the steps here to install Gradle.
If you are using Mac or Linux, it is highly recommended to install SDKMAN, which allows you to then easily install Gradle using SDKMAN. The list of steps to install Gradle on Mac and Linux are:
- Install SDKMAN (curl -s “https://get.sdkman.io” | bash)
- Initialize SDKMAN (source "$HOME/.sdkman/bin/sdkman-init.sh")
- Verify the installation was a success (sdk version)
- Use SDKMAN to install Gradle (sdk install gradle)
- Note: This will install the most recent version
- To install a specific version, supply the version (sdk install gradle 4.7)
- Verify the installation was a success (gradle -v)
For Windows users, you should be able to follow the steps/setup wizard here
If you are using linux, do the following:
- Update package lists (sudo apt-get update)
- Install MySQL Server (sudo apt-get install mysql-server)
- Start MySQL Server (sudo systemctl start mysql) or (sudo systemctl start mysqld) depending on your linux distro
- Secure the installation (sudo mysql_secure_installation). This will have you enter the root username and password Verify your credentials (mysql -u root -p). This will prompt you to enter the password you entered in step 4.
- Download disk image (DMG) from dev.mysql.com/downloads/mysql/
- Mount the disk image and follow the installer instructions
- In the terminal, change the directory to the MySQL folder (cd /usr/local/mysql)
- Run the secure installation (sudo bin/mysql_secure_installation) and follow the setup
- To start running MySQL, open your Mac's System Preferences and open the application near the bottom of the window. There will be a button to start the server.
IntelliJ has a built-in database tab that allows you to manage the contents of your database from within the IDE. In order to add your localhost database to IntelliJ, do the following:
- Open Database Tab in IntelliJ. In most cases, this is located on the right-hand side of the screen. On some Linux distributions, you may need to manually access it through
View -> Tool Windows -> Database. - Add
radio_telescopeschema to MySQL usingcreate database radio_telescope - Edit the line in build.gradle
def profile = (project.hasProperty('profile') ? project.profile : 'prod').toLowerCase()todef profile = (project.hasProperty('profile') ? project.profile : 'local').toLowerCase()to setup the database on your local machine. - Add New MySQL Datasource & Test Connection (using credentials used for MySQL installation) Note: specify the database url as the one found in the local application properties file
- If the connection works, you're good to go!
The application depends on certain application properties files that unfortunately cannot be added to GitHub. These files must be obtained from the repository owner. The properties files must be placed in
/RT-Contracts/src/main/resources/properties.
As well, to run the database locally you must add your local MySQL password to the spring.datasource.password field of the application_local.properties file.
In order to install the gradle wrapper (needed to boot up the application locally), issue the following
command in the terminal inside of IntelliJ:
gradle wrapper
Then, boot the application with gradlew bootRun (./gradlew bootRun on Linux). This will populate the local database.
The API endpoints and their respective form templates are hosted on SwaggerHub here. They will be updated as new endpoints are added.
The Radio Telescope Contracts/Back-End application uses javadocs to publish documentation. This process can be done manually via the following process:
- Publishing javadocs in kotlin is done via dokka
- In the build.gradle file, run the dokka task, or in the terminal run 'gradle dokka' to generate the documentation folder
- Take the contents of the 'docs' folder that was created and put it in the gh-pages branch
- NOTE: overwrite any existing files in the gh-pages branch with the contents of the newly generate docs folder
- Still on the gh-pages branch, add, commit, and push the changes and GitHub will handle the rest
Alternatively, if you cloned the repository via git/ssh, you can simply run the following command, which will automate the above process for you (recommended):
- Run the
./publish-api-docs.shscript
The docs can be viewed here. As a general rule of thumb, the docs should be published whenever code is merged into master and deployed to the production server.
The management console for the web application (along with the services used for this project) can be accessed here.
In order to access the management console, you need an IAM User account. If you do not have one, contact the console root user (mentioned above) and they will create an IAM user for you and send you the credentials.
For the backend, we use:
- Java JDK 8, openjdk or through oracle, either way just needs to be jdk 8
- Gradle 4.9
- Intellij Ultimate Edition (You can get this for free using your YCP email)
- make sure to change the "changeset tfranks:" number to 125
- make sure that your mySql plugins correlate to the version of your mySql installer
There is a lot going on with these files, and if something isn't working the problem most likely resides here. Important Things to check:
- The spring.datasource.username is set to the correct user of your database
- The spring.datasource.password is set to the correct password of your database
- The file name of properties files is set to application_{insert correct name here}.properties This is the connection string it looks for when running ["src/main/resources/properties/application_${profile}.properties"]
- as weird as it is in order to fix the Bean error is to setup up a new backend project and make sure it runs correctly
- then after that return to the original project and now the error should now be gone
The backend will not run on any other Java JDK version than 1.8. If the build fails during the compile step, verify the java version it is looking for is correct
The backend may run into another issue with the bean creation:
"2022-10-12 11:29:00.140 ERROR 9340 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' [...] "
- Suggested fix is to restart the computer since Tomcat is very moody