Skip to content

akshatsh0610/Book_Review_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Book Review Backend API

A full-stack backend service built with TypeScript, Express.js, GraphQL, PostgreSQL, and Redis. This API allows users to manage a collection of books and their reviews. It implements caching with Redis and follows a modular, scalable architecture using TypeORM for database interaction.


🚀 Features

  • Add and fetch books with reviews using GraphQL
  • PostgreSQL database with TypeORM
  • Redis caching for optimized reads
  • Structured error handling and logging
  • Unit and integration testing with Jest
  • Flexible GraphQL schema with express-graphql
  • Type-safe, production-ready backend using TypeScript

🧰 Tech Stack

Layer Technology
Runtime Node.js, TypeScript
Framework Express.js
Database PostgreSQL with TypeORM
Caching Redis
API Layer GraphQL
Testing Jest
Dev Tools Docker, ts-node, nodemon

⚙️ Setup Instructions

✅ 1. Clone the Repository

git clone https://github.com/your-username/Book_Review_Backend.git
cd Book_Review_Backend

✅ 2. Install Dependencies

npm install

✅ 3. Create an .env file

DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=yourPassword
DB_NAME=book_review

✅ 4. Run PostgreSQL and Redis Using Docker

PostgreSQL

docker run --name book-review-db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=book_review -p 5432:5432 -d postgres

Redis

docker run --name book-review-redis -p 6379:6379 -d redis

Then run :

docker ps

✅ 5. Run Migrations

npm run typeorm -- migration:generate src/migrations/InitSchema --dataSource src/ormconfig.ts
npm run typeorm -- migration:run --dataSource src/ormconfig.ts

✅ 6. Start the Server

npm run dev

GraphQL playground will be available at:

http://localhost:4000/graphql

GraphQL Queries

1. Get all books

query {
  books {
    id
    title
    author
    reviews {
      id
      content
    }
  }
}

2. Add a book

mutation {
  addBook(title: "1984", author: "George Orwell") {
    id
    title
    author
  }
}

3. Add a review

mutation {
  addReview(bookId: 1, content: "Amazing read") {
    id
    content
    bookId
  }
}

4. Get reviews of a book

query {
  reviews(bookId: 1) {
    id
    content
  }
}

Running Tests

npm test

Author

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published