This monorepo contains the applications and services that constitute the Rhizone Learning Management System.
You can clone the repository via HTTPS as normal, but if you plan to contribute code to this repository in the future, you may want to consider installing and configuring the GitHub CLI tool to clone the repository after logging in. This helps address authentication errors when pushing commits to your working branch in the repository.
- Install the GitHub CLI from its website, following the instructions for your operating system / platform.
- In your terminal, run the command
gh auth login
. Choose the following options:- What account do you want to log into?
GitHub.com
- What is your preferred protocol for Git operations?
SSH
- Generate a new SSH key to add to your GitHub account?
Y
- Enter a passphrase for your new SSH key (Optional)
leave this blank, just press [ENTER]
- How would you like to authenticate GitHub CLI?
Login with a web browser
- What account do you want to log into?
- Copy the code that is given to you, then open the GitHub Device Login page in your web browser and log in to GitHub.
- Once logged in, press
[ENTER]
to complete the login process in the terminal. - Change directory to the folder you would like to store your repository
clone. Our recommendation would be
~/Developer
. - In your terminal, run the command:
gh repo clone OpenTree-Education/rhizone-lms
to clone the repository. - If you will be using Visual Studio Code to edit code for this project, you
can use the following command to open the repository in VSCode:
code rhizone-lms
Otherwise, open the repository in the editor or IDE of your choice.
The app uses GitHub as an auth provider. Each dev must create their own GitHub app to handle authentication.
- Log into GitHub.
- Go to Settings / Developer settings.
- Click "OAuth Apps", then click "New OAuth App" or "Register a new application".
- Enter the following data.
- Application name:
Rhizone LMS (Development)
- Homepage URL:
http://rhi.zone-development/
- Application description:
Rhizone LMS (Development)
- Authorization callback URL:
http://api.rhi.zone-development/auth/github/callback
- Application name:
- Click "Register application".
- Click "Generate a new client secret".
- In your terminal or code editor, make a copy of the
.env.example
file in the clone you made of the repository and name it.env
.- Paste the Client ID from GitHub as the value for
GITHUB_CLIENT_ID
. - Paste the Client Secret from GitHub as the value for
GITHUB_CLIENT_SECRET
.
- Paste the Client ID from GitHub as the value for
The development environment assumes that the domains rhi.zone-development
and
api.rhi.zone-development
resolve to your dev machine.
- Open your
hosts
file for editing. You may need to do this with administrator privileges. On macOS and Linux, the file is at/etc/hosts
. On Windows it is atC:\Windows\System32\drivers\etc\hosts
. - Add the following lines to resolve the development domain names to the loopback address.
127.0.0.1 rhi.zone-development
127.0.0.1 api.rhi.zone-development
The development environment uses Docker Compose to run all the required services at once.
- Install Docker Compose. For macOS and Windows users, Docker Compose comes with Docker Desktop.
- Run
docker compose up
to start the dev environment. - Once the containers have started, visit http://rhi.zone-development/ in your web browser to use the app.
- When finished developing, press
CTRL + C
to stop Docker Compose.
When accessing http://rhi.zone-development/ or http://api.rhi.zone-development/,
the Nginx configuration that Docker Compose uses first checks to see whether the
webapp or api are running on localhost
, respectively. If they are, the
requests are forwarded to localhost
, otherwise they're forwarded to their
Docker containers.
While working on the api, run yarn develop
from the ./api/
directory while
docker compose up
is also running.
While working on the webapp, run yarn develop
from the ./webapp/
directory
while docker compose up
is also running.
When working on tasks such as Nginx configuration or database migrations, or
after pulling changes to the webapp or api from GitHub, the images need to be
rebuilt before starting Docker Compose again. This can be done with either
docker compose build
or docker compose up --build
.
The /api
folder contains an Express.js server that
exposes an HTTP API that allows other applications to interact with the
database and third-party services like GitHub.
The /db
folder contains scripts and migrations for the database.
The /nginx
folder contains configuration files for Nginx for different
environments.
The /webapp
folder contains a React app that enables user functionality and
communicates with the api.
This project expects specific versions of Node and Yarn to be used. It is
recommended to install Node Version Manager and
call nvm use
from each project directory before running Node scripts.
nvm
offers additional tips in its documentation about
deeper shell integration
such as automatically calling nvm use
when using the cd
command.
docker compose
takes longer to type than dc
, so add an alias in your shell
to simplify running commands. For example, the following will add a line
aliasing dc
to docker compose
in the ~/.profile
file.
echo 'alias dc="docker compose"' >> ~/.profile
source ~/.profile
Then any docker compose
command would be able to be run with dc
. For
example, docker compose up
, would be simply dc up
.
Your operating system and IDE may create files and folders inside the project
directory. Since the project can't account for which operating systems and IDEs
its contributors use, these paths are not listed in the project's .gitignore
file.
To prevent these files from getting picked up by Git across your machine, create
a global .gitignore
file. Check out
this Gist for more
info.
ESLint and Prettier can automatically fix many mistakes that will cause
automated checks to fail. It is recommended to use the preconfigured
yarn delint
command before committing to a module that supports it.
For files that aren't reformatted by Prettier, configure your IDE to ensure there is a newline at the end of the file on save.