Build a Goodreads Clone with Spring Boot and Astra DB — Part 1

Want to learn how to build a quick and simple Spring Boot application that is highly available, easily scalable, and can handle millions and millions of data records? This video tutorial and companion blog series will guide you through building a Spring Boot book tracking application end-to-end, and then connecting it to the NoSQL cloud database — DataStax Astra DB.

You may already know how to build a simple application with Spring Boot, but do you know how to make that same app scale, have high availability, and handle millions of views? The new Code With Me — Better Reads series from Java Brains, focuses on building a clone of the popular website, Goodreads.com which can handle large amounts of data.

You’ll be building a full-stack Spring Boot application, backed by the cloud-native Astra DB, built on a serverless implementation of Apache Cassandra. The intention is to build an app that can store a catalog of every book published in the world! For this, we’re going to need the power of Astra DB.

In this first installment of the series, you’ll start by designing the UX.

The app you will build: BetterReads

If you have ever used Goodreads.com, then you will find the application you will be building with this tutorial is very similar: a book tracker. Though our app will be slightly simplified functionality-wise, we still want to be able to do all this at scale.

First, let’s walk through the features of the app that we’re going to build.

Figure 1. The web application home page.

BetterReads features

  • SSO login using GitHub
  • Search via book title or author
  • Landing pages for book includes title, author, description, cover photo
  • A personal dashboard
  • Ability to track a particular book, set reading start/end dates, and ratings. Currently reading books show up at the top, and finished books are ordered by the finish date
Figure 2. Search books by title.

The BetterReads app is designed to be fast—even if we were to have literally every book ever published saved in our database, we expect pages to load quickly. With the architecture that you are going to build out, individual pages will render super fast, despite the huge amount of data we are serving. You will be able to scale the app to our needs, no matter if there are ten users or hundreds of thousands of users.

The technologies we will be using are: Astra DB, Spring Boot, Spring Security, ThymeLeaf, and Spring Data for Apache Cassandra®.

What is Astra DB?

Astra DB is the cloud database-as-a-service built on the NoSQL data engine: Cassandra, that powers global enterprises like Netflix and Instagram. Cassandra is known for its high availability, linear scalability, and unparalleled horsepower even at petabytes of data.

Astra DB configures and manages Cassandra for you so you can focus on building and deploying cloud-native applications within a matter of minutes. It’s also completely free up to 80GB storage and/or 20 million monthly operations. Even beyond this, Astra DB is completely serverless, reducing your costs by allowing you to run Cassandra clusters only when needed, using intelligent autoscaling.

What is Spring Security?

Spring Security is a powerful and highly customizable authentication and access-control framework that focuses on providing both authentication and authorization to Java applications. It is also the de-facto standard for securing Spring-based applications.

Like all Spring projects, the real power of Spring Security is found in how easily it can be extended to meet custom requirements.

What is ThymeLeaf?

ThymeLeaf is a modern server-side Java template engine for both web and standalone environments. It is designed to produce web views and provides support for generating HTML, XHTML, JavaScript, and CSS documents.

With modules for Spring Framework and a host of integrations with various tools, ThymeLeaf is ideal for modern-day HTML5 JVM web development.

What is Spring Data for Apache Cassandra?

The Spring Data for Apache Cassandra project applies core Spring concepts to the development of solutions when using Cassandra.

Spring Data Cassandra wraps the DataStax Java Driver and is one way of connecting your Java application code and your Cassandra database. It allows you to form records from POJOs, and then write queries by simply typing a valid method name.

A good alternative to connect a Spring Boot project to Cassandra is to use the Stargate project, which offers app-to-database connectivity via REST, GraphQL, gRPC, and a schemaless JSON document API.

The requirements for this tutorial are:

  • JDK and some IDE installed (IntelliJ, VSCode, Eclipse, etc.)
  • A free Astra DB account

Designing the UX

It is very important to do UX design first, as it will give you an idea of the overall flow of the app, what kind of data we will need, and how we need to optimize our database for common usage patterns. Knowing how users will query the data is particularly important for a denormalized database, such as Cassandra, so we can structure our database accordingly. We know we want our app to do the following:

  • Host the metadata of “All the Books in the World”
  • Allow users to browse books by name and author
  • Allow users to mark a book as “Read” or “Want to Read”
  • Dashboard of books you have read or want to read
  • Ability to rate books

The data Source we will be using is OpenLibrary. Due to the enormous volume of data provided by the OpenLibrary’s Data dump, you will be using a subset of this data later in a later blog post for testing your application.

These are the key pages, or UX elements that we will need for our application:

  • The Book Page: You are going to provide one page for every book in the database. This page will include basic information about the book, such as the cover image, title, description, and author. There is an additional form included for a logged-in user. If they have read the book, they can provide a start and end date, and a rating for the book. For status, they can say whether they are currently reading or finished reading the book. This page needs to be performant, all this book information needs to be able to load as quickly as possible.
Figure 3. The book page wireframe.
  • The Author Page: If a user clicks on an author’s name from the Book Page, they will be brought to the Author page. This page will have an image of the author, if available, and the books the author has written (with the most recently written showing up first). There will be a page for every author in our database.
Figure 4. The wireframe for the author page.
  • The Search Page: Users can search for a book. There will be a text box and a search input button. A user can enter a book title, and once they search for a book, they should get all the books that match that particular search criteria.
Figure 5. The wireframe for the author page.
  • Home Page (no-login): Since some functionality of the app requires a user session (ex. marking a book as read), we need a login page. The Home page will have an OAuth login and a search text box. We don’t want to restrict the usage of the app to users who have logged in, but if they want to mark a book as “read”, for instance, they need to log in.
Figure 6. The wireframe for the home page without login.
  • Home Page (Logged in): If the user is logged in, the home page will be a view of their dashboard, along with a list of the most recent books they have read, in reverse chronological order. Books currently being read will be listed on top.
Figure 6. The wireframe for the home page while logged in.

Conclusion

This has been a basic overview of the design of the UX. In the next blog post in this series, we will begin preparing for development as we explore the overall system design and architecture of the Better Reads app. We will design our application and database to work efficiently with this huge amount of book metadata. Check out the Github repository with the full code for this project.

Follow the DataStax Tech Blog for more developer stories. Check out our YouTube channel for tutorials and DataStax Developers on Twitter for the latest news about our developer community.

  1. Code With Me — Better Reads
  2. Astra DB: Multi-cloud DBaaS built on Apache Cassandra
  3. Create an Astra DB account
  4. Apache Cassandra
  5. Java Brains on YouTube
  6. Stargate Project
  7. OpenLibrary
  8. BetterReads project — Github
  9. DataStax Tech Blog
  10. DataStax YouTube channel
  11. Documentation: Create an Astra DB database
  12. DataStax Twitter for Developers
  13. DataStax Community

--

--

--

We’re huge believers in modern, cloud native technologies like Kubernetes; we are making Cassandra ready for millions of developers through simple APIs; and we are committed to delivering the industry’s first and only open, multi-cloud serverless database: DataStax Astra DB.

Recommended from Medium

“If it turns out that this is incurable, would you marry me?”

IBM Power Systems, Red Hat OpenShift and Dynatrace — an Excellent Trio

Dynatrace in a Red Hat OpenShift environment

Production Ready Kubernetes Cluster Deployment on Ubuntu

How to Run Your Streamlit Apps in VSCode

Conga Composer : SObject row was retrieved via SOQL without querying the requested field …

January 7: AWS revenue (2013 to 2021)

WHAT YOU NEED TO KNOW BEFORE IMPLEMENTING ROBOTIC PROCESS AUTOMATION FOR YOUR BUSINESS

Setting up Postgres with Ruby on Rails 7 on Ubuntu 20.04

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
DataStax

DataStax

DataStax is the company behind the massively scalable, highly available, cloud-native NoSQL data platform built on Apache Cassandra®.

More from Medium

Spring for GraphQL

Quarkus — Subatomic Java Review: Apache Kafka Producer & Consumer

Calling Soap Services with WebClient — SpringBoot

Spring Boot Microservice Monitoring with Prometheus and Grafana