项目作者: pranavagiligar

项目描述 :
Event management system
高级语言: Kotlin
项目地址: git://github.com/pranavagiligar/velocity.git
创建时间: 2020-03-05T14:27:25Z
项目社区:https://github.com/pranavagiligar/velocity

开源协议:MIT License

下载


velocity-CI

Event management system - This can manage generic events defined by user and communicate this with subscribers


Please refer Wiki or GithubIO for better readablity


Setup

  1. Install free IntelliJ IDEA Community Edition and opt for Kotlin in it
  2. Clone this repository
  3. Setup MongoDB server. Easy one is to get free MongoDB database in a hosted server from HERE
    • Get setup of cloud MongoDB(Atlas) HERE
  4. Building the project

    1. For Windows: Open the Command prompt in the project directory
      • run the command gradlew.bat clean bootRun
    2. For Linux or Mac: Open the Terminal emulator in the project directory

      • run command ./gradlew clean bootRun

        Note: In case you just want to generate JAR file, replace bootRun with bootJar or build

    3. Running the jar can be done using command java -jar -Ddebug=true build/libs/velocity_{version}_{yyMMddHHmm}/server-{version}.jar

      • example:

        1. pranava@ubuntu:~/velocity$ pwd
        2. /home/pranava/velocity
        3. pranava@ubuntu:~/velocity$ ./gradlew clean build
        4. > Task :compileKotlin
        5. BUILD SUCCESSFUL in 3s
        6. 5 actionable tasks: 5 executed
        7. pranava@ubuntu:~/velocity$ java -jar -Ddebug=true build/libs/velocity_0.0.1-SNAPSHOT_2003102238/server-0.0.1-SNAPSHOT.jar
        8. Spring Boot (v2.2.4.RELEASE)
        9. embedded.tomcat.TomcatWebServer : Tomcat started on port: 80 (http) with context path '/api'
        10. com.velocity.VelocityApplicationKt : Started VelocityApplicationKt in 4.256 seconds

      If you are seeing Tomcat Started and Started VelocityApplicationKt, means project successfully built and running on port 80
      Note: -Ddebug=true switch is temporary. Future commits would include Custom Run configuration file.

    1. Insert roles into roles collection in MongoDB.

      1. db.roles.insertMany([
      2. { name: "ROLE_USER" },
      3. { name: "ROLE_MODERATOR" },
      4. { name: "ROLE_ADMIN" },
      5. ])

      Note: Currently this is manual step. In future this might be done through an API

    2. Running the project: Open a web browser and open http://localhost/api/server/info which will show a welcome page

      Note: This Project needs Java 8/11

Configurations

  1. The application.properties file contains the line
    spring.data.mongodb.uri=${MONGO_URL_CON}
    in which MONGO_URL_CON is the MongoDB database URL of the MongoDB server which is the system environment variable

    Find the steps to set MONGO_URL_CON as system environment variable in HERE
  2. Like MONGO_URL_CON environment variable setup, JWT_SECRET_KEY also need to be set as environment variable. The key is any string which represent as encryption password

  3. The application.properties has a key called com.velocity.jwtExpirationMs which represents JWT expiration time in milliseconds. Default is 1-Day(86400000 ms)

  4. The port number of the server can be configured in application.properties file. Default port number is port 80

  5. Postman collection 2.1 can be found in velocity/docs/velocity.postman_collection.json


Project structure

The current project structure is just a draft. After getting comfortable with Spring, package refactor will be done.

  1. ```
  2. pranava@ubuntu:~/velocity/src/main$ pwd
  3. /user/pranava/velocity/src/main
  4. pranava@ubuntu:~/velocity/src/main$ tree
  5. .
  6. ├── java # Java files
  7. ├── kotlin # Kotlin files
  8. │ └── com
  9. │ └── velocity
  10. │ ├── VelocityApplication.kt # Main class
  11. │ ├── config # DB configs. (Temporary)
  12. │ │ └── MongoConfig.kt
  13. │ ├── controller # Entry point of API (Apart from filters)
  14. │ │ ├── AuthController.kt
  15. │ │ └── UserController.kt
  16. │ ├── dao # Access point for all repository (DB and network calls)
  17. │ ├── db # Datebase
  18. │ │ ├── doc # Collection models
  19. │ │ └── repo # Base Reposiotries to access collections
  20. │ ├── model
  21. │ │ ├── ERole.kt # Static predefined roles
  22. │ │ └── payload # Request/Response models
  23. │ │ ├── request # Request models
  24. │ │ └── response # Response models
  25. │ ├── security # Spring security related modules
  26. │ │ ├── WebSecurityConfig.kt # Route - authentication/authorization configs
  27. │ │ ├── jwt # JWT related classes
  28. │ │ └── service # Secuirty support services (UserDetailsService implementations)
  29. │ └── service # Application business logics
  30. └── resources # All the Spring configuration files
  31. └── application.properties # Application properties (Like MongoDB connection URL, JWT secret key)
  32. ```

Learning resources


Keywords

  • Spring Boot 2.2.4
  • Spring Security
  • Kotlin
  • Java 8/11
  • MongoDB
  • JWT
  • Gradle
  • REST API

Project Velocity -
Copyright (c) 2020 Pranava Giligar