Advertisement
adwas33

SPRING DOKUMENTACJA

May 1st, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.73 KB | None | 0 0
  1. # Project for register startups
  2. ## About
  3. ---
  4. Project was created to WSEI Design Thinking Hub science club . It will be used for realize competition called "Elevator Pitch" . Application has got 2 dedicated profiles one is dedicated for developers second one is for production enviroment .
  5.  
  6. ## Features
  7. ---
  8. - Register startup team
  9. - Send email to support with custom user message and his name
  10. - Confirm account via email with veryfication link
  11. - Login to user pannel
  12. - Insert startup idea
  13. - Edit user data
  14. - Delete account
  15. - Change password
  16. - Resend email with veryfication link
  17. ---
  18. #### Admin features
  19. - Get all registered teams
  20. - Edit own password
  21. - Annouce to every participant message with email written in HTML
  22. - Review Idea
  23. ---
  24. ## Usage
  25. ---
  26. >Mostly features depends on logged user .
  27. >Here i will provide which user has got feature deppending on his authority .
  28.  
  29. | Endpoint | Action with descritpion |Authority|
  30. |------|------|-----|
  31. |/register|Endpoint to register team with validation|Anybody|
  32. |/resendEmail|Send again email to requested mail|Anybody|
  33. |/contact-form|Provide admin email with message|Anybody|
  34. |/login|Login with LoginCredenitials JSON|Anybody|
  35. |/editUserData|User will edit his own data|User|
  36. |/getUserData|Get user data from backend|Admin,User,Test|
  37. |/deleteTeam|Delete logged team|User|
  38. |/changePassword|Change password endpoint |Admin,User|
  39. |/admin/annouce|Admin will send annouce message to all teams |Admin|
  40. |/admin/setQualifcationStatusAndComment/{id}|Place where we can put review |Admin|
  41. |/admin/getTeams|Get all present teams from backend|Admin|
  42. > *` Warring`*
  43. >Program should be configured correctly before launch with correct enviroment variables .
  44. >Watch [Installation](#Configure-enviroment-variables) part .
  45. ## Tech stack
  46. ---
  47. - [Spring framework] - Is a set of production ready for user in production enviroment
  48. - [Spring Boot] - Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".
  49. - [Spring MVC] - Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning .
  50. - [Spring Data JPA] - Spring project that provides API for map the entities . Under simple API works Hibernate with ORM .
  51. - [Spring Security] - Spring Security is a framework that provides authentication and authorization.
  52. - [Thymeleaf] - is a server-side Java template engine for both web and standalone environments.
  53. - [Java Mail API] - Java Liblary to send emails from java application . It support's emails in HTML.
  54. - [Lombock] - Liblary to reduce boilerplate code.
  55. - [H2 Database] - In memory database mostly used for developer needs .
  56. - [MySQL] - It is the most popular SQL server .
  57. - [Liquibase] - It is opensource liblary for DB migrations which support SQL , XML and other formats .
  58. - [Jakarta Bean Validation] - is a pack of annotation with constraints and validation parameters .
  59.  
  60.  
  61. ## Installation
  62. ---
  63. Application requires Java 16 + to run and in production profile additionally MySQL serwer.
  64.  
  65. If you want compile that project you have to have JDK with java 16 + and enter the package and then run these commands.
  66.  
  67. ```sh
  68. mvn clean
  69. mvn compile
  70. mvn package
  71. ```
  72. That commands will create <NAME_FILE>.jar file which is ready to deploy to server or run by comand :
  73. ```
  74. java -jar <NAME_FILE>.jar
  75. ```
  76. It will run our spring application . Following command will run it in the background .
  77. ```
  78. java -jar <NAME_FILE>.jar &
  79. ```
  80. We can run program some custom enviroment variables . Just replace <VARIABLE> with name of variable xyz value . We can use it as mutch as we want .
  81. ```
  82. java -jar -D<VARIABLE>=xyz <NAME_FILE>.jar
  83. ```
  84. ### Configure enviroment variables
  85. ---
  86. > Our application has to be configured before launch .
  87. > Here I will provide you some informations what is nessesary to be configured
  88.  
  89. In file application.properities you have to provide informations :
  90. ```
  91. frontEndLink=
  92. emailSupport=
  93. jwt.expirationTime=
  94. jwt.secret=
  95. spring.mail.password=
  96. spring.mail.username=
  97. admin.password=
  98. admin.email=
  99. testUser.password=
  100. testUser.email=
  101. spring.profiles.active=
  102. ```
  103. - frontEndLink - fill with URI to frontend
  104. - emailSupport - fill with email to whom will be going mails from contactform
  105. - jwt.expirationTime - fill with number of seconds how many seconds will be JWT Token valid
  106. - jwt.secret - fill with generated secret KEY (Array of characters)
  107. - spring.mail.password - fill with password to emailsender
  108. - spring.mail.username - fill with username of emailsender
  109. - admin.password - fill with admin password ( ADMIN LOGIN CREDENITIAL )
  110. - admin.email - fill with admin email (ADMIN LOGIN CREDENITIAL)
  111. - That same do for TESTUSER
  112. - spring.profiles.active= fill with dev ( developer mode ) or prod (production mode)
  113.  
  114. If you want to configure for example database URL you will have to edit application-??.yml file depends on profile which will be active .
  115. ## Docker
  116. ---
  117. Application is eazy to build with docker. I provided dedicated DockerFile so everything is done expect build image . `Application will run in PRODUCTION MODE by defalut here.`
  118.  
  119. By default, the Docker will expose port 8080, so change this within the
  120. Dockerfile if necessary. When ready, simply use the Dockerfile to
  121. build the image.
  122.  
  123. You have to compile application before use this command .
  124. ```sh
  125. docker build -t .
  126. ```
  127.  
  128. This will create the app image and pull in the necessary dependencies.
  129.  
  130. Once done, run the Docker image and map the port to whatever you wish on
  131. your host. In this example, we simply map port 8000 of the host to
  132. port 8080 of the Docker (or whatever port was exposed in the Dockerfile):
  133.  
  134. ```sh
  135. docker run -d -p 8000:8080 --restart=always --cap-add=SYS_ADMIN --name=<YOUR_NAME>
  136. ```
  137. ## Demo account
  138. ---
  139. At present application is avaliable at address
  140. [http://dth.wsei.edu.pl/](http://dth.wsei.edu.pl/)
  141. To test that application is running i have created test user witch mutch reduced authorities than normal user .
  142. Login credenitials
  143. ```
  144. Login : test@test.pl
  145. Password : test
  146. ```
  147. [Spring framework]: <https://spring.io/projects/spring-framework>
  148. [Spring Boot]:<https://spring.io/projects/spring-boot>
  149. [Spring MVC]:<https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html>
  150. [Spring Data JPA]:<https://spring.io/projects/spring-data-jpa>
  151. [Spring Security]:<https://spring.io/projects/spring-security>
  152. [Jakarta Bean Validation]:<https://beanvalidation.org/2.0/spec/>
  153. [Thymeleaf]:<https://www.thymeleaf.org/>
  154. [Java Mail API]:<https://www.oracle.com/java/technologies/javamail-api.html>
  155. [Lombock]:<https://projectlombok.org/>
  156. [H2 Database]:<http://h2database.com/html/main.html>
  157. [MySQL]:<https://www.mysql.com/>
  158. [Liquibase]:<https://www.liquibase.org/>
  159.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement