Skip to content

Instantly share code, notes, and snippets.

@icemc
Last active October 21, 2020 17:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icemc/a40d856362e888dc611a78fd255d081f to your computer and use it in GitHub Desktop.
Save icemc/a40d856362e888dc611a78fd255d081f to your computer and use it in GitHub Desktop.
GSoC-2018 Contribution - by Abanda Ludovic

Agora Web Frontend and REST API

Student : Abanda Ludovic

Organisation : AOSSIE

Links

Agora Web API

The goal of the project is to divide the old agora platform into a REST API and a web frontend. This part of the project was to produce a REST API(backend) for the Agora platform. I made use of the models that were already found in the code base and also reused as much code as I could. The following parts will describe the project in details.

Use case modeling

I have identified the following tasks in the project at the starting of the project.

  1. Endpoints for user signup and login with email base accounts - Done
  2. Endpoints for user login using social media account - Done
  3. Endpoints for user to logout. - Done
  4. Endpoints for user to create and schedule Election. - Done
  5. Endpoints for user to edit Election. - Done
  6. Endpoints for user to delete the Election. - Done
  7. Endpoints for election creator to invite the voter to the Election. - Done
  8. System will inform the voter with the link to vote the Election. - Done
  9. System will handle the timeline of the Election. Done
  10. System will count the votes and produce the results for the Election after the Election. - Done
  11. Voter can vote the Election. - Done

Deep view into the technology.

This project is created using play framework 2.6 seeds template.

These are some of the main technologies, we have used in the project.

We started the Google summer of code by defining all backend specifications as Swagger specs. Configured the project using play framework 2.6 seeds and integrated swagger UI then deploying it in the cloud. We used Heroku as the Cloud option. We have made available the prototype user interfaces in the Heroku cloud. After that, we have started to work with abstract schema of the models and create controllers to handle actions on those models. Then we started to work with the user authentication part. We use silhouette as our authentication library. After that we spent time to configure the Silhouette module and created email based signup and signin endpoints after which we worked on authentication with social providers still using silhouette. Finally we have built JWT token based authentication and authorization system for OAuth2 and email based login. Apart from that we created endpoints for user to logout, update their account and change their password.

After that we started working on the election services and models.Then we searched a cloud solution for MongoDB. We use Mlab as our cloud database and found it to be great for development. We used Play2-ReactiveMongoDB to connect to mongoDB in order to store and get our election and user data. After which we created controllers and endpoints to create, edit, delete and get election data.

After which we created endpoints to verify voters identity and for voters to vote for elections. We have used the AES (Advanced encryption standard) for creating the passcode for the voter. We used Play-Mailer with Sendgrid to send the emails to voters. Then we started to implement the vote counting function using Agora library and saved the data into the database.

We created results endpoints to serve the results for finished elections or elections that have support for real-time results. All these endpoints are available at demo with basic swagger documentation describing each endpoints. I discussed a lot with my mentors on each step that was to be taken and they have always helped me with valuable guidance on what is needed.Though the API supports various features I can't really say it is production ready since we have to test it with real users and observe how it responds. We worked on the API documentation as we were building the API due to swagger integration. So each new endpoint that was created was accompanied with its documentation, we have many things to improve in documentation and also in the Agora API.

Merge Requests

  1. Merge request !1 - Upgraded to play 2.6.12 and added swagger specs: - status Merged

    • Upgraded old play framework app from version 2.5 to 2.6.
    • Integrated swagger UI
    • Implemented email base signup and sign in endpoints
  2. Merge request !2 - Imported models from old codebase and made the required changes.: - status Merged

    • Imported required models and services from old code base and added some too
  3. Merge request !3 - Added user actions - Status: Merged

    • Implemented user account actions such as logout, change password, change profile info and get user data
    • Host development branch on Heroku
  4. Merge request !4 - Social authentication - Status: Merged

    • Implementing Social authentication with OAuth2 social providers such as Facebook and Google. (edited)
  5. Merge request !5 - Account verification - Status: Merged

    • Implemented user account verification endpoints
    • Implemented means for user to reset password if forgotten.
  6. Merge request !6 - Election endpoints - Status: Merged

    • Implemented elections endpoints
    • Users could now create, edit, delete and view elections
    • Implemented endpoints for users to add voters.
    • Implemented endpoint for users to vote.
  7. Merge request !7 – Voting Result endpoints - Status: Merged

    • Implemented endpoint to get election results
  8. Merge request !8 - Major improvements - Status: Merged

    • Let dates be in UTC format so that users with different time zones will have the correct time shown to them.
    • Return user information and token during login instead of only token to prevent second Rest call to get user data
    • Add other ballot parsers (before we supported only Preferential ballot parsing). Now we support all ballot types
    • Add other elections that depends on the new Ballots supported
  9. Merge request !9 - Documentation - Status: Merged

    • Improved readme file and included documentation about my GSOC work

Agora Frontend

This part of the project was to produce an angular 6 application as frontend for the Agora platform. The project was built from scratch after the backend was in an advanced state. The following parts will describe the project in details.

Use case modeling

I have identified the following tasks in the project at the starting of the project.

  1. Interface for user signup and login with email base accounts - Done
  2. Interface for user login using social media account - Done
  3. Interface for user to change password for email based accounts - Done
  4. Interface for user to logout - Done
  5. Interface for user to create and schedule Election. - Done
  6. Interface for user to edit Election. - Done
  7. Interface for user to delete the Election. - Done
  8. Interface for election creator to invite the voters to vote for the Election. - Done
  9. Interface for voters to vote the Election. - Done
  10. Interface for election results - Done

Deep view into the technology.

This project is created using Angular 6. It makes use of various open source libraries available for angular 6. Some of which are listed bellow

We started working on the frontend at the beginning of the second phase of GSOC. We started by defining all models that are required to communicate with the backend. After which we hosted the minimal app on heroku. From there we started working with user authentication, the first authentication type we started with was the email based account authentication system then we later finished with authentication using social providers such as Facebook. To obtain social accounts from the social providers we used Angularx-social-login. At this point users could signup and login into the system

After which we worked on user specific actions such as viewing profile information, updating profile, changing their password and user logout. We created interfaces for the actions described above

After that we started working on election services and specific models to support our design. We created interfaces to create, edit and delete elections along side with a dashboard. After this we created interfaces for the election creator to invite voters, we also created interfaces for these voters to vote for the elections they were invited. Then finally we created an interface to show the results of the election.

I would like to thank every AOSSIE member, especially my mentors, Thuvarakan Tharmarajasingam, Bruno Woltzenlogel Paleo and Ezequiel Postan for being so nice and helpful. I have learnt a lot in the past 3 months and it has been a great experience to be a part of this wonderful community.

Merge Requests

  1. Merge request !1 - Initial angular 6 setup: - status Merged

    • Initialized the project with Agular 6 web framework
  2. Merge request !2 - Added angularx-social plugin for OAuth2 authentication - status Merged

  3. Merge request !3 - Footer header - Status: Merged

    • Implemented footer and header components
  4. Merge request !4 - Login logout - Status: Merged

    • Implemented user signup and signin using email base accounts
    • Implemented user signin using social providers.
  5. Merge request !5 - Dashboard - Status: Merged

    • Implemented user dashboard containing user elections and some statistics
    • Implemented profile interface with ability to update profile information
    • Implemented add, edit and election interfaces
    • Implemented interface for election creator to invite voters
  6. Merge request !6 - Result and voting - Status: Merged

    • Implemented interface for voters to vote
    • Implemented interface for user to view election results
    • Made some major bug fixes
  7. Merge request !7 - Recover password - Status: Merged

    • Implemented reset password functionality for email based accounts
  8. Merge request !8 - Documentation - Status: Merged

    • Improved readme file and included documentation about my GSOC work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment