Skip to content

A Rails backend to support the Simple.org mobile app

License

Notifications You must be signed in to change notification settings

vkrmis/simple-server

 
 

Repository files navigation

Simple Server

Build Status

This is the backend for the Simple app to help track hypertensive patients across a population.

Development Setup

First, you need to install ruby: https://www.ruby-lang.org/en/documentation/installation It is recommended to use rbenv to manage ruby versions: https://github.com/rbenv/rbenv

gem install bundler
bundle install
rake db:create db:setup db:migrate

To run simple-android app with the server running locally, you can use ngrok https://ngrok.com

brew cask install ngrok
rails server
ngrok http 3000

The output of the ngrok command will have an url that can be used to access local-server. This url should be set as qaApiEndpoint in gradle.properties.

Workers

We use sidekiq to run async tasks. To run, first make sure that redis (>4) is installed:

brew install redis

# after installing ensure your redis version is >4
redis-server -v

Start the sidekiq process by running

bundle exec sidekiq

Testing Email

We use Mailcatcher for testing email in development. Please use the following to set it up on your machine.

Note: Please don't add Mailcatcher to the Gemfile, as it causes conflicts.

gem install mailcatcher
mailcatcher

Now you should be able to see test emails at http://localhost:1080

Configuring

The app can be configured using a .env file. Look at .env.development for sample configuration

Running the application locally

The application will start at http://localhost:3000.

RAILS_ENV=development bundle exec rails server

Running the tests

RAILS_ENV=test bundle exec rspec

Documentation

API

API Documentation can be accessed at /api-docs on local server and hosted at https://api.simple.org/api-docs

ADRs

Architecture decisions are captured in ADR format and are available in /doc/arch

ERD (Entity-Relationship Diagram)

These are not actively committed into the repository. But can be generated by running bundle exec erd

Deployment

  • simple-server is deployed to the environment using capistrano.
  • Make sure you add your SSH keys as single sign-on so that cap doesn't get confused when there's more than 1 instance to deal with. You can do this simply by running ssh-add -K ~/.ssh/id_rsa.
bundle exec cap <enviroment> deploy
# eg: bundle exec cap staging deploy

Rake tasks can be run on the deployed server using capistrano as well. For example,

bundle exec cap staging deploy:rake task=db:seed

Contributing

The contribution guidelines can be found here.

About

A Rails backend to support the Simple.org mobile app

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 86.0%
  • HTML 11.2%
  • CSS 2.4%
  • Other 0.4%