/betterreads

Cassandra demo app - BetterReads

Primary LanguageJava

betterreads

Cassandra demo app - BetterReads (Similar to GoodReads). Data is first loaded into datastax Cassandra cluster using this app

Design Doc

Cassandra Docs

GitHub User authentication setup

Follow this video and this (or this) github repositories to build oauth2Login using github.

  1. Create a GitHub App and get the Client ID and Client Secret values. (Specify callback URL as http://localhost:8080/login/oauth2/code/github for development, uncheck Web hooks)
  2. Add those values in application.yml
  3. Run the Spring Boot App.

Creating books data in Cassandra cluster:

Cassandra console after data creation: image

Checkout the Book.java Class for book_by_id table which facilitates this feature.

Book detail:

We get book by id from Cassandra book_by_id table and display it to UI image

Book search:

We make call to https://openlibrary.org/search.json?q={query} api to get search result. We can't perform search in Cassandra as that would be very slow. Ideally we should have used an Apache Lucene based text search engine (such as elastic-search or solr). We should have build an index in elastic-search from Cassandra (or Kafka depending on how we design it) and then we should have performed the search query on elastic-search. However, since the scope of this app was to learn how to use Cassandra db, we are leveraging openlibrary's available search API - https://openlibrary.org/dev/docs/api/search. image

Tracking user interactions with books:

Cassandra console: For every user interaction with a new book, a new row will be added in this table

  1. user njha-collab adds info for book OL10005006W
  2. user njha-collab updates info for book OL10005006W (same entry is updated)
  3. user njha-collab adds info for another book OL10009701W image

Checkout the BookInfoByUserIdAndBookId.java Class For book_by_userid_and_bookid table which facilitates this feature.

UI: image image

My books feature:

Displays top books that a user has interacted with on user's home page Cassandra console: image

Checkout the BookInfoByUserId.java Class For books_by_userid table which facilitates this feature.

UI: image

Reading materials: