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.
.env.example
contains a template for your own setup. Make a copy of it with cp .env.example .env
.
Follow the instalation below to enable Hot-reload for development.
https://pkg.go.dev/github.com/githubnemo/compiledaemon
- Download and setup PostgresSQL (https://www.enterprisedb.com/downloads/postgres-postgresql-downloads)
- When setting up the account make password=password and go default for everything else.
- Then search for pgadmin4 from windows search bar and open pgadmin4 and create a new database called
Website
If you don't want to install and run a database locally, use ElephantSQL.
- Create an account https://customer.elephantsql.com/login
- Press
Create New Instance
- In the setup, ensure that Plan is set to Tiny Turtle (Free)
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"
- 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 is0
. These are also set in the.env.example
file. - If you have a different setup, change the
REDIS_ADDR
,REDIS_PASSWORD
andREDIS_DB
fields in your.env
file to match your setup.
- 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
andREDIS_DB
fields in your.env
file to match your setup.
- 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 runningredis-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 asapt
orpacman
. 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 cacheGET key
- Get the value of a keyDEL key
- Delete a key-value pairFLUSHALL
- Delete all key-value pairs in all databases
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
go build
(install dependencies and build project)go run .
(run server)CompileDaemon -command="./backend"
(run with Hot-reload)
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.
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"
Contributions are welcome! If you have suggestions for improvements, please open an issue.
This project is licensed under the MIT License. See the LICENSE file for details.