Mudamos is a web platform built with Rails framework.
Local development can be configured using a dotenv
file. The is a .env.sample
that can be used to setup the initial one.
cp .env.sample .env.development
If the sample env file does not require any change, you can just run the setup script, which will copy the file for you.
bin/setup
-- installs dependencies and prepares the database
In order to access the admin area, an admin user must be created.
rake users:create_admin_user
Follow the instructions, and use the created user to access the admin area.
rails s
1 - Run gem install mailcatcher
2 - Run mailcatcher
3 - Go to http://localhost:1080/
- 'PETITION_PUBLISHER_QUEUE': Name of the sqs queue used for publishing the petitions
- 'PETITION_PUBLISHER_PRIORITY': The priority of the sqs queue for the publication the petitions
- 'USER_SYNC_QUEUE': Name of the sqs queue used for the user synchronization with the mobile platform
- 'PETITION_MOBILE_SYNC_QUEUE': Name of the sqs queue used for the synchronization of the petitions versions with the mobile api
- 'PETITION_MOBILE_SYNC_QUEUE_PRIORITY': The priority of the sqs queue for the synchronization of the petitions versions with the mobile api
- 'PETITION_PDF_GENERATION_QUEUE': Name of the sqs queue used for the generation of the PDFs of the petitions
- 'PETITION_PDF_GENERATION_QUEUE_PRIORITY': The priority of the sqs queue for the generation of the PDFs of the petitions
- 'PETITION_PDF_BUCKET': Name of the bucket where the petition's pdfs are stored
- 'PETITION_NOTIFIER_QUEUE': Name of the bucket where push messages are sent
- 'PETITION_NOTIFIER_QUEUE_PRIORITY': The priority of the notifier queue
- 'AWS_ACCESS_KEY_ID': AWS access key id used to access the aws resources
- 'AWS_SECRET_ACCESS_KEY': AWS secret access key used to access the aws resources
- 'AWS_REGION': The region where the AWS resources are
APP_DEFAULT_HOST
: Which url the application is hostedAPP_DEFAULT_SCHEME
: Which scheme the application uses (http or https)- 'MOBILE_API_URL': The Mobile API url
- 'MOBILE_API_SECRET': The Mobile secret key
- 'MOBILE_API_TIMEOUT': The ammount in seconds the system will use as timeout when trying to communicate with the Mobile API
- 'ONESIGNAL_API_KEY': The one signal api key (push message)
- 'ONESIGNAL_APP_ID': The one signal app id (push message)
API_CACHE_EXPIRES_IN
: The ammount in minutes that the system will use to expire requests from the Mobile APIMOBILE_API_ID_IOS
: The iOs Mobile app id
Patners can access information on this platform. in order to do so, an oauth applciation must be created by an admin user.
- as an admin access:
oauth/applications
and create a new partner application - Patners can use both the client id (application id) and client secret to issue a request for an access token
Partners should call like bellow:
curl -XPOST "http://apphost/oauth/token?client_secret={client_secret}&client_id={client_id}&grant_type=client_credentials" -H "Accept: application/json" -d ''
A valid response would be:
{"access_token":"98f46d3a93245a428ec2749fe40cf256bcd9ff81d3cddb08fb28b0fb3515a598","token_type":"bearer","expires_in":7200,"created_at":1488915853}
Later partners can use the available apis:
- pre signature
This api receives a user which will be pre signing a project.
curl -v -XPOST "http://apphost/partners_api/petitions/{petition_id}/pre_sign" -H "Authorization: Bearer 66bffa59da5bf7a14e5a92c1affa8a4a3928195933135ff0fac8550336f65f1e" -H "Accept: application/json" -H "Content-Type: application/json" -d '{"email": "[email protected]", "name": "A user name"}'
Where petition_id
is the id of a project (PetitionPlugin::DetailVersion
).
A 204 response means a success.
Recommended values:
- Default Visibility Timeout: 60 secs
- Message Retention Period: 4 days (SQS default)
- Maximum Message Size: 256 KB (SQS default)
- Delivery Delay: 0 secs (SQS default)
- Receive Message Wait Time: 0 secs (SQS default)
Recommended values:
- Default Visibility Timeout: 60 secs
- Message Retention Period: 4 days (SQS default)
- Maximum Message Size: 256 KB (SQS default)
- Delivery Delay: 0 secs (SQS default)
- Receive Message Wait Time: 0 secs (SQS default)
Recommended values:
- Default Visibility Timeout: 60 secs
- Message Retention Period: 4 days (SQS default)
- Maximum Message Size: 256 KB (SQS default)
- Delivery Delay: 0 secs (SQS default)
- Receive Message Wait Time: 0 secs (SQS default)
Recommended values:
- Default Visibility Timeout: 60 secs
- Message Retention Period: 14 days
- Maximum Message Size: 256 KB (SQS default)
- Delivery Delay: 15 secs (SQS default)
- Receive Message Wait Time: 15 secs
bundle exec shoryuken -C config/shoryuken.yml -R
Remember to export your env vars
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 | | | |
| | | | | |<-------------------------+ | | |
| | | | | | | | | |
| | | | Publishes the petition | | | | | |
| | | | <-------------------------+ | | | | |
| | | | | | | | | |
+---+ +---+ +---+ +---+ +---+
$ rake push:message["A title", "A body"]