> For the complete documentation index, see [llms.txt](https://smu-portal.gitbook.io/get-started/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smu-portal.gitbook.io/get-started/backend/environment-variables.md).

# Environment Variables

### Introduction

Environment variables allow us to define some configuration that is decoupled from the code-base. It makes the application deployment easier in different environments (e.g. Heroku). Information that varies (hence the term *variables*) depending on the environment should be included in this file. Also, sensitive information like API tokens or database URLs should not be in this source code or known by unauthorized entities.

### Environment Variables in Node.js

Node.js provides a global variable called `process.env` which is an [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects) that contains all environment variables accessible to the developer. These environment variables are stored in a file called `.env` and, by convention, they are defined in a capitalized snake case, e.g `DB_URL`.

If you check the repository, you will find a file called, `.env.example` that contains variables used by the backend application.

### Connection to the Database

First, fork the repository and clone it on your machine (if you face some issues during this step, you can refer back to the *GitHub Guide*).

To allow the backend to connect to your database, create a `.env` file that is an exact copy of `.env.example` and modify it as follows:

```bash
# DB #
DB_URL = <CONNECTION-STRING-FROM-THE-PREVIOUS-SECTION>
```

Note that changes in the `.env` are ignored by *git* and that is why we provide the `.env.example` file to serve as a skeleton or a specification for the variables. As a matter of fact the `.env` file should not be pushed.
