Skip to content

Latest commit

 

History

History
109 lines (82 loc) · 6.45 KB

README.md

File metadata and controls

109 lines (82 loc) · 6.45 KB

Agora-Web

Readme

Rest API for Agora Web that uses Agora: An Electronic Voting Library implemented in Scala

This project is created using the play framework 2.6 seeds template.

build status

Scala Play Updated
August 08, 2018

To run the development environment for this REST API, you need Git, Sbt and MongoDB installed.

Table of contents

Installation

To install the backend, please do the following:

  1. Install Git.
  2. Clone this repo with https://gitlab.com/aossie/Agora-Web
  • Note: If you just want to use the project, cloning is the best option. However, if you wish to contribute to the project, you will need to fork the project first, and then clone your Agora-Web fork and make your contributions via a branch on your fork.
  1. Install and run MongoDB

    1. The project currently only supports MongoDB v3.6 or lower
    2. Follow the installation instructions for your respective platform here:
      • MacOS
        • Please make sure you have the Homebrew package manager installed. If not, you can follow the instructions here to install it.
        • Make sure you install the older version of MongoDB with brew install [email protected]
        • Make sure that the mongod command points to the 3.6 version of the binary. You confirm this by executing which mongod. It should output something like:

        /usr/local/opt/[email protected]/bin/mongod

      • Linux
        • Instructions for popular Linux distributions are available at the above link.
        • Unfortunately, older releases of MongoDB do not officially support newer releases of some distributions. The packages may work fine, but compatibility is not guaranteed.
      • Windows
        • Please make sure that you select v3.6 when the above link points you to the MongoDB Download Center. Any installation method (MSI/Zip) should be fine.
    3. Create a database named in MongoDB using the mongo command or using MongoDB Compass
  2. Configure Silhouette to allow Agora's frontend to do Oauth2 authentication:

    1. Make a copy of silhouette.conf and rename it to silhouetteLocal.conf.

    2. Create new applications in Facebook, Twitter and Google

    3. Fill the following fields in silhouetteLocal.conf with the ids, keys and secrets from your created applications. You will need to provide only the keys for Facebook since it's the only social provider we support for now, though we intend to support the others in the future.

      facebook.clientID=${?FACEBOOK_CLIENT_ID}
      facebook.clientSecret=${?FACEBOOK_CLIENT_SECRET}
      google.clientID = ${?GOOGLE_CLIENT_ID}
      google.clientSecret = ${?GOOGLE_CLIENT_SECRET}
      
    4. Change the redirect URL in silhouetteLocal.conf to your localhost localhost:9000.

    5. Delete the line include "silhouetteLocal.conf" from silhouetteLocal.conf.

  3. As above, make a copy of application.conf and rename it to applicationLocal.conf.

    1. Assign your MongoDB URI to the mongodb.default.uri field.
      • For example, if you are using MongoDB locally, and you created a database named 'Agora' during the setup phase of MongoDB, then you URL might look like "mongodb://localhost:27017/Agora" Therefore, you must set the field like this:

      mongodb.default.uri=mongodb://localhost:27017/Agora

    2. Set your SendGrid username and password in applicationLocal.conf.
      user = ${?SENDGRID_USERNAME}
      password = ${?SENDGRID_PASSWORD}
      
    3. Delete the lines include "silhouette.conf" and include "applicationLocal" from applicationLocal.conf.

Running the application

To start the API, please do the following:

  • Make sure you have java 8 installed and not java 9. For some reasons the build fails with java 9
  • Start the server by running sbt run in the root folder.
  • Go to http://localhost:9000/ in a browser. Where you will see the API documentation hosted using swagger UI.
    • Note: Changing any source code while the server is running will automatically recompile and reload the application on the next HTTP request.

API documentation

REST API documentation is available under address: REST API

Deployment

The current development branch is deployed on heroku and is available at http://agora-rest-api.herokuapp.com/

Troubleshooting your local environment

Always git pull and get the latest from master. Google and Stackoverflow are your friends. You can find answers for most technical problems there. If you run into problems you can't resolve, feel free to open an issue.

Further Reading / Useful Links