Coder Social home page Coder Social logo

2goodreads's Introduction

2goodreads

book listing and reviews

Tech Stack

uses prisma, mysql, express on the server and react, react-router, redux-toolkit, sass on client

API Specs

Get All Books

  • Endpoint: GET /books
  • Description: Get a list of all books with average ratings.
  • Response:
    • Status: 200 OK
    • Body: An array of book objects, each containing book details and average rating.

Get Book by ID

  • Endpoint: GET /books/:id
  • Description: Get detailed information about a specific book including its average rating.
  • Parameters:
    • id (number): The ID of the book to retrieve.
  • Response:
    • Status: 200 OK
    • Body: Book details including average rating.

Create Rating for a Book

  • Endpoint: POST /ratings
  • Description: Create a new rating and review for a book.
  • Request Body:
    • review (string): The review text.
    • rating (number): The rating value (1-5).
    • bookId (number): The ID of the book being rated.
  • Response:
    • Status: 201 Created
    • Body: The rating object.

DB schema

Table Rating {
  id        UUID        [primary key]
  createdAt DateTime   [default: `now()`, not null]
  updatedAt DateTime   [not null]
  review    Text
  rating    Int
  bookId    UUID
  foreign key (bookId) references Book(id)
}

Table Book {
  id          UUID        [primary key]
  createdAt   DateTime   [default: `now()`, not null]
  updatedAt   DateTime   [not null]
  name        Text
  author      Text
  description Text
  price       Int
  img         Text?
}

Ref: Rating.bookId > Book.id

Getting Started

Clone the repo

git clone https://github.com/33j33/2goodreads.git

Server

  1. cd ./server
  2. npm install
  3. create a mysql database. usage of any other other can be configured in schema.prisma.
  4. create an .env file at root of server directory.
  5. specify db url in MYSQL_URL in format mysql://${USER}:${PASSWORD}@${HOST}:${PORT}/${DB}
  6. specify dev server port, eg PORT=3000
  7. run npx prisma generate to create prisma client for you, using the schema.
  8. run npx prisma migrate dev to run migrations.
  9. run npx prisma db seed to seed db using books defined in prisma/seed.ts
  10. run npx run dev to start dev server

Client

  1. cd ./client
  2. npm install
  3. create an .env file and specify backend server url in REACT_APP_API_URL
  4. run npm run start

2goodreads's People

Contributors

33j33 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.