Skip to content

AbdulDevHub/Opal-Labs-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Opal Labs β€” Backend

Backend services powering the Opal Labs productivity platform.


πŸ–₯ Frontend Repository


Go PostgreSQL Redis OAuth MIT License


✨ 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

🧱 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.

cp .env.example .env

πŸ” CompileDaemon (Hot Reload)

To enable hot-reload during development, install CompileDaemon:

πŸ“¦ https://pkg.go.dev/github.com/githubnemo/compiledaemon


🐘 PostgreSQL Setup

Local Installation

  1. Download PostgreSQL: πŸ‘‰ 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:

    Website
    

☁️ ElephantSQL (Hosted Option)

If you prefer not to run PostgreSQL locally:

  1. Create an account: πŸ‘‰ https://customer.elephantsql.com/login

  2. Click Create New Instance

  3. Select plan: Tiny Turtle (Free)

Update the following values in your .env file:

DB_USER="<User & Default Database>"
DB_PASSWORD="<Password>"
DB_NAME="<User & Default Database>"
DB_HOST="<Server>"
DB_PORT=5432
DB_SSL_MODE="disable"

⚑ Redis Setup

Local Installation

  1. Download Redis: πŸ‘‰ https://redis.io/download

  2. Ensure Redis is running on:

    localhost:6379
    
  3. Defaults (already set in .env.example):

    • Password: "" (empty)
    • Database: 0

If your setup differs, update:

REDIS_ADDR
REDIS_PASSWORD
REDIS_DB

☁️ Hosted Redis (RedisLabs)

  1. Create an account: πŸ‘‰ https://redislabs.com/

  2. Create a free Redis database

Update your .env file:

REDIS_ADDR="<Public Endpoint>"
REDIS_PASSWORD="<Default User 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:

    redis-server
  • Stop Redis:

    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


πŸš€ Running the Server

go build
go run .

Hot Reload Mode

CompileDaemon -command="./backend"

πŸ§ͺ Running Tests

With the server running, open another terminal:

cd tests
go test -v

Run a specific test:

go test -run "test_function_name"

☁️ Testing Hosted Backend

Replace:

localhost:8000

With:

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

Example

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 file for details.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages