Developer Quickstart
The purpose of this document is to provide detailed instructions to enable a new engineer to quickly get the various components up and running in a development environment.
Components
The Mustard web application consists of the following components:
Angular (v10) Frontend Application
Ruby on Rails (v5) API
Sidekiq Worker (background task processing queue)
Redis DB
Postgres DB
External Services
SES - Email delivery
Daxtra - CV parsing
Algolia - Candidate profile indexing & search
Bullhorn - Used to import/export candidates
Install and Run the Application
1. Download the code
The mustard app lives in a monorepo at https://github.com/mustard-app/mustard.
The top level structure of the code consists of the following:
.vscode/
- Visual Studio Code editor settingsapi/
- the rails appdeploy/
- deployment configurations and scriptsfrontend/
- the angular app.gitignore
- file to ignore sensitive or temporary files from being committed to version controldocker-compose.yaml
- configuration file for local development with docker
To download the code, open a bash terminal with git installed, and run
$> git clone git@github.com:mustard-app/mustard.git
Once you’ve downloaded the repository locally, you’ll need to create environment files which contain ENV variables for each of your key environments. (development, staging, production).
2. Create the Backend Environment Files
The backend environment files live in the “mustard/api” directory of the project. To create, run the following.
$> cd ./mustard/api
$> touch .env # local
$> touch staging.env # staging
$> touch production.env # production
3. Create the Frontend Environment Files
The frontend environment files live in the “mustard/frontend/src/environments” directory of the project. Due to the public nature of frontend code, any production config for the angular app will always be visible. This is why we already have the staging and production config files in this directory. To create the local environment file, run the following.
$> cd ./mustard/frontend/src/environments
$> cp sample-environment.ts environment.ts
4. Run with Docker
Firstly, regardless of OS, you’ll need to install Docker. You can find instructions on how to install for your OS here: https://www.docker.com/get-started
Navigate to the root directory of the repository, and run the following.
$> docker-compose run api rails db:create # database setup
$> docker-compose run api rails db:setup # database setup
$> docker-compose run api rails db:migrate # database setup
$> docker-compose run frontend yarn install # frontend dependency installation
$> docker-compose up # run the server
Once all of the above are run and completed, you should be able to view the application locally at http://localhost:3000/. The first compilation of the angular app will take approximately 1 minute, and will not be available until complete.
5. Run without Docker
For more fine grained control during development, you may want to run the application outside of docker. This is less consistent with staging and production environments, and may also be inconsistent with other developer’s local environments, so care must be taken when developing without docker. Below outlines how you would run each part of the application by hand on MacOS, installation in other environments is not outlined.
Install dependencies
Install imagemagick
$> brew install imagemagick
Install Redis
$> brew install redis
$> redis-cli
$> CONFIG SET requirepass "password"
This requires adding the redis_url to the environment “./mustard/api/.env” locally as `REDIS_URL=redis://password@localhost:6379/0`
$> brew services restart redis
Install Postgres
$> brew install postgres
$> /usr/local/opt/postgres/bin/createuser -s postgres
Install Frontend dependencies
$> brew install yarn
$> npm install -g @angular/cli
Install backend dependencies
$> brew install rbenv
$> bundle install
Setup the Database
Navigate to the API directory and run the following to setup the database schema
$> cd ./mustard/api
$> bundle exec rails db:create
$> bundle exec rails db:setup
$> bundle exec rails db:migrate
Run the components
Backend
$> cd ./mustard/api
$> bundle exec rails s
Background processing
$> cd ./mustard/api
$> bundle exec sidekiq
Frontend
$> cd ./mustard/frontend
$> ng serve --host=0.0.0.0 --port=3000 --disable-host-check
Common rails commands in docker
It is common during Ruby on Rails development to run certain commands to do things like migrate the database, run the rails console, view the currently configured routes or run rspec test suite.
Accessing the Rails Console
docker-compose run api rails c
Running migrations
docker-compose run api rails db:migrate
Listing current routes
docker-compose run api rails routes
Running the test suite
docker-compose run api rspec
Last updated
Was this helpful?