An open API service indexing awesome lists of open source software.

https://github.com/abduldevhub/opal-labs-backend

This is a public and enhanced copy of a private repository in which I worked with a team of 7 people to create a Notion-like productivity website. The project is built using Next.js, TypeScript, Google OAuth, the Agile Model, PostgreSQL, Redis, Playwright, and Go.
https://github.com/abduldevhub/opal-labs-backend

elephantsql go postgresql postman redis render rest-api sql

Last synced: 3 months ago
JSON representation

This is a public and enhanced copy of a private repository in which I worked with a team of 7 people to create a Notion-like productivity website. The project is built using Next.js, TypeScript, Google OAuth, the Agile Model, PostgreSQL, Redis, Playwright, and Go.

Awesome Lists containing this project

README

          

# ๐Ÿง  Opal Labs โ€” Backend

Backend services powering the Opal Labs productivity platform.


[๐Ÿ–ฅ Frontend Repository](https://github.com/AbdulDevHub/Opal-Labs-Frontend)


![Go](https://img.shields.io/badge/Go-00ADD8?logo=go&logoColor=white)
![PostgreSQL](https://img.shields.io/badge/PostgreSQL-316192?logo=postgresql&logoColor=white)
![Redis](https://img.shields.io/badge/Redis-DC382D?logo=redis&logoColor=white)
![OAuth](https://img.shields.io/badge/Auth-Google%20OAuth-red)
![MIT License](https://img.shields.io/badge/License-MIT-green)

---

## โœจ Introduction

This is a **public copy of a private repository** where I collaborated with a **team of 7 developers** to build a Notion-like productivity platform.

This repository contains the **backend** services for the application.
For the frontend implementation, visit ๐Ÿ‘‰ **[Opal Labs Frontend](https://github.com/AbdulDevHub/Opal-Labs-Frontend)**

### ๐Ÿงฑ Backend Tech Stack

- **Language:** Go
- **Database:** PostgreSQL
- **Caching:** Redis
- **Authentication:** Google OAuth 2.0
- **Testing:** Go testing framework
- **Methodology:** Agile

---

## ๐Ÿ›  Setup

### ๐Ÿ” Environment Variables

The `.env.example` file contains a template for configuration.

```bash
cp .env.example .env
````

---

### ๐Ÿ” CompileDaemon (Hot Reload)

To enable hot-reload during development, install **CompileDaemon**:

๐Ÿ“ฆ [https://pkg.go.dev/github.com/githubnemo/compiledaemon](https://pkg.go.dev/github.com/githubnemo/compiledaemon)

---

## ๐Ÿ˜ PostgreSQL Setup

### Local Installation

1. Download PostgreSQL:
๐Ÿ‘‰ [https://www.enterprisedb.com/downloads/postgres-postgresql-downloads](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads)

2. During setup:

- Set password to: `password`
- Leave all other options as default

3. Open **pgAdmin4** and create a database named:

```text
Website
```

---

### โ˜๏ธ ElephantSQL (Hosted Option)

If you prefer not to run PostgreSQL locally:

1. Create an account:
๐Ÿ‘‰ [https://customer.elephantsql.com/login](https://customer.elephantsql.com/login)

2. Click **Create New Instance**

3. Select plan: **Tiny Turtle (Free)**

Update the following values in your `.env` file:

```bash
DB_USER=""
DB_PASSWORD=""
DB_NAME=""
DB_HOST=""
DB_PORT=5432
DB_SSL_MODE="disable"
```

---

## โšก Redis Setup

### Local Installation

1. Download Redis:
๐Ÿ‘‰ [https://redis.io/download](https://redis.io/download)

2. Ensure Redis is running on:

```text
localhost:6379
```

3. Defaults (already set in `.env.example`):

- Password: `""` (empty)
- Database: `0`

If your setup differs, update:

```env
REDIS_ADDR
REDIS_PASSWORD
REDIS_DB
```

---

### โ˜๏ธ Hosted Redis (RedisLabs)

1. Create an account:
๐Ÿ‘‰ [https://redislabs.com/](https://redislabs.com/)

2. Create a **free** Redis database

Update your `.env` file:

```bash
REDIS_ADDR=""
REDIS_PASSWORD=""
REDIS_DB=0
```

โ„น๏ธ These values can be found under the **Configuration** tab in RedisLabs.

---

### ๐Ÿ“ฆ Redis Usage Notes

- The backend will still run **without Redis**, but caching will be disabled.
- Start local Redis:

```bash
redis-server
```

- Stop Redis:

```bash
redis-cli shutdown
```

#### Common Redis Commands

- `SET key value`
- `GET key`
- `DEL key`
- `FLUSHALL`

---

## ๐Ÿ” Google OAuth 2.0

Follow the setup instructions provided in the team drive:

๐Ÿ‘‰ [https://drive.google.com/drive/folders/1PWzpsJGXIDA_RnRRoEcJe_U5yvGC6s_U?usp=sharing](https://drive.google.com/drive/folders/1PWzpsJGXIDA_RnRRoEcJe_U5yvGC6s_U?usp=sharing)

---

## ๐Ÿš€ Running the Server

```bash
go build
go run .
```

### Hot Reload Mode

```bash
CompileDaemon -command="./backend"
```

---

## ๐Ÿงช Running Tests

With the server running, open another terminal:

```bash
cd tests
go test -v
```

Run a specific test:

```bash
go test -run "test_function_name"
```

---

## โ˜๏ธ Testing Hosted Backend

Replace:

```text
localhost:8000
```

With:

```text
https://opal-labs-backend-muej.onrender.com
```

### Example

```text
https://opal-labs-backend-muej.onrender.com/page-get/123
```

---

## ๐Ÿค Contributing

Contributions are welcome!

- Open an issue for bugs or feature requests
- Submit a PR for improvements

---

## ๐Ÿ“„ License

This project is licensed under the **MIT License**.
See the [LICENSE](LICENSE) file for details.