Skip to content

MyLibList, a project for ICT2103 Information Management. Built using Node.js, PostgreSQL, MongoDB, Next.js and Docker!

Notifications You must be signed in to change notification settings

rawsashimi1604/MyLibList

Repository files navigation

2103 Project MyLibList

This is our project for ICT2103 Information Management. It includes a REST API (Client-Server Architecture) using various GET, POST, PUT and DELETE routes. It also includes a Frontend Application using Next.js. The project is also Dockerized to be run in any environment.

StudentID GithubHandle Name
2101927 rawsashimi1604 Gavin Loo Wei Ren
2101391 jianweiiii Lim Jian Wei
2100701 irfaan96 Irfaan
2100614 junweilam Jun Wei
2100711 2100711 Lee Yong Chong
2100764 ZafrullaKamil Zafrulla

Technologies used

  • Docker
  • Node.js
  • Next.js
  • TailwindCSS
  • Prettier
  • REST API

Installing the project

  • You should have an .env file created in the server directory of this project. Details of .env file will be provided below.
  • Make sure you have Docker on your machine. Use the command docker ps to check. If not, install Docker Desktop.
  • Ensure you have Node.js on your machine. Use the command node -v to check. If not install Node.js.
  • Clone the github repo.
git clone https://github.com/rawsashimi1604/MyLibList.git
cd MyLibList
  • Start Docker Desktop / daemon
  • Open 2 terminals
  • Use py startBackend.py to start the backend on 1 terminal
  • Use py startFrontend.py to start the frontend on 1 terminal

Environment File Contents

Create .env file, put in server directory. .env file will therefore be in /MyLibList/server/.env

Contents:

BACKEND_PORT=8085
FRONTEND_PORT=3000

# Change this if you want to change database used
# DATABASE=POSTGRES
DATABASE=MONGO

MONGO_PORT=27017
MONGO_USER=root
MONGO_PASSWORD=rootpassword

POSTGRES_USER=postgres
POSTGRES_PASSWORD=password123
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_DB=defaultdb

FRONTEND_APP_URL_LOCAL=http://localhost:3000/

ACCESS_TOKEN_SECRET=ab160c0c2d797410e67f741a6c7710559a7818ff8a90e3300d723614b7dba322b5ce3e516df9e2065afd9f40439d637a09469e543e88326bc5e43af003611a10
REFRESH_TOKEN_SECRET=3b4afa89360cdd66701f1aa510ce2c5f691092eb14166a29483fc918e0cec2d2f85cf2f25144c9df87221a75d44013ee045639cf6385bf80170bb89c5ee20dfa

Generating your own access token and refresh token secrets

To generate these secrets, navigate to secret.js and run the file using node secret.js, a secret will be generated using the generateSecret() algorithm and you can put it into your .env environment variables.

Changing database instance between MONGO and POSTGRES

  • To change the database instance that is currently being run, simply change the DATABASE variable in the .env file to POSTGRES or MONGO. After, stop the docker containers and run a docker system prune to ensure all containers are stopped. Then rerun the app, and the application will restart using the specified database instance.

Running API Requests to the backend through Postman.

To manually test the Postman Collection, import the postman collection located at ./2103-Project.postman_collection.json

API Routes

Route Function
POST /api/user Register new user to the system.
GET /api/user?email= Get user data by email from system
PUT /api/user/changePassword Update user’s password
POST /api/user/likedBooks GET user’s liked books by sending email query
POST /api/user/readingLists GET user’s reading lists by sending email query
GET /api/readingList/:readingListID GET user’s reading lists by specific readingListID
GET /api/readingList/all GET all user’s reading list
POST /api/readingList CREATE user’s reading list
DELETE /api/readingList DELETE user’s reading list
POST /api/readingList/book CREATE new book in user’s reading list
DELETE /api/readingList/book DELETE book from user’s reading list
GET /api/book GET specific book
POST /api/book/like CREATE like for book
GET /api/book/topBooks GET top 20 books sorted by likes
POST /api/auth/login Logs user in, providing a JWT access and refresh token. Token is then stored in the user’s cache.
DELETE /api/auth/logout DELETE user’s JWT refresh token
POST /api/auth/token CREATE new refresh token

CI/CD flow

CD (Continuous Development)

  • Run py startBackend.py

  • Docker starts PSQLDB app

  • Docker starts MongoDB app

  • Docker seeds PSQL database using init.sql and database scripts found in the seedDB folder

  • Docker starts Node.js app

  • Application has successfully started with all predefined data

  • Run py startFrontend.py

  • Docker starts Next.js app

CI (Continuous Integration)

  • After adding some code
  • Use npm run beautify to achieve similar coding formatting standards
  • Add/pull to git repo using git commands
    • git add .
    • git commit -m ""
    • git push

About

MyLibList, a project for ICT2103 Information Management. Built using Node.js, PostgreSQL, MongoDB, Next.js and Docker!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages