> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/monkeytypegame/monkeytype/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> Set up your local development environment to contribute code to Monkeytype

This guide will help you set up a local development environment for Monkeytype. Follow these steps if you need to test functionality changes, take screenshots, or work on features that require the full application stack.

<Note>
  If you only want to add languages, quotes, or themes without running the application locally, check out the [Basic Contributions](/contributing/basic-contributions) guide instead.
</Note>

## Prerequisites

Before you begin, ensure you have:

* A computer with a stable internet connection
* A text editor or IDE
* Basic familiarity with Git and command line tools
* Node.js version 24.11.0 LTS

### Git Setup

<Warning>
  **Windows users**: Run `git config --global core.autocrlf false` before cloning the repository to prevent CRLF errors.
</Warning>

Git is optional but highly recommended for contributing to Monkeytype. If you're not comfortable with command-line Git, consider using [Sourcetree](https://www.sourcetreeapp.com/), which provides a graphical interface.

When installing Sourcetree, make sure to select the option to install Git alongside it.

### Node.js and PNPM

Monkeytype currently uses Node.js version `24.11.0 LTS`.

**Using nvm (recommended)**:

```bash theme={null}
nvm install 24.11.0
nvm use 24.11.0
```

<Note>
  Windows users should use [nvm-windows](https://github.com/coreybutler/nvm-windows).
</Note>

**Alternative**: Download directly from the [Node.js website](https://nodejs.org/en/).

**Install pnpm**:

Monkeytype uses `pnpm` for package management instead of `npm` or `yarn`:

```bash theme={null}
npm i -g pnpm@10.28.1
```

## Installation

<Steps>
  <Step title="Fork the Repository">
    Go to the [Monkeytype repository](https://github.com/monkeytypegame/monkeytype/) and click the "Fork" button in the top-right corner to create your own copy.
  </Step>

  <Step title="Clone Your Fork">
    Clone your forked repository to your local machine:

    ```bash theme={null}
    git clone https://github.com/YOUR_USERNAME/monkeytype.git
    cd monkeytype
    ```
  </Step>

  <Step title="Install Dependencies">
    Install all project dependencies:

    ```bash theme={null}
    pnpm i
    ```
  </Step>

  <Step title="Configure Firebase (Optional)">
    Skip this step if you won't be working with the account system. You can always set it up later.

    1. Create a [Firebase project](https://console.firebase.google.com/u/0/)
    2. Enable Firebase Authentication:
       * Go to `Build > Authentication > Sign-in method`
       * Enable `Email/Password` and `Google` sign-in
    3. Install Firebase CLI:
       ```bash theme={null}
       pnpm add -g firebase-tools
       firebase login
       ```
    4. Configure Firebase in the frontend:
       * Duplicate `frontend/src/ts/constants/firebase-config-example.ts`
       * Rename to `firebase-config.ts`
       * Add your Firebase config from Project Settings > General > Your apps
    5. Set up `.firebaserc`:
       * Duplicate `frontend/.firebaserc_example` to `.firebaserc`
       * Update the project ID:
       ```json theme={null}
       {
         "projects": {
           "default": "your-firebase-project-id"
         }
       }
       ```
  </Step>

  <Step title="Set Up Databases (Optional)">
    Only required if you're working on the backend or account system.

    1. Copy `backend/example.env` to `backend/.env`
    2. Set up the database server:

    **Option 1: Docker (Recommended)**

    Install [Docker](http://www.docker.io/gettingstarted/#h_installation) and run:

    ```bash theme={null}
    npm run docker-db-only
    ```

    **Option 2: Manual Installation**

    * Install [MongoDB Community Edition](https://docs.mongodb.com/manual/administration/install-community/)
    * Install [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/)
    * Ensure both services are running

    3. (Optional) Install [MongoDB Compass](https://www.mongodb.com/try/download/compass) for visual database management
       * Connect using: `mongodb://localhost:27017`
  </Step>
</Steps>

## Running Monkeytype Locally

You can run Monkeytype manually or with Docker.

### Running Both Frontend and Backend

```bash theme={null}
npm run dev
```

This starts:

* Frontend development server on [http://localhost:3000](http://localhost:3000)
* Backend development server on [http://localhost:5005](http://localhost:5005)

### Running Frontend Only

**Manual**:

```bash theme={null}
npm run dev-fe
```

**Docker**:

```bash theme={null}
cd frontend && npm run docker
```

### Running Backend Only

**Manual**:

```bash theme={null}
npm run dev-be
```

**Docker**:

```bash theme={null}
cd backend && npm run docker
```

<Note>
  The development server automatically rebuilds when you make changes in the `src/` directory. Rebuilding may take a moment depending on your machine.
</Note>

Use <kbd>Ctrl+C</kbd> to stop the development servers.

## Network Access (Optional)

To access the frontend from other devices on your network, create `frontend/.env`:

```
BACKEND_URL="http://<Your IP>:5005"
```

## Other Useful Commands

### Linting and Formatting

```bash theme={null}
# Lint all code
npm run lint

# Lint with auto-fix
npm run lint-fix

# Format check
npm run format-check

# Format fix
npm run format-fix
```

### Testing

```bash theme={null}
# Run all tests
npm run test

# Test frontend only
npm run test-fe

# Test backend only
npm run test-be
```

### Building

```bash theme={null}
# Build all
npm run build

# Build frontend only
npm run build-fe

# Build backend only
npm run build-be
```

## Code Quality

Monkeytype uses [Oxc (Oxfmt and Oxlint)](https://github.com/oxc-project/oxc) for code formatting and linting. These tools run automatically when you make a commit via Git hooks.

## Next Steps

* Review the [Guidelines](/contributing/guidelines) for contribution standards
* Learn about [Basic Contributions](/contributing/basic-contributions) for adding languages, quotes, and themes
* Explore [Advanced Contributions](/contributing/advanced-contributions) for code changes

## Getting Help

If you have questions or run into issues:

* Ask in the `#development` channel on [Discord](https://discord.gg/monkeytype)
* Open a discussion on [GitHub Discussions](https://github.com/monkeytypegame/monkeytype/discussions)
* Contact the maintainers on [GitHub](https://github.com/Miodec)
