Coder Social home page Coder Social logo

code4romania / monitorizare-vot-votanti-api Goto Github PK

View Code? Open in Web Editor NEW
8.0 20.0 10.0 15.74 MB

API pentru monitorizarea incidentelor din cadrul alegerilor parlamentare din 2016.

Home Page: http://monitorizarevot.ro/

License: Mozilla Public License 2.0

PHP 98.31% JavaScript 0.24% CSS 0.03% HTML 1.03% Dockerfile 0.38%
civic-tech civic-hacking code4ro elections monitoring api laravel election-data election-monitoring

monitorizare-vot-votanti-api's Introduction

Monitorizare Vot - Rest API

GitHub contributors GitHub last commit License: MPL 2.0

See the project live

Monitorizare Vot is a mobile app for monitoring elections by authorized observers. They can use the app in order to offer a real-time snapshot on what is going on at polling stations and they can report on any noticeable irregularities.

The NGO-s with authorized observers for monitoring elections have real time access to the data the observers are transmitting therefore they can report on how voting is evolving and they can quickly signal to the authorities where issues need to be solved.

Moreover, where it is allowed, observers can also photograph and film specific situations and send the images to the NGO they belong to.

The app also has a web version, available for every citizen who wants to report on election irregularities. Monitorizare Vot was launched in 2016 and it has been used for the Romanian parliamentary elections so far, but it is available for further use, regardless of the type of elections or voting process.

Contributing | Built with | Repos and projects | Deployment | Feedback | License | About Code4Ro

Contributing

This project is built by amazing volunteers and you can be one of them! Here's a list of ways in which you can contribute to this project.

Built With

Uses Laravel 5.2

Main packages:

  • JWT-Auth - tymondesigns/jwt-auth
  • Dingo API - dingo/api
  • Laravel-CORS barryvdh/laravel-cors

Requirements

  • PHP 7+ (with mbstring, openSSL extensions);
  • Apache or Nginx (mod_rewrite required);
  • MySQL;

Repos and projects

Related projects:

Other MV related repos:

Deployment

Services

In /tools/docker you can find a docker compose file that starts a php server with apache, a mysql server and a phpmyadmin instance. You will need to have docker and docker-compose(https://docs.docker.com/compose/) installed.

To start the services, go to the tools/docker folder and run:

docker-compose up -d

Project setup

  • Install prerequisites
composer install
  • Configurations

Initial .env setup

cp .env.docker .env

Add new local keys

php artisan key:generate //Not sure if really neccesary
php artisan jwt:generate

Run DB scrips

php artisan migrate --seed
  • Run the local server with
php artisan serve
  • Test your storage folders structure

    Sometimes these folders need to be created manually if the user doesn't have the rights to do so:

    • /storage/framework/cache
    • /storage/framework/sessions
    • /storage/framework/views
    • /storage/logs

Access http://localhost:8000 or http://localhost:8000/api/check in the browser to test the project. For documentation you can access http://localhost:8000/api/documentation

  • (Optional) Swagger

To generate the swagger files

php artisan l5-swagger:publish
php artisan l5-swagger:generate

Once the files are generated you can access the swagger documentation at: http://localhost:8000/api/documentation

Testing it works

Once everything is built and started you can access the webservice at http://localhost:3200 and the phpmyadmin at http://localhost:3201 . If you are running Linux then you can use the direct IPs as well ( this does not work for Mac or Windows ).

To list the container do:

docker ps

The containers can be accessed by:

docker exec -it <container_name> bash

You can run composer and php commands from inside the container.

To add special configs to the PHP ini inside the container you can modify the config file.

Project structure

Main Features

AuthController

  • login();
  • signup();
  • recovery();
  • reset();

You will need:

  • login: just email and password;
  • signup: whatever you like: you can specify it in the config file;
  • recovery: just the user email address;
  • reset: token, email, password and password confirmation;

IncidentController Endpoint

  • GET /api/incidents ( get last 20 incidents )

  • GET /api/incidents?limit=100 (Get more incidents)

  • _GET /api/incidents?limit=10&page=3+ (limit parameter is optional, will default to 20)

  • GET /api/incidents?status[]=Pending (filter by state)

  • GET /api/incidents?status[]=Pending&status[]=Rejected (get pending and rejected)

  • POST /api/incidents (Create incident)

  • PUT /api/incidents/5/approve (Approve incident - ADMIN)

  • PUT /api/incidents/5/reject (Reject incident - ADMIN)

  • DELETE /api/incidents/5 (Delete incident - ADMIN)

A Separate File for Routes

You can specify your routes in the api_routes.php file, that will be automatically loaded. In this file you will find many examples of routes.

Secrets Generation

Every time you create a new project starting from this repository, the php artisan jwt:generate command will be executed.

Configuration

As I already told before, this boilerplate is based on dingo/api and tymondesigns/jwt-auth packages. So, you can find many informations about configuration here and here.

However, there are some extra options that I placed in a config/boilerplate.php file.

  • signup_fields: you can use this option to specify what fields you want to use to create your user;
  • signup_fields_rules: you can use this option to specify the rules you want to use for the validator instance in the signup method;
  • signup_token_release: if "true", an access token will be released from the signup endpoint if everything goes well. Otherwise, you will just get a 201 Created response;
  • reset_token_release: if "true", an access token will be released from the signup endpoint if everything goes well. Otherwise, you will just get a 200 response;
  • recovery_email_subject: here you can specify the subject for your recovery data email;

Creating Endpoints

You can create endpoints in the same way you could to with using the single dingo/api package. You can read its documentation for details.

After all, that's just a boilerplate! :)

Cross Origin Resource Sharing

If you want to enable CORS for a specific route or routes group, you just have to use the cors middleware on them.

Thanks to the barryvdh/laravel-cors package, you can handle CORS easily. Just check the docs at this page for more info.

Feedback

  • Request a new feature on GitHub.
  • Vote for popular feature requests.
  • File a bug in GitHub Issues.
  • Email us with other feedback [email protected]

License

This project is licensed under the MPL 2.0 License - see the LICENSE file for details

About Code4Ro

Started in 2016, Code for Romania is a civic tech NGO, official member of the Code for All network. We have a community of over 500 volunteers (developers, ux/ui, communications, data scientists, graphic designers, devops, it security and more) who work pro-bono for developing digital solutions to solve social problems. #techforsocialgood. If you want to learn more details about our projects visit our site or if you want to talk to one of our staff members, please e-mail us at [email protected].

Last, but not least, we rely on donations to ensure the infrastructure, logistics and management of our community that is widely spread across 11 timezones, coding for social change to make Romania and the world a better place. If you want to support us, you can do it here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.