# Starting the Backend

If you have successfully completed the previous sections, your `.env` file should look like this:

{% code title=".env" %}

```bash
# APP #
SITE_NAME = SMUPortal
APP_SECRET = YgTP8SVHvLYWTn4E3aaM9tXPw8x-lInKCfFO10ZQWBo
REFRESH_TOKEN = 1UKfOmU5rlhan2wnkyjQGkK2sNaJCE-rPS-hOls5Wlk
TOKEN_EXPIRES_IN = 1h

# Email domain names should be seperated by a vertical bar (used in regex)
EMAIL_DOMAINS = medtech.tn|msb.tn|smu.tn

# DB #
DB_URL = <DB-CONNECTION-STRING>

# NodeMailer #
# SMTP_USER should contain an email not a username
SMTP_SERVICE = gmail
SMTP_USER = <EMAIL-ADDRESS>
SMTP_TYPE = OAuth2

# Google OAuth
G_CLIENT_ID = <CLIENT-ID>
G_CLIENT_SECRET = <CLIENT-SECRET>
G_ACCESS_TOKEN = <ACCESS-TOEKN>
G_REFRESH_TOKEN = <REFRESH-TOEKN>
G_REDIRECT_URI = https://developers.google.com/oauthplayground
```

{% endcode %}

{% hint style="warning" %}
Do not forget to replace all placeholders (e.g. \<CLIENT-ID>) with their correct values.
{% endhint %}

We are all set to start the backend code.

First, install the dependencies using `npm i` command.

```bash
~/smuportal-backend (master)
npm i
```

Once that is finished, you can start the server using `npm start` and you should get the following output

```bash
~/smuportal-backend (master)
npm start

> smuportal@0.0.0 start ~/smuportal-backend
> nodemon server.js

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Server is up
Connection to DB established!
```

If for some reason you got a different output, please make sure that you have correctly followed the instructions from previous sections or you can open an [issue](https://github.com/MedTech-CS321/smuportal-backend/issues).

That's it! The backend server is now running. If you are comfortable enough with backend technologies you can start developing, or you can browse the following sections where we go through a small example of a backend service.

Happy coding 🎉!
