Skip to content

Java Vert.x API with AWS RDS PostgresDB for the SFTT React Client. Deployed to AWS ElasticBeanstalk via TravisCI.

Notifications You must be signed in to change notification settings

Code-4-Community/speak-for-the-trees-backend-v2

Repository files navigation

Speak for the Trees Backend

Build Status Coverage Status

This is the Java backend API for the Speak for the Trees frontend.

Setup 🔧

First follow all the steps for setting up the general development environment which can be found here. This will walk you through:

  • Installing, creating, and running a local PostgreSQL database (speak-for-the-trees)
  • Configuring IntelliJ
  • Installing Maven
  • Installing Java 8
  • Configuring project properties files
  • Compiling and running the API

Following these steps, all that is left is to import data into the database. This has been made easy through import routes. You can find these import routes in the Postman collection posted below. Follow the steps below in order to import all the relevant data:

  • Call POST api/v1/user/signup to create a super admin user with a JSON body that follows the format of:
    {
        "username": "someUsername",
        "email": "[email protected]",
        "password": "somePassword",
        "firstName": "someFirstName",
        "lastName": "someLastName"
    }
    • Using your preferred method for postgres (Intellij, PgAdmin, postgres console, etc.) edit the user row you just created so that their privilege_level column is equal to SUPER_ADMIN
    • Call POST /api/v1/user/login to login to your admin user account with a JSON body that follows the format of:
    {
        "email": "[email protected]",
        "password": "yourPassword"
    }
    • Copy the "accessToken" returned by that call and add it as the value of a header called 'X-Access-Token' for all seeding API calls
  • Import data is stored in the SFTT.import.data S3 bucket. Ask one of the team leads for the .json files
    • Call POST api/v1/protected/import/neighborhoods with the contents of neighborhoods.json as the body
    • Call POST api/v1/protected/import/sites with the contents of sites.json as the body.
    • Call POST api/v1/protected/import/tree_species with the contents of tree_species.json as the body.
    • Call POST api/v1/protected/import/tree_benefits with the contents of tree_benefits.json as the body.

At this point your database is fully set up and contains real data for neighborhoods and trees around Boston!

Running the API 🤖

The ServiceMain.java class has the main method for running the code, this can be run directly in IntelliJ. Alternatively: mvn install creates a jar file at: service/target/service-1.0-SNAPSHOT-jar-with-dependencies.jar. This can be run from the command line with the command java -jar service-1.0-SNA..... The API will then be available at http://localhost:8081 by default.

Postman Collection 🚀

Our Postman collection is an ever expanding list of routes that can easily be called through Postman. You can find our latest collection here. Make sure the API is running when you try to call a route.

API Specification 📖

The official API specification for this backend can be found at https://docs.c4cneu.com/sftt/sftt-api-spec/. This lists every single route that is callable, explains what it does, shows the associated request body and lists the possible responses. When making changes to the backend developers should create a matching PR for the API spec reflecting their changes.

Database Schema 📝

The database schema can be found here: https://lucid.app/lucidchart/2e440718-aca6-4efa-adb1-4fc6112bcf42/view. This is an up-to-date overview of what fields the database contains.

About

Java Vert.x API with AWS RDS PostgresDB for the SFTT React Client. Deployed to AWS ElasticBeanstalk via TravisCI.

Topics

Resources

Stars

Watchers

Forks

Languages