Rock Mountain
  • Home
  • User Guide
    • Glass Web Components
    • Using reCAPTCHA
    • Publishing Source Code with Syntax Highlighting
  • Developer Guide
    • Getting Started
    • Adding NPM Packages
    • Database
      • Backing Up and Restoring Data
      • Database Schema
      • MongoDB Tips and Snippets
      • VS Code and the MongoDB Playground
    • Common Errors and Their Solutions
    • Developing Glass Web Components
    • DevOps
      • Build and Deployment Procedure
      • GitHub Conventions and Workflow
      • Merging Preview Into Main
    • File Structure
    • React Components
      • SiteLayout Component
      • Toggle Lazy Load Image Component
    • Update or Change the Fav Icon
    • References and Learning Resources
  • Icons
Powered by GitBook
On this page
  • Get the Source Code
  • Launch VS Code
  • Checkout the Preview Branch or Create and Checkout a New Branch
  • Install Project Dependencies
  • Create the .env.local File
  • Obtain MongoDB Atlas Credentials
  1. Developer Guide

Getting Started

PreviousPublishing Source Code with Syntax HighlightingNextAdding NPM Packages

Last updated 3 years ago

Get the Source Code

Source code for the project can be found . Use one of the following commands to clone the repo to your local machine.

  • HTTPS: git clone https://github.com/codyburleson/rmtn.git

  • SSH: git clone git@github.com:codyburleson/rmtn.git

  • GitHub CLI: gh repo clone codyburleson/rmtn

Launch VS Code

We recommend development with (VS Code). From within the project directory, you can launch VS Code with the following command.

code .

On Windows, if you want to develop with the Windows Subsystem for Linux (WSL), you will need to install the WSL extension for VS Code. For more information, see .

After launching VS Code, select Terminal > New Terminal to show the terminal within the IDE. You'll need the terminal to install dependencies and to run the project in development mode, among other things.

Checkout the Preview Branch or Create and Checkout a New Branch

Our habit is to work in a branch other than the main branch and then merge into main once work is fully tested. You can create your own unique branch to work in, or you can at least checkout the preview branch and work with it. You can switch to the preview branch by running the following command.

git checkout preview

To create a new branch that is based on your currently checked out (HEAD) branch, simply use "git branch" with the name of the new branch as the only parameter. You can then "checkout" the branch to work within it.

git branch <new-branch>
git checkout <new-branch>

Install Project Dependencies

Next, run the following command to install package dependencies.

npm install
# or
yarn install

This installs all of the node packages that are defined in the ./package.json file, which is found in the root of the project.

Tip: With npm, you can also use the command, "npm i", which is shorthand for "npm install".

After running the command, you should see a node_modules folder in the root of the project. The node_modules folder is never committed to GitHub because it is specified to be ignored in the .gitignore file.

Create the .env.local File

In apps/rockmtn-platform, you will find a file called .env.local.example. This contains environment variables that need unique values. Copy the .env.local.example template and rename the copy to .env.local. You can use the following command to copy and rename the file.

cp .env.local.example .env.local

As you proceed with the Getting Started procedure, you'll be filling out values in this file. Environment variables that exist in this file for local development purposes must also be available as environment variables on any environment you deploy to. We'll soon go over how to do that for the main cloud server environment that we support, which is Vercel.

Because the .env.local file contains secrets like login credentials, it is included in the .gitignore file and will not be committed to the source code repository. Be sure to keep a secure backup of all the values needed for this file as you obtain them.

Obtain MongoDB Atlas Credentials

Rock Mountain uses Mongo DB Atlas for its NoSQL cloud database.

If you are working independently or with your own fork, you can sign up for your own MongoDB Atlas account and obtain your own credentials.

After signing up, you'll need to get the connection string that enables you to connect the application and use it in the .env.local file. Here's how.

Navigate to Databases > Deployment and, click the Connect button...

Next, click "Connect your application"...

Copy the connection string found under "2. Add your connection string into your application code"...

  • In the .env.local file, paste the connection string as the value for the MONGODB_URI variable.

  • Replace <username> and <password> with credentials for a user that has readWrite access to a database named "rmtnPreview". We recommend setting two administrative users for such access; one for the preview database (e.g. username: dev) and one for the main database, which will be created later (e.g. username: admin).

  • Replace the database name, "myFirstDatabase", in the URL connection string with the name, "rmtnPreview". We will later create a whole separate database for production called "rmtnMain," but don't worry about that for now.

  • Make sure the value for the MONGODB_DB environment variable is rmtnPreview.

The entries in .env.local should now look something like this:

MONGODB_URI=mongodb+srv://admin:msr5TLrtxqxcGefO@cluster0.cwrqa.mongodb.net/rmtnPreview?retryWrites=true&w=majority
MONGODB_DB=rmtnPrevie

This is all we need to get started with the database. When the system recognizes that it does not exist, the database will be created automagically.

Note: To see how we programmatically create database collections when they do not already exist, take a look in the file, ./lib/mongodb.js. Before we cache the connection in the global object, we call checkAndCreateAllMissingCollections(). For each collection that must exist the function calls checkAndCreateSingleMissingCollection().

If you are developing with the Rock Mountain team, you can obtain the MongoDB Atlas URL, database name, and login credentials for use in your own development environment. or another team member to obtain the information.

on GitHub
Visual Studio Code
Get started using Visual Studio Code with Windows Subsystem for Linux
Contact Cody Burleson