itsriodejaneiro / mudamos-web

Plataforma de práticas participativas Mudamos
https://www.mudamos.org
GNU General Public License v3.0
42 stars 6 forks source link

Mudamos

Mudamos is a web platform built with Rails framework.

Project setup

Local development can be configured using a dotenv file. The is a .env.sample that can be used to setup the initial one.

If the sample env file does not require any change, you can just run the setup script, which will copy the file for you.

Dependencies

Mudamos depends on the following softwares:

Accessing the admin area

In order to access the admin area, an admin user must be created.

Follow the instructions, and use the created user to access the admin area.

Running the web server

Testing emails on development

1 - Run gem install mailcatcher 2 - Run mailcatcher 3 - Go to http://localhost:1080/

Environment variables

Partners api

Patners can access information on this platform. in order to do so, an oauth applciation must be created by an admin user.

Getting an access token

Partners should call like bellow:

A valid response would be:

Later partners can use the available apis:

Pre signature api

This api receives a user which will be pre signing a project.

Where petition_id is the id of a project (PetitionPlugin::DetailVersion).

A 204 response means a success.

Queue configurations

Petition pdf generation

Recommended values:

Petition mobile sync

Recommended values:

Petition publisher

Recommended values:

Petition notifier

Recommended values:

Running the workers

bundle exec shoryuken -C config/shoryuken.yml -R

Remember to export your env vars

Petition flow

This diagram shows the flow of the petition, from the user creation, to its publication.

+--------------------+    +------------------------+    +------------------------+    +-------------------------+    +------------------------+
|                    |    |                        |    |                        |    |                         |    |                        |
|                    |    |                        |    |                        |    |                         |    |                        |
|    Admin User      |    |      Mudamos-Web       |    |           SQS          |    |      Mobile-api         |    |       Blockchain       |
|                    |    |                        |    |                        |    |                         |    |                        |
|                    |    |                        |    |                        |    |                         |    |                        |
+--------------------+    +------------------------+    +------------------------+    +-------------------------+    +------------------------+
        +---+                      +---+                           +---+                          +---+                         +---+
        |   |Creates the petition  |   | Schedule pdf generation   |   |                          |   |                         |   |
        |   +---------------------->   +------------------------>  |   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |  Generates the pdf and    |   |                          |   |                         |   |
        |   |                      |   |  stores it on S3          |   |                          |   |                         |   |
        |   |                      |   | <-------------------------+   |                          |   |                         |   |
        |   |                      |   |                           |   |   Register petition on   |   |                         |   |
        |   |                      |   |                           |   |   the mobile api         |   |                         |   |
        |   |                      |   +--------------------------------------------------------->|   |                         |   |
        |   |                      |   |                           |   |                          |   |  Register the petition  |   |
        |   |                      |   |                           |   |                          |   |  on the blockchain      |   |
        |   |                      |   |                           |   |  Schedule the petition   |   +-----------------------> |   |
        |   |                      |   |                           |   |  publication (async, SQS)|   |                         |   |
        |   |                      |   |                           |   |<-------------------------+   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |    Publishes the petition |   |                          |   |                         |   |
        |   |                      |   | <-------------------------+   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |  Schedule share link      |   |                          |   |                         |   |
        |   |                      |   |  generation               |   |                          |   |                         |   |
        |   |                      |   +------------------------>  |   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |  Generate share link and  |   |                          |   |                         |   |
        |   |                      |   |  stores it                |   |                          |   |                         |   |
        |   |                      |   | <-------------------------+   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   | Schedule sync petition    |   |                          |   |                         |   |
        |   |                      |   +-------------------------> |   |                          |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        |   |                      |   |  Start the petition sync  |   |                          |   |                         |   |
        |   |                      |   | <-------------------------+   |                          |   |                         |   |
        |   |                      |   |                           |   |  Sync petition info      |   |                         |   |
        |   |                      |   |                           |   |  on the mobile api       |   |                         |   |
        |   |                      |   +--------------------------------------------------------> |   |                         |   |
        |   |                      |   |                           |   |                          |   |                         |   |
        +---+                      +---+                           +---+                          +---+                         +---+

Send a push message

$ rake push:message["A title", "A body"]

Release

Inorder to build a new app image version, you need to provide the script both APP_VERSION and HUB_APP_URI.

ps. aws cli v1 required.

This command below will build the image and apply the version, staging and latest tags. The version tag will be pushed to the HUB (image repository).

$ APP_VERSION=x.xx.x HUB_APP_URI=some-uri ./bin/release

In order to push the staging image do:

$ HUB_APP_URI=some-uri ./bin/push-staging

In order to push the latest image (production).

$ HUB_APP_URI=some-uri ./bin/push-latest

Troubleshooting

If libv8 and therubyracer fails to install on mac, try:

$ brew install v8@3.15
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)

If you're using a Postgres docker, you may need to set PGGSSENCMODE=disable

$ PGGSSENCMODE=disable bundle exec rails s