> For the complete documentation index, see [llms.txt](https://nandas-organization.gitbook.io/bringin-technical-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nandas-organization.gitbook.io/bringin-technical-documentation/services/auth-services.md).

# Auth Services

Auth services in bringin backend project. Used grpc server to serve authentication logic. The grpc protocol defined at **api/proto** folder.

<figure><img src="/files/zDhbRv9nY7CKaoawWBnF" alt=""><figcaption><p>Auth Folder Structure</p></figcaption></figure>

### Tech Stack

* Golang version 1.20
* Postgres version 14 as Primary Database
* Redis for caching auth user

### Installation

* Make sure you have golang version 1.20
* Make sure you have postgres that support uuid, jsonb
* Make sure you have installed redis
* Make sure you have cores sdk
* See Recommmended project structure section.

### Migrate Database

Make sure you already create database and integrate with uuid extension. Look at [this](https://dba.stackexchange.com/questions/153017/how-do-i-install-enable-the-uuid-ossp-extension-on-postgres-9-3) to create uuid extension. Look at folder **internal/sqls** you can execute sql in that folder to migrate database.

<figure><img src="/files/S5vLobDm4AfoRNg1FhwA" alt=""><figcaption><p>Sql Commands</p></figcaption></figure>

### Run Services

First to run this services, make sure your database and the tables that needed already created. Then create **.env** file from **example.env** template. The **example.env** file look likes below change the configuration and match with your environment.

<figure><img src="/files/f6GAEnGNQUQr7Z8ejrhi" alt=""><figcaption></figcaption></figure>

Note for **SECRET\_AES\_FRONT\_PASSWORD, IV\_AES\_FRONT\_PASSWORD, SECRET\_AES\_BACK\_PASSWORD** and **IV\_AES\_BACK\_PASSWORD** value length must be 16 character.

After **.env** file created. Run this command

```go
    go mod download // run this if dependency not downloaded
    go mod tidy // run this if dependency changed
    go run cmd/main.go -command=main
```
