# Setting things up

## Setting up the .env file

Make a copy of the `.env.example` file and rename it to `.env`

```bash
cp .env.example .env
```

Fill in the values for the environment variables in the `.env` file. You can find the values for the variables in the [Environment Variables](/contributing-to-keyshade/environment-variables.md) section.

## Installing Docker

We tend to use docker for doing the heavy lifting on our behalf. Currently, we use it to set up the integration test environment before you make a commit. To make sure your experience is smooth, consider installing docker from <https://docs.docker.com/engine/install/>

## Node Version

Keyshade works with any active Long-Term Support (LTS) version of Node.js. You can download the current LTS version from the [official Node.js website](https://nodejs.org/en/download).

## Setting up `pnpm`

The project uses `pnpm` as the package manager. To install `pnpm`, run the following command:

```bash
npm install -g pnpm
```

{% hint style="info" %}
For Linux users, in case the above command fails with permission error, try running this:

```bash
sudo npm install -g pnpm
```

{% endhint %}

## Installing the dependencies

To install the dependencies, run the following command:

```bash
pnpm install
```

## Building all the required packages

To make sure all the things work fine, build all these packages by running the following commands:

* Build the secret-scan package:

```bash
pnpm build:secret-scan
```

* Build the schema:

```bash
pnpm build:schema
```

* Build the api-client:

```bash
pnpm build:api-client
```

Or, want to save your precious time? Run all three commands in one go by running this command:

```bash
pnpm build:packages
```

## Installing Turbo

The final step involves installing our monorepo management tool. We have transitioned to using Turbo to streamline our development process. To install Turbo, run the following command:

```bash
npm install turbo --global
```

For more information on how to get started with Turbo, refer to the [official Turbo documentation](https://turbo.build/repo/docs).

## Installing nest CLI

If you plan to work on the API, you would need the **NestJS CLI.** To do this, simply run:

```bash
npm install -g @nestjs/cli
```

## Setting up the development environment

We cluster every dependency that Keyshade will need into our `docker compose` file. So, in order to start developing, you will first need to fire up these dependencies using one single command:

```bash
docker compose up -d
```

This will start the following things in a dockerized environment and then expose the services to your host machine:

1. PostgreSQL: This is the database that Keyshade uses to store all the data.
2. Redis: This is the cache store that Keyshade uses to store the cache data.

Please note that, in order for these steps to work, you will need to ensure that the following ports are free:

* 5432
* 6379
* 9000
* 9001

### Issues regarding PostgreSQL

We have heard quite a few contributors facing a difficult time in getting PSQL to work. If you are facing issues with PostgreSQL, you can try the following:

* Ensure that you don't have a local version of PostgreSQL running on your machine.
* Make sure that you don't have any other docker containers running on the same port.

### Shutting things down

Once you have finished your development, it is recommended to shut down the docker infrastructure using:

```bash
docker compose down
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keyshade.io/contributing-to-keyshade/setting-things-up.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
