/Backend

Repository with Backend code for InnoTutor project. It is written on Java/Spring.

Primary LanguageJavaMIT LicenseMIT

Backend

dark_logo

LicenseHits-of-Code


Developers: Daniil Livitn, Roman Soldatov

Contents

This is the repository with Backend code for the InnoTutor project. The backend is designed as REST API, so you need the frontend part to access it. Alternatively, you can use Postman or Swagger. The main description of the project is available here

Requirements

Technical Stack:

For this open-source project, we used the simplest registration way via Google Firebase

  • as a website user, you need to have a Google account
  • as a developer, who is going to host this project version, you need to get your own Google credentials.

In case of using this project in Innopolis University we'll change authentication to innopolis email login page.

Stakeholders and their roles 👤

  • Backend Development Team
    • Developer 1 – Backend developer. Implement the backend on Java/Spring which interacts with the PostgreSQL database.
    • Developer 2 – Backend developer. Implement the backend on Java/Spring which returns the result to the frontend via REST API.
    • Developer 3 – Backend developer. Write tests for the Backend.
      Stake: Development process

API

There is documentation with all requests which backend supports. You can read about API documentation here

Database

We use Docker and PostgreSQL for the database. Here is the database diagram

  • If you want to import our database, you can use restore.sql file with empty tables.
  • In application.properties file specify your database's URL, username and password.
  • Guide how to import your database: link
  • Guide how to use PostgreSQL in Docker: link

Google credentials

To log in, you need to provide your Google credentials created here. Then open application.properties file and input your JSON Google credentials file as a single string in GOOGLE_CREDENTIALS field. You can use this online service to convert JSON into a string with escape characters: link

In case of any problems refer to this guide

Hosting and CI

We use Heroku to host the backend. Here is the deployed version of it. For continuous integration, we have to make a pull request into the main branch. Then Heroku will automatically deploy a new version on the server.

To build the project on Heroku's server you need to provide config vars: DATABASE_URL and GOOGLE_CREDENTIALS. Also, add this buildpack https://github.com/buyersight/heroku-google-application-credentials-buildpack.git

Guide how to work with config vars: link

How to install locally

  • Download this project
  • Open it in IntelliJ IDEA
  • Set up database and Google credentials (check instructions above Database and Google credentials)
  • Open InnotutorBackendApplication java class and press ctrl+R

Guide how to run Spring project: link

Another way of install project but without IDE (note: you should have Maven installed)

  1. Clone this repository to your machine using: https://github.com/InnoTutor/Backend.git
  2. You need to create a database and specify the path to it in the application.properties. Besides this, you need to specify your username, password and google credentials.

    Note: Path to application.properties: application.properties
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/innotutor}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:root}
...
GOOGLE_CREDENTIALS=<Your Google Credentials>
  1. Using the command line, navigate to the root folder of the project and run the command:
mvn clean install
  1. After a successful build, you need to run the command:
java -jar .target/innotutor_backend-0.0.1-SNAPSHOT.jar

or

java -jar target/innotutor_backend-0.0.1-SNAPSHOT.jar

Code analysis

  • The result of PMD static analyzer. Do not be scared by such a huge number of violations. We fixed all the violations that we could fix. Other violations can not be fixed due to spring framework-specific code which requires to follow special name convention, so the framework could understand fields and create particular Beans.

Want to contribute?

You can contribute to this project. Just fork the repository from the develop branch, implement changes you want to propose and make a pull request. Also, there are issues, so feel free to submit a new one or participate in existing.