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 databaseMudamos depends on the following softwares:
brew install imagemagick
https://github.com/ello/heroku-buildpack-imagemagick
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/
API_CACHE_EXPIRES_IN
: The ammount in minutes that the system will use to expire requests from the Mobile APIAPP_DEFAULT_HOST
: Which url the application is hostedAPP_DEFAULT_SCHEME
: Which scheme the application uses (http or https)MOBILE_API_ID_IOS
: The iOs Mobile app idPatners can access information on this platform. in order to do so, an oauth applciation must be created by an admin user.
oauth/applications
and create a new partner applicationPartners 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:
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": "user@mail.com", "name": "A user name"}'
Where petition_id
is the id of a project (PetitionPlugin::DetailVersion
).
A 204 response means a success.
Recommended values:
Recommended values:
Recommended values:
Recommended values:
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 (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 | | | |
| | | +--------------------------------------------------------> | | | |
| | | | | | | | | |
+---+ +---+ +---+ +---+ +---+
$ rake push:message["A title", "A body"]
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
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