Skip to content

Latest commit

 

History

History
145 lines (100 loc) · 4.33 KB

CONTRIBUTING.md

File metadata and controls

145 lines (100 loc) · 4.33 KB

Contributing

Thank you for contributing! This guide will help you set up the project environment.

Setup Instructions

  1. Clone the repository

    git clone https://github.com/Co-App-Team/backend.git
  2. Open the project

    • Open the project in IntelliJ IDEA.
  3. Install Java JDK

If set up properly, your Java SDK version in IntelliJ should look as follows:

JavaSDKIntelliJ.png

  1. Set up Gradle

    • If Gradle is not set up in IntelliJ, download and configure it.

    • Set the Gradle version for this project:

      ./gradlew wrapper --gradle-version 9.2.1
    • Verify Gradle version:

      ./gradlew --version
  2. Include Keys

For the application to function properly, you need to include keys inside local.properties under the root of the project:

CoApp
├── Dockerfile
├── README.md
├── build
├── build.gradle
├── docs
├── gradle
├── gradlew
├── gradlew.bat
├── local.properties    <----- Include keys here
├── settings.gradle
└── src

local.properties will have the following fields:

SPRING_DATA_MONGODB_URI=<YOUR_MONGO_DB_URI>
NO_REPLY_EMAIL_PASSWORD=<YOUR_NO_REPLY_EMAIL_PASSWORD>
JWT_SECRET_KEY=<YOUR_JWT_SECRET_KEY>
GOOGLE_GENAI_API_KEY=<YOUR_GOOGLE_GENAI_API_KEY>

Important

For TA to run and build our project locally, please reach out to any of our team member for local.properties

  1. You're ready to go!

    • You can now build and run the project using Gradle. Launch the backend locally by select: buildProjectFirstOption.png

or find src/main/java/com/backend/coapp/CoAppApplication.java and run:

buildProjectSecondOption.png

Development workflow

Preliminary

Project structure

We follow a layered architecture, where an application is organized into horizontal layers, and each layer has a clear responsibility. Ensure to follow the structure as described in ARCHITECTURE.md.

Coding standard

We follow Google Java Style Standard for all Java code to ensure consistency and readability across the project.

Tip

Make sure to format your code using ./gradlew spotlessApply before commit.

Commit message

Each commit should follow the structure below:

Header  # A concise summary, no more than 50 characters

Body    # Optional. Wrap lines at 72 characters

Development

  1. Create a branch by following the convention: task/<issue_number>-<IndicatorOfTheTask>.
  2. Merge to dev when the task development is completed.
  3. dev is only merged to main on the release day.

Important

All tasks branch need to be merged to dev. Please avoid merging task branch directly to main.

Authentication for development

For every API call, except from api/auth/*, the application will expect JWT to be included in the header of the request. To obtain the JWT token, you will need to log in to the application (if you have not yet created an account, please do so). After log in successfully, you can find JWT in cookie:

loginFromPostman.png

Postman will also cache your cookie here:
tokenExample.png

If you need to clean cookie and login against, please select Cookies and remove Authorization cookie

Testing

Unit tests

To run unit tests, you can either run through IntelliJ or through terminal using this command:

./gradlew test

Important

Since we are using testing container, make sure to have Docker running in the background before triggering the unit tests

Mutation tests

To run mutation tests, you can use the following command:

./gradlew pitest 

Load tests

To run the load test, please follow the instructions shown in loadtest.js.