# Local Environment Setup

{% hint style="info" %}
**Prerequisites**

Ensure the following tools are installed on your system:

1. **Node.js (version 20.11.0)**
   * If you have **nvm** configured, the correct Node.js version will automatically be used when you navigate to the `ui` or `api` directories (based on `.nvmrc` files).
   * Otherwise, install Node.js 20.11.0 from [Node.js downloads](https://nodejs.org/).
2. **Yarn**\
   Install Yarn globally:

   ```bash
   npm install -g yarn
   ```
3. **PostgreSQL**
   * Install PostgreSQL locally (e.g., via [PostgreSQL Downloads](https://www.postgresql.org/download/)) and create DB
   * Or follow [Database Setup](/intercode-saas-kit/getting-started/database-setup.md)
     {% endhint %}

### **Setup Steps**

1. **Install Dependencies**
   * Navigate to the `api` directory and run:

     ```bash
     yarn install
     ```
   * Navigate to the `ui` directory and run:

     ```bash
     yarn install
     ```

2. **Set Environment Variables**
   * For the `api`: Create a `.env` file and set:<br>

     ```gitignore
     # Email
     EMAIL_SENDER=             # Sender email (AWS SES or SendGrid)
     EMAIL_SERVICE=            # Email service ('aws' or 'sendGrid')

     # OAuth
     FACEBOOK_APP_ID=          # Facebook App ID
     FACEBOOK_APP_SECRET=      # Facebook App Secret
     GOOGLE_CLIENT_ID=         # Google Client ID
     GOOGLE_CLIENT_SECRET=     # Google Client Secret

     # Password Reset
     RESTORE_PASSWORD_SECRET=  # Secret for password reset tokens

     # Stripe
     STRIPE_API_KEY=           # Stripe API Key
     STRIPE_WEBHOOK_SECRET=    # Stripe Webhook Secret

     # AWS S3 / MinIO
     AWS_S3_ACCESS_KEY=        # AWS S3 Access Key
     AWS_S3_SECRET_ACCESS_KEY= # AWS S3 Secret Key
     AWS_S3_REGION=            # AWS S3 Region
     AWS_S3_HOST=              # AWS S3 Custom Host (optional)

     # Two-Factor Authentication
     TWO_FACTOR_AUTH_APP_NAME= # App name for 2FA (e.g., Google Authenticator)

     # Environment
     NODE_ENVIRONMENT=         # Node environment ('development', 'production')

     # CAPTCHA
     CAPTCHA_SECRET_TOKEN=     # CAPTCHA Secret Token
     ```

   * For the `ui`: Create a `.env.development` file and set:

     <pre class="language-gitignore" data-full-width="true"><code class="lang-gitignore"># Base URLs
     REACT_APP_BASE_URL=http://localhost:3000         # Frontend base URL
     REACT_APP_API_BASE_URL=http://localhost:8000     # Backend API base URL

     # OAuth Config
     REACT_APP_GOOGLE_CLIENT_ID=                      # Google Client ID
     REACT_APP_FACEBOOK_CLIENT_ID=                    # Facebook Client ID

     # Stripe Config
     REACT_APP_STRIPE_PUBLIC_KEY=                     # Stripe public key

     # CAPTCHA
     REACT_APP_CAPTCHA_SECRET=                        # Google CAPTCHA secret
     </code></pre>

{% hint style="info" %}
**This is not the full list of environment variables.**\
For the complete list of supported environment variables, please refer to the constants file where all available envs are defined.

You can find the constants files in:

* **UI:** `ui/src/common/constants/constants.js`
* **API:** `api/src/constants.ts`
  {% endhint %}

3. **Run the Applications**

   * Start the backend server:

     ```bash
     cd api
     yarn start:dev
     ```
   * Start the frontend server:

     ```bash
     cd ui
     yarn start
     ```


---

# 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://intercode.gitbook.io/intercode-saas-kit/getting-started/local-environment-setup.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.
