Skip Navigation
Tyrone Williams

OpenLib

Summary

OpenLib is a mock library site allowing users to digitally borrow books and resources. The site features admins pages to create and manage books, authors, book series, and other book details.

Objectives

The main objective with this project was getting familiar with using NextJS with Vercel (serverless) verse more typical VPS backends. I also decided to test using pre-built auth systems, in this case NextAuth, instead of rolling my own.

Technologies and Tools

Front-end

  • NextJS with using Apollo, React Query, and local state for state management.
  • Cypress for E2E testing.
  • Typescript for static typing javascript.
  • Prisma for ORM with postgreSQL as the database.
  • Redis for managing the caching search request as well as commonly used query like most viewed genres, highest rated books, and popular books.

Challenges

The main focus for this project was learning to uses tools/technology I was not used to from past projects. For this projects, there were three main differences:

NextJS

As my previous project were created with Create React App or Vite I decided to use NextJS along with vercel. While non-serverless setups made sense for previous project, due to the need of WebSockets, this project did not have that limitation and the combination of NextJS & Vercel provides an overall better development experience.

Authentication

Any project that I have needed an auth system I've normally create my own system, but for this project I decided to check out the pre built options for NextJS. I used NextAuth for this project and while this provides an really easy setup for getting auth up and running quick, it did have some issues. The biggests issues currently is trying to get it to work for the new app router for NextJS which is the only reason I haven't moved over from the page router yet. They are currently working on moving the library (might have happened already) so I'll probably be leaving this project in pages router until then.

Database

There's many options when it comes to database and orm solutions for Node, and for many projects I was using Mongo to gain more experience with it. The data for this project was mostly centered around relationships between some actor and books, so I decided to move back to SQL with Postgres using Prisma. Prisma with typscript made developing the backend much easier and the type safty it gives you confidence for avoiding simple mistakes. I did consider a newer project at the timer Drizzle, however I believe at the time it only supported MySQL so I decided against it wanting to stick with Postgres. While the experience was overall great with Prisma, I did have some issue with joining tables and in one instance just decided to use raw SQL as I couldn't exactly figure out what was going wrong.