Skip to content

This is a public and modified 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.

License

AbdulDevHub/Opal-Labs-Backend

Repository files navigation

Opal Labs [Backend]

Introduction

This is a public copy of a private repository in which I am 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. NOTE: This repository is the backend section of the site, to view the frontend, go to this repository link.

Setup

.env

.env.example contains a template for your own setup. Make a copy of it with cp .env.example .env.

Compile Daemon Installation

Follow the instalation below to enable Hot-reload for development.

https://pkg.go.dev/github.com/githubnemo/compiledaemon

Postgres Setup

Local Installation

ElephantSQL

If you don't want to install and run a database locally, use ElephantSQL.

After setting up a Database in ElephantSQL, in your .env, change the following fields so that they match your ElephantSQL Instance:

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

  • Download and setup the latest stable release of Redis (https://redis.io/download)
  • Ensure that the server is running on localhost:6379 (this is the default and has been set in the .env.example template file)
  • Default password is "" (empty string), and the default database is 0. These are also set in the .env.example file.
  • If you have a different setup, change the REDIS_ADDR, REDIS_PASSWORD and REDIS_DB fields in your .env file to match your setup.

Hosted Redis

  • If you don't want to install and run a Redis server locally, you can use a hosted service such as RedisLabs.
  • Create an account at https://redislabs.com/, and create a new free database.
  • In the .env file, change the following fields so that they match your RedisLabs setup:
REDIS_ADDR="<Public Endpoint>"
REDIS_PASSWORD="<Default User Password>"
REDIS_DB=0
  • The information can be found in the Configuration tab under your specific database in the RedisLabs website.
  • If you have a different setup, change the REDIS_ADDR, REDIS_PASSWORD and REDIS_DB fields in your .env file to match your setup.

Redis Usage

  • The backend will run if the Redis server is not running, but the caching functionality will not work.
  • If you are using a local redis instance, the server can be started by running redis-server in the terminal, and you can stop it by running redis-cli shutdown.
  • If you are using a hosted redis instance, you can manage the cache through RedisInsight or a similar tool. Our suggestion is to use the redis-cli tool, which can be downloaded from the official Redis website or through a package manager such as apt or pacman. RedisLabs provides the command to connect to the database, which can be found by clicking on the Connect button in the RedisLabs' Databases dashboard.
  • These are some of the commands that you can use to manage the cache:
    • SET key value - Set a key-value pair in the cache
    • GET key - Get the value of a key
    • DEL key - Delete a key-value pair
    • FLUSHALL - Delete all key-value pairs in all databases

Google OAuth 2.0

Follow the instructions outlined in Setting up Google OAuth 2.0 (located in the team drive).

https://drive.google.com/drive/folders/1PWzpsJGXIDA_RnRRoEcJe_U5yvGC6s_U?usp=sharing

How to run

  • go build (install dependencies and build project)
  • go run . (run server)
  • CompileDaemon -command="./backend" (run with Hot-reload)

How to tests

Once the server is running open another terminal and change directories to tests and run "go test -v" to run all tests functions, or you can run "go test -run 'test_function_name'" to run individual test functions.

How to tests backend Server hosted in cloud

Send requests as usual except 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! If you have suggestions for improvements, please open an issue.

License

This project is licensed under the MIT License. See the LICENSE file for details.


About

This is a public and modified 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

No packages published

Languages