Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cl0nebot/in-spiritus

 
 

Repository files navigation

Build Status Code Climate Test Coverage Issue Count

In Spiritus

The goal of this project is to simplify order and distribution management for startup food companies. This is the backend for several other client apps (Working Titles).

  1. Last Strawberry
  2. Watermelon Juice

Setup Dev Environment

  1. Install docker

Setup Third Party Services

Signup for the following services:

  1. Xero
  2. Mailgun
  3. AWS
  4. Papertrail
  5. Routific
  6. Mapbox

Setup papertrail logging

  1. Create a new log destination
  2. Duplicate and rename config/log_config.example.yml ~> config/log_config.yml
  3. Copy the Host and Port into config/log_config.yml

Setup Xero

  1. Create a demo company via the xero interface Create demo account
  2. Goto the xero dev console Xero Dev - Applications
  3. Create a new private application
  4. Select the Demo Company as the target
  5. Generate keys - Leave password blank:
mkdir ~/xero_keys
cd ~/xero_keys
openssl genrsa -out privatekey.pem 1024
openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825
openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer
pbcopy < publickey.cer
  1. Paste in the public key into the xero new app form

Setup ENV vars

Add in the following env vars to the stack

  1. XERO_API_KEY=APP_KEY
  2. XERO_SECRET=APP_SECRET
  3. XERO_PRIVATE_KEY=rsa_private_key
  4. SPOILAGE_ACCOUNT_CODE=400
  5. COGS_ACCOUNT_CODE=500
  6. SALES_ACCOUNT_CODE=400
  7. REDIS_URL=redis://localhost
  8. REDIS_ADDRESS=redis
  9. AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY
  10. AWS_SECRET_ACCESS_KEY=SECRET
  11. AWS_REGION=us-east-1
  12. PDF_BUCKET=aws_bucket
  13. MAIL_GUN_DOMAIN=mg.yourdomain.com
  14. [email protected]
  15. ROUTIFIC_API_KEY=routific_api_key
  16. MAPBOX_API_TOKEN=mapbnox_api_key
  17. SLACK_CHANNEL_URL=https://hooks.slack.com/services/key
  18. DISTRIBUTION_SLACK_CHANNEL_URL=https://hooks.slack.com/services/key
  19. FIREBASE_URL=https://yourapp.firebaseio.com/
  20. GOOGLE_API_KEY=google_api_key
  21. [email protected]

Note The XERO_PRIVATE_KEY needs to be converted to a single line with newlines replaced with \n Example:

XERO_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQC7yxBqf5NnEFeyNkNIj+1EIFK4NDsOSITYkNh7kQSKbyUmHes1\nAE29ePg7+S8mYhMBfQy0U/2IGI9RDsQKsZLpEj0iiBpBLtl0N1sg90Nc+RjEAPaR\nA63bKVDi1fCstilaQbXN7dQeGEOg83Zh/5WzNtdJlC823iDoWwCWVhK63wIDAQAB\nAoGARZCKazkJDHO0WLLbJ8URGlxy6AOJINhiRasaVmO47+MOOpl2Xx9RrLPkvKtM\n+QX5jmKZUu+NsqhOZrN2kZOIHKS7lV/+6HkxCVhmkWFN1Y0oapaZ8Gggp7OJ2uwP\nv3eXeOzZnlqY/cwjDzntgyO5Gyek47rwh319q62VRxwJ/wECQQD5LRCRfQryrYgu\nVO2wjOeWX3bfHI8wk+8wjwQ7BSdROME2N+/opUuWUZ5pmjaowEYuSuEqdakkDIfU\n1EseYwFfAkEAwO+nYRrMIW9Jv7zWB0sHK3f01rQqL0uRudRkZoaMKRu+CzODOdHX\n3PMqgPlip9OypK/uDRL1teQ8zj+QDTs2gQJBALOmxSJQSFttuBjHjNPU04g8bhRU\nnvyEPFkDVCaFcbKCu/MuY1+WBahsU22LLUt/zVnFDRDC4l8mVayiH0LaWPsCQH2i\nkWgWPx71jruiJ+0P2ldgAbteDqpFl1tfBxIMQ3Dxc8tve+BG2T4zylW6D5ghro63\nUViKJB6RxVa45WD4UgECQFWqHSe84+hoNgel5gZw2nIF8kNvnT0mI6EQRTfXqFcG\nXlR1tb04Ega6LrgXD7W120NXPKK+R3GO2AxIi7vg9qU=\n-----END RSA PRIVATE KEY-----"

Install the in-spiritus-cli tool

The easiest way to get the project running is by using the CLI tool. This will manage starting and stopped, migrations, opening sessions to the correct containers and several other regular tasks

  1. npm install -g mlvk/in-spiritus-cli - Install the tool globally
  2. is serve - Run from the root of the project. Starts all the containers
  3. is --help

Read the cli docs for more info.

Manage the containers with docker-compose manually

If you have trouble using the CLI tool, you can manage the docker-compose manually with these commands.

Starting containers

  1. docker-compose -f docker/docker-compose-no-sync.yml up - To start just to base services (without workers)
  2. docker-compose -f docker/docker-compose.yml up - To start all services

Exec against running containers

  1. docker-compose -f docker/docker-compose.yml exec web rake db:reset - Run the first time you build the containers

Util Commands

  1. docker-compose -f docker/docker-compose.yml exec web rake db:migrate - To run migrations
  2. docker-compose -f docker/docker-compose.yml exec web rake erd - Generate Entity-Relationship Diagrams
  3. docker-compose -f docker/docker-compose.yml exec web rails c - Start a rails console
  4. docker-compose -f docker/docker-compose.yml exec web bash - Start a bash shell on the web container
  5. docker-compose -f docker/docker-compose.yml exec db psql -U postgres - Open a psql command line in the db container
  6. docker-compose -f docker/docker-compose.yml exec redis redis-cli - Start the redis-cli on the redis container

Misc

  1. Run docker-compose -f docker/docker-compose.yml exec rake secret for each slot where needed in the secrets file

Domain Model Diagram

alt tag

Building docker images

  1. Build a new base web container (When Gemfile changes): docker build -f docker/Dockerfile.app -t mlvk/in-spiritus:0.0.12 .
  2. Build a new base web container (When Gemfile changes): docker build -f docker/Dockerfile.python -t mlvk/in-spiritus-python:0.0.1 .

Publishing docker hub

  1. Push to dockerhub registry: docker push mlvk/in-spiritus:0.0.13
  2. Push to dockerhub registry: docker push mlvk/in-spiritus-python:0.0.2

Setup Atom for testing

  1. You can install the ruby-test Atom plugin
  2. For the setting in the mini test area use the following settings:
  3. Minitest command: run all tests: is zeus test
  4. Minitest command: run test file: is zeus test {relative_path}
  5. Minitest command: run current test: is zeus test {relative_path}:{line_number}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 72.0%
  • HTML 28.0%