The Pearl API. Handles server side logic and communication with the Pearl Client.
- Before you begin, make sure you have Ruby 2.2+ and Rails 4.2+ installed.
- Sign up for a SendGrid account (emails to users are sent using SendGrid servers). Alternatively, you can configure the API to use a different smtp server of your choice.
- Sign up for a TrueVault account (TrueVault serves as a HIPAA compliant database for Pearl). Afterwards, sign in and:
- Create a TrueVault "admin" user.
- Create at least one TrueVault vault. Creating a different vault for testing, development and production environments is recommended.
- Take note of the following keys. You will need them to configure the API to work with TrueVault.
Account ID
- Found in theAccount
tab.API Key
- Go to theUsers
tab, and click on the admin user to view the API key.Vault ID(s)
- Found in theVaults
tab.
-
Clone this repository.
-
CD into the Pearl API root directory.
-
Install the dependencies:
bundle install
-
Create the database tables:
rake db:create rake db:migrate
-
In the
config
directory, create anapplication.yml
file.NOTE: Do NOT commit this file - it is meant to contain private information for your eyes only! It should be ignored by default with the bundled
figaro gem
.# config/application.yml # Setting environment varibles for communicating with TrueVault: TV_ACCOUNT_ID: YOUR_TRUEVAULT_ACCOUNT_ID_HERE TV_ADMIN_API_KEY: YOUR_TRUEVAULT_ADMIN_API_KEY_HERE # Setting environment varibles for sending emails with SendGrid: SENDGRID_USERNAME: YOUR_SENDGRID_USERNAME_HERE SENDGRID_PASSWORD: YOUR_SENDGRID_PASSWORD_HERE # Secret key for devise DEVISE_SECRET_KEY: YOUR_DEVISE_SECRET_KEY_HERE # Production database password PEARLAPI_DATABASE_PASSWORD: YOUR_PEARLAPI_DATABASE_PASSWORD_HERE # Development environment-specific variables development: TV_VAULT_ID: YOUR_DEVELOPMENT_TRUEVAULT_VAULT_ID_HERE SECRET_KEY_BASE: YOUR_DEVELOPMENT_SECRET_KEY_BASE_HERE # Test environment-specific variables test: TV_VAULT_ID: YOUR_TEST_TRUEVAULT_VAULT_ID_HERE SECRET_KEY_BASE: YOUR_TEST_SECRET_KEY_BASE_HERE # Production environment-specific variables production: TV_VAULT_ID: YOUR_PRODUCTION_TRUEVAULT_TEST_VAULT_ID_HERE SECRET_KEY_BASE: YOUR_PRODUCTION_SECRET_KEY_BASE_HERE
-
Thats it! If you want to test out the API:
rails server
-
If you wish to use a different SMTP server (instead of SendGrid), open
application.yml
file and replace# config/application.yml ... # Setting environment varibles for sending emails with SendGrid: SENDGRID_USERNAME: YOUR_SENDGRID_USERNAME_HERE SENDGRID_PASSWORD: YOUR_SENDGRID_PASSWORD_HERE ...
with:
# config/application.yml ... # Setting environment varibles for sending emails: CUSTOM_SMTP_SERVER_USERNAME: YOUR_USERNAME_HERE CUSTOM_SMTP_SERVER_PASSWORD: YOUR_PASSWORD_HERE ...
-
Update the
environment.rb
file. It should look something like the following, but may change depending on the SMTP server you choose to use.# config/environment.rb ... # Configure mailer ActionMailer::Base.smtp_settings = { :user_name => ENV["CUSTOM_SMTP_SERVER_USERNAME"], :password => ENV["CUSTOM_SMTP_SERVER_PASSWORD"], :domain => 'heroku.com', :address => YOUR_SMTP_ADDRESS_HERE, :port => YOUR_SMTP_PORT_HERE, :authentication => :plain, :enable_starttls_auto => true } ...