> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rmitnct.club/llms.txt
> Use this file to discover all available pages before exploring further.

# Development

> Learn how to preview changes locally.

<Info>
  **Prerequisite**: You should have installed [Node.js](https://nodejs.org)
  (version 20 or higher).
</Info>

## Installation

Step 1. Install [bun](https://bun.sh/docs/installation) on your machine (if you don't already have it yet), by running the following command:

**macOS/Linux:**

```bash theme={null}
curl -fsSL https://bun.sh/install | bash
```

**Windows:**

```bash theme={null}
powershell -c "irm bun.sh/install.ps1 | iex"
```

## Why Bun?

We chose bun as our runtime and package manager based on its [design goals](https://bun.sh/docs#design-goals), which align perfectly with our platform's needs:

* **4x Faster Startup**: Bun processes start significantly faster than Node.js, improving development experience and CI/CD performance
* **Built-in TypeScript & JSX Support**: No need for additional transpilation setup - bun natively executes `.ts`, `.tsx`, and `.jsx` files
* **All-in-One Toolkit**: Combines runtime, package manager, bundler, test runner, and script runner in a single executable
* **Web Standards Compatibility**: Implements modern Web APIs like `fetch`, `WebSocket`, and `ReadableStream` out of the box
* **Node.js Compatibility**: Drop-in replacement for Node.js with full compatibility for existing projects
* **Better Performance**: Powered by JavaScriptCore engine with reduced memory usage and faster execution

These benefits make bun an ideal choice for our monorepo architecture and development workflow.

Step 2. **Configure Tiptap Pro Registry:**

<Warning>This step is no longer needed.</Warning>

Step 3. After configuring Tiptap Pro registry, you can install all dependencies by running the following command:

<CodeGroup>
  ```bash standard theme={null}
  bun install
  ```

  ```bash short-hand theme={null}
  bun i
  ```
</CodeGroup>

To complete the initial setup, please restart your IDE so that it can recognize the newly installed dependencies. Additionally, some recommended VS Code Extensions may only work after restarting your IDE.

<Tip>
  If you're using VS Code, you can install following the recommended extensions
  that will help you with the development process:
  [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint),
  [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode),
  [Vitest](https://marketplace.visualstudio.com/items?itemName=vitest.explorer),
  [Tailwind CSS
  IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss),
  [Version
  Lens](https://marketplace.visualstudio.com/items?itemName=pflannery.vscode-versionlens),
  [Error
  Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens),
  [Pretty TypeScript
  Errors](https://marketplace.visualstudio.com/items?itemName=YoavBls.pretty-ts-errors),
  [Material Icon
  Theme](https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme).
</Tip>

## Development

### Start Next.js apps

To develop all apps and packages (without requiring a local setup), run the following command:

```bash bun theme={null}
bun dev
```

<Info>
  This command will start all Next.js apps in development mode. You can access
  the apps by visiting the following URL: [http://localhost:7803](http://localhost:7803)
</Info>

### Start Local Supabase Instance

To start a local supabase instance (database), run the following command:

```bash bun theme={null}
bun sb:start
```

<Info>
  This command will start a local supabase instance on your machine. You can
  access the supabase instance by visiting the following URL:
  [http://localhost:8003](http://localhost:8003)
</Info>

<Warning>
  You need to have Docker installed and running on your machine to start a local
  supabase instance.
</Warning>

### Stop Local Supabase Instance

To stop the local supabase instance, run the following command:

<CodeGroup>
  ```bash standard theme={null}
  bun sb:stop
  ```

  ```bash short-hand theme={null}
  bun stop
  ```
</CodeGroup>

### Better Development Experience

In case you want to run all local development servers, run the following command:

```bash bun theme={null}
bun devx
```

<Info>
  Running `devx` will:

  1. Stop the currently running supabase instance and save current data as backup (if there is any)
  2. Install all dependencies
  3. Start a new supabase instance (using backed up data)
  4. Start all Next.js apps in development mode

  If you want to have the same procedure without the backup, you can run `bun devrs` instead. This will:

  1. Stop the currently running supabase instance (if there is any)
  2. Install all dependencies
  3. Start a new supabase instance (with clean data from seed.sql)
  4. Start all Next.js apps in development mode
</Info>

<Tip>
  In case you don't want to run a local supabase instance, you can run `bun dev`
  instead.
</Tip>

### Local development

#### Seed accounts

There are 5 seed accounts that are already set up for local development:

1. [local@tuturuuu.com](mailto:local@tuturuuu.com)
2. [user1@tuturuuu.com](mailto:user1@tuturuuu.com)
3. [user2@tuturuuu.com](mailto:user2@tuturuuu.com)
4. [user3@tuturuuu.com](mailto:user3@tuturuuu.com)
5. [user4@tuturuuu.com](mailto:user4@tuturuuu.com)

You can use any of these accounts to log in to the app and quickly test the functionality of the app, since they are already set up with the necessary data.

#### Authentication

A local mail server (**InBucket**) is automatically set up by Supabase to handle authentication emails.

<Info>
  You can access the mail server by visiting the following URL:
  [http://localhost:8004](http://localhost:8004)
</Info>

## Build

To build all apps and packages, run the following command:

```bash bun theme={null}
bun run build
```

## Test

To run all tests, run the following command:

```bash bun theme={null}
bun run test
```

<Warning>
  Tests are still a work in progress. We're currently working on adding tests to all packages to ensure the best quality possible.
</Warning>

## Git Conventions

NCTHub uses standardized conventions for Git commits and branch naming. For more information, see the [Git Conventions](/git-conventions) guide to learn how to format your commits and branch names to align with our workflow.
