This contribution guide is for cases in which you need to test the functionality of your changes, or if you need to take screenshots of your changes. You will need a computer with a stable internet connection, a text editor, Git, and NodeJS with version 18.17.1. There are some additional requirements depending on what you're looking to contribute, such as Firebase for authentication, Mongo and Docker for the backend. Read the below sections to understand how to set up each of these tools.
IMPORTANT: If you are on Windows, run git config --global core.autocrlf false
before cloning this repo to prevent CRLF errors.
Git is optional but we recommend you utilize it. Monkeytype uses the Git source control management (SCM) system for its version control. Assuming you don't have experience typing commands in the command line, we suggest installing Sourcetree. You will be able to utilize the power of Git without needing to remember any cryptic commands. Using a Git client such as Sourcetree won't give you access to the full functionality of Git, but provides an easy to understand graphical user interface (GUI). Once you have downloaded Sourcetree, run the installer. While installing Sourcetree, keep your eyes peeled for the option to also install Git with Sourcetree. This is the option you will need to look for in order to install Git. Make sure to click yes in the installer to install Git with Sourcetree.
Currently, the project is using version 18.17.1 LTS
.
If you use nvm
(if you use Windows, use nvm-windows) then you can run nvm install
and nvm use
(you might need to specify the exact version eg: nvm install 18.17.1
then nvm use 18.17.1
) to use the version of Node.js in the .nvmrc
file.
Alternatively, you can navigate to the NodeJS website to download it from there.
You can use docker to run the frontend and backend. This will take care of OS specific problems, but might be a bit more resource intensive. You can download it from the Docker website.
The account system will not let you create an account without a Firebase project. You can skip this if you don't think you will need it (you can always set it up later)
-
Create a Firebase account if you already haven't done so.
-
Create a new Firebase project.
- The project name doesn't matter, but the name
monkeytype
would be preferred. - Google Analytics is not necessary.
- The project name doesn't matter, but the name
-
Enable Firebase Authentication
- In the Firebase console, go to
Authentication > Sign-in method
- Click on
Email/Password
, enable it, and save - Click on
Google
, add a support email and save
- In the Firebase console, go to
-
Generate a Firebase Admin private key (optional, only needed if you want to work on the backend)
- In your Firebase console, go to Project Settings > Service Accounts
- Click "Generate New Private Key"
- Save as
serviceAccountKey.json
inside thebackend/src/credentials/
directory.
-
Run
npm install -g firebase-tools
to install the Firebase Command Line Interface. -
Run
firebase login
on your terminal to log in to the same google account you just used to create the project. -
Within the
frontend
directory, duplicate.firebaserc_example
, rename the new file to.firebaserc
and change the project name to the firebase project id you just created.- Run
firebase projects:list
to find your firebase project id. - If
.firebaserc_example
does not exist after cloning, create your own with:
{ "projects": { "default": "your-firebase-project-id" } }
- Run
Within the frontend/src/ts/constants
directory, duplicate firebase-config-example.ts
, rename it to firebase-config.ts
- If you skipped the Firebase step, you can leave the fields blank
- Otherwise:
- Navigate to
Project Settings > General > Your apps
- If there are no apps in your project, create a new web app
- In the
SDK setup and configuration
section, selectnpm
- The Firebase config will be visible below
- Paste the config into
firebase-config.ts
- Navigate to
If you want to access the frontend from other machines on your network create a file frontend/.env
with this content:
BACKEND_URL="http://<Your IP>:5005"
Follow these steps if you want to work on anything involving the database/account system. Otherwise, you can skip this section.
-
Inside the backend folder, copy
example.env
to.env
in the same directory. -
Setup the database server
Local Server | Docker (recommended) |
---|---|
|
|
- (Optional) Install MongoDB-compass. This tool can be used to see and manipulate your database visually.
- To connect, type
mongodb://localhost:27017
in the connection string box and press connect. The Monkeytype database will be created and shown after the server is started.
- To connect, type
- Run
npm run install-all
in the project root to install all dependencies.- If you are on Windows, use
npm run install-windows
. - If neither works, you will have to run
npm install
in root, frontend, and backend directories. Now you are ready to build and run Monkeytype.
- If you are on Windows, use
- Frontend:
cd frontend && docker compose up
- Backend (in another terminal window):
cd backend && docker compose up
- Frontend and backend
npm run dev
- Only frontend (if you skipped the Backend section):
npm run dev-fe
These commands will start a local dev server on port 3000. It will watch for changes and rebuild when you edit files in src/
or public/
directories. Use Ctrl+C to stop it.
Note: Rebuilding doesn't happen instantaneously and depends on your machine, so be patient for changes to appear.
Code style is enforced by Prettier, which automatically runs every time you make a commit.
For guidelines on commit messages, adding themes, languages or quotes, pleases refer to CONTRIBUTING.md. Following these guidelines will increase the chances of getting your change accepted.
If you have any questions, comments, concerns, or problems let me know on GitHub, Discord in the #development
channel, or ask a question on Monkeytype's GitHub discussions and a contributor will be happy to assist you.