# Social Network Services

Social network services in bringin backend project use grpc server to serve logic. The grpc protocol defined at **api/proto** folder. Social network services serve social network logic like ( create network invitation, withdraw invitation, accept invitation & reject invitation)**.**&#x20;

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

### Tech Stack

* Golang version 1.20
* Postgres version 14 as Primary Database
* Redis for publishing data

### Installation

* Make sure you have golang version 1.20
* Make sure you have postgres that support uuid, jsonb
* Make sure you have installed redis
* 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/FqxmAEwk0IPvEzaVE6tu" alt=""><figcaption></figcaption></figure>

Besides executing the commands above, you can execute the command below to migrate database. But before you execute migrate command, make sure you already set database environment in **.env** file

<pre class="language-go"><code class="lang-go"><strong>    go mod download // run this if dependency not downloaded
</strong>    go mod tidy // run this if dependency changed
    go run cmd/main.go -command=migrate:up // execute migration up will create tables
</code></pre>

There are 3 migrate commands :

* command `migrate:up` will create tables
* command `migrate:down` will drop tables
* command `migrate:both` will drop and then create tables

### 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/D07OqUvOTYM8Ap9ZkjPe" alt=""><figcaption></figcaption></figure>

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
```


---

# 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://nandas-organization.gitbook.io/bringin-technical-documentation/services/social-network-services.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.
