diff --git a/README.md b/README.md index 423605e..14a9c35 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Anyone can discover books without signing in. Registered users can also save fav - **Use the application comfortably:** Readr supports keyboard use, responsive layouts, light and dark themes, and accessible feedback. +You can read more about what Readr does and see a checklist against the project description in the [specification](./docs/specifications.md). + We provide an example user that anyone can use. This is also helpful for evaluators when reviewing the project. Just use the "Login as example user" button on the login screen. You can also take a look at the credentials below if you want to log in manually. @@ -58,6 +60,8 @@ Check out [CONTRIBUTING.md](./CONTRIBUTING.md) for further details regarding cod ## Other documentation +- [Specification](./docs/specifications.md) + - What Readr does and a checklist against the project description - [Project choices and reasoning](./docs/choices-and-reasoning.md) - Tech stack and tool choices, discussions and reasoning behind the decisions - [Infrastructure](./docs/infrastructure.md) diff --git a/docs/choices-and-reasoning.md b/docs/choices-and-reasoning.md index d83d7bb..79321cc 100644 --- a/docs/choices-and-reasoning.md +++ b/docs/choices-and-reasoning.md @@ -19,14 +19,13 @@ - [Only relevant filter options](#only-relevant-filter-options) - [E2E testing](#e2e-testing) - [Specification changes](#specification-changes) + - [Original plan](#original-plan) + - [Changes from the original plan](#changes-from-the-original-plan) ## Overview Some parts of the stack were given by the course: React with TypeScript and Vite, a GraphQL backend, and our own database running directly on the VM without Docker. The choices below are the ones we made ourselves. -Our original plan is in the [specification](./specifications.md). -We ended up doing some things differently - this is described at the end of this document. - ## PostgreSQL as the database Our data can be modeled using relations: books belong to many genres, and users have favorites that point to books. PostgreSQL handles this well with foreign keys and joins, and supports case-insensitive search with `ILIKE`. It is also one of the most used databases in real production applications, comfortably handling hundreds of thousands to millions of records (i.e. SQL rows in the tables). @@ -170,6 +169,34 @@ Instead, we use CI for other tasks, such as linting and formatting. ## Specification changes -- **Filters:** We filter on genres, language, book format, number of pages and a minimum number of ratings. The specification also mentioned author, publisher, place and person. Authors are covered by the search field, which searches both titles and authors, and we have not implemented filters for publisher, place and person. The dataset has columns for these: `publisher`, `setting` (places) and `characters` (persons). `publisher` is filled in for 93% of the books, but `setting` and `characters` only for 22% and 26%, so filters on those two would leave out most of the books. -- **Login:** Instead of Google login, we support email/password and GitHub and Discord login. Google was rejected since it required https connection, which we do not provide. -- **Reviews:** Implemented in delivery 4 as specified, with a star rating from 1 to 5 and an optional text. Reviews are written and shown on the book's page, and the user's own reviews are also listed on their profile. A book's rating combines the rating from the dataset with the reviews from our users. +### Original plan + +This is what we planned at the beginning of the project. + +#### Data + +- **Source:** Books from an open-source books dataset, possibly one from [Kaggle](https://kaggle.com). We would import a selection of books into our own database, so that search, filtering and sorting happen on our server. Cover images would still be loaded from the internet, because storing them would quickly fill the 10 GB of storage on our VM. We would only store each book's cover link or ID. +- **Fields per book:** title, authors, first publish year, subjects, language, cover ID, average rating, description and possibly more if the dataset includes it. + +#### User interaction + +- **Search** on title and author. The search is case-insensitive and debounced, so we don't send a request on every keystroke. +- **Filter** on author, subject, place, person, publisher and language. +- **Sort** by rating. +- **Pagination** through the results, a **details page** for each book, and previous/next buttons to browse between books. +- **User-generated data**, stored in our database: + - **Favorites**, shown on their own page. + - **Reviews** with a star rating and an optional text. +- **Login:** if time allows, we will add Google login. + +### Changes from the original plan + +We ended up doing some things differently from our original plan. + +- **Dataset:** The plan left the dataset undecided. We chose the Comprehensive Literary Greats dataset from Kaggle. +- **Cover images:** The plan was to store a cover link or ID. We store each cover URL and load the image externally. +- **Filters:** The plan included author, subject, place, person, publisher and language. We deliver genre, language, book format, page count and a minimum number of ratings. Authors are covered by the search field, which searches both titles and authors. We did not implement filters for publisher, place and person. The dataset has columns for these, but `setting` (places) and `characters` (persons) are only filled in for 22% and 26% of the books, so filters on those two would leave out most of the books. +- **Sorting:** The plan only included sorting by rating. We added it, along with relevance, title, publication date and page count. +- **Login:** The plan was Google login if time allowed. Instead, we support email/password, GitHub and Discord login. Google was rejected because it required an HTTPS connection, which we do not provide. +- **Favorites:** The plan was a separate favorites page. Favorites are shown on the user's profile instead. +- **Reviews:** Implemented in delivery 4 as specified, with a star rating from 1 to 5 and optional text. Reviews are written and shown on the book's page, and the user's own reviews are also listed on their profile. A book's rating combines the dataset rating with the reviews from our users. diff --git a/docs/specifications.md b/docs/specifications.md index 2096095..c46c267 100644 --- a/docs/specifications.md +++ b/docs/specifications.md @@ -1,38 +1,185 @@ # Specification +- [Overview](#overview) - [Data](#data) -- [Design](#design) - [User interaction](#user-interaction) +- [Behavior](#behavior) + - [Search](#search) + - [Filters](#filters) + - [Sorting](#sorting) + - [Pagination and URLs](#pagination-and-urls) + - [Accounts and favorites](#accounts-and-favorites) + - [Reviews](#reviews) + - [Home page](#home-page) +- [Design and interface](#design-and-interface) +- [Qualities](#qualities) + - [Accessibility](#accessibility) + - [Scalability and performance](#scalability-and-performance) + - [Sustainability](#sustainability) +- [Checklist against the project description](#checklist-against-the-project-description) + - [Functionality](#functionality) + - [Quality](#quality) + - [Technology](#technology) + - [Testing and quality control](#testing-and-quality-control) + - [Documentation and hosting](#documentation-and-hosting) -## Data +## Overview + +This document describes what Readr does and how it meets the project requirements. For implementation details, reasoning behind technical decisions and more, see the other project documentation. + +Readr is a book discovery application for searching, filtering and browsing a large catalogue of books. Visitors can explore books and read reviews without an account. Registered users can also save favorites, write and manage reviews, and view a personal profile. -- **Source:** Books from an open-source books dataset, possibly one from [Kaggle](https://kaggle.com). - We will import a selection of books into our own database, so that search, - filtering and sorting happens on our server. Cover images are still loaded - from the internet, because storing them would quickly fill the 10 GB of - storage on our VM. We only store each book's cover link or ID. -- **Fields per book:** title, authors, first publish year, subjects, language, - cover ID, average rating, description and possibly more if the dataset includes it. +Structure: -## Design +- **Home page:** popular books, genres, catalogue statistics, and recommendations for signed-in users with favorites +- **Books page:** search, filters, sorting and paginated results +- **Book details:** book information and reviews +- **Login and signup** +- **Profile and settings** -![Search page](./images/book-grid.png) -![Sketches of homepage and login](./images/sketches.png) +## Data -- The search page with the grid works well, so we only plan to polish it. -- The book details page will be redesigned. Reviews will be shown and written - there. -- We will add a separate page that lists the user's favorite books. +- **Source:** [Comprehensive Literary Greats Dataset](https://www.kaggle.com/datasets/thedevastator/comprehensive-literary-greats-dataset) +- **Storage:** Book data is imported into the project's PostgreSQL database. +- **Cover images:** Only each cover's URL is stored. Browsers load the images from Goodreads, so the project does not host them. +- **Book fields:** title, author, series, ISBN, description, language, format, edition, page count, publisher, publication date and year, genres, cover URL, rating and number of ratings. Some fields may be missing for individual books. +- **User data:** accounts, favorites and reviews. A review has a star rating and optional text. ## User interaction -- **Search** on title and author. The search is case-insensitive and debounced, - so we don't send a request on every keystroke. -- **Filter** on author, subject, place, person, publisher, language. -- **Sort** by rating. -- **Pagination** through the results, a **details page** for each book, and - previous/next buttons to browse between books. -- **User-generated data**, stored in our database: - - **Favorites**, shown on their own page. - - **Reviews** with a star rating and an optional text. -- **Login:** if time allows, we will add Google login. +Anyone can: + +- Search the catalogue by title or author. +- Filter results by genre, language, book format, page count and minimum number of ratings. +- Sort results by relevance (the default), rating, title, publication date or page count. +- Browse results as a paginated grid. +- Open a book's details page to see its information and reviews, and move on to other books. +- See highlights and statistics on the home page, and open a random book. +- Switch between light and dark themes. + +Signed-in users can also: + +- Register and sign in with email and password, GitHub or Discord. +- Add and remove books from their favorites. +- Write, update and delete their own reviews. +- See their favorites and reviews on their profile page. +- Receive recommendations based on the genres of their favorites. + +## Behavior + +### Search + +- Matches titles and authors, and is case-insensitive. +- Input is debounced, so a request is not sent for every keystroke. +- If a search has a small typo, Readr suggests similar titles or authors ([details](./choices-and-reasoning.md#suggest-similar-titles)). If no similar books are found, it shows an empty-results message. + +### Filters + +- Available filters: genre, language, book format, page count and minimum number of ratings. +- Selecting several genres returns books matching **any** of them ([details](./choices-and-reasoning.md#genre-selection)). +- The genre, language and format lists only show options that give books for the current search and the other filters, with the number of books for each option ([details](./choices-and-reasoning.md#only-relevant-filter-options)). + +### Sorting + +- Available orders: relevance (the default), rating, title, publication date and page count. +- Relevance puts books with the most ratings first. For suggestions of similar titles/authors, the closest matches come first. +- Choosing "Rating: high to low" also adds the filter "10,000+ ratings", unless a minimum number of ratings is already selected ([details](./choices-and-reasoning.md#rating-sort-filter)). + +### Pagination and URLs + +- Results are shown 12 books per page. +- Search text, filters, sorting and page number are stored in the URL, so a results view can be revisited, bookmarked or shared. + +### Accounts and favorites + +- The catalogue, book details and reviews can be viewed without signing in. +- Sign-in options: email and password, GitHub, Discord. +- Favorites are stored in the database and shown on the profile. + +### Reviews + +- A review has a star rating from 1 to 5 and optional text. +- Signed-in users can create, edit and delete their own reviews. +- Reviews appear on book details pages and on the profile of the user who wrote them. +- A book's displayed rating combines the dataset rating with user reviews. + +### Home page + +- Shows top-rated books, genres and catalogue statistics. +- "Surprise me" opens a random book. +- Recommendations are shown only to signed-in users with favorites, and are based on the genres of those favorites. + +## Design and interface + +Readr has a clean, uncluttered design with a neutral color palette, so the book covers and content stand out. The layout is clear and consistent across the application, and it adapts from phones to desktop displays. Light and dark themes are available. + +The images below are from the beginning of the project and are kept for archival purposes only. They do not represent the finished application. + +
+Early screenshot and sketches + +![Early screenshot of the search page](./images/book-grid.png) + +![Early project sketches](./images/sketches.png) + +
+ +## Qualities + +### Accessibility + +Readr must be usable by everyone, including people who rely on a keyboard or assistive technology. How this is done and tested is described in [Accessibility](./accessibility.md). + +### Scalability and performance + +- The backend and database handle search, filtering, sorting and counts. The client requests one page at a time. +- Search is debounced, and Apollo Client caching avoids some repeated requests. +- Database indexes support the main search, filter and sort operations. + +### Sustainability + +Readr should follow sustainable web development principles, mainly by limiting the amount of data that is stored, transferred and processed. The choices made are described in [Sustainability](./sustainability.md). + +## Checklist against the project description + +### Functionality + +- [x] **Case-insensitive search without unnecessary requests:** title/author search, case-insensitive and debounced. +- [x] **List suited to large result sets:** server-side pagination, 12 books per page. +- [x] **More details about each object:** book details pages with information and reviews. +- [x] **Filter and sort the whole result set:** done by the backend. +- [x] **Persistent, presented user-generated data:** favorites and reviews are stored in the database and shown in the app. +- [x] **Search possible without login:** the catalogue and book details are public. +- [x] **Usable without manually creating an account:** the login page has a button that signs in as a test user. + +### Quality + +- [x] **Universal design and accessibility:** see [Accessibility](./accessibility.md). +- [x] **Sustainable web development:** see [Sustainability](./sustainability.md). +- [x] **Design suited to the data:** book grid, details pages, profile and home page. +- [x] **Scalability:** server-side search, filtering, sorting and pagination, supported by database indexes. + +### Technology + +- [x] **React and TypeScript with Vite:** used by the frontend. +- [x] **State management:** URL parameters for search state, Apollo Client for server-state caching. +- [x] **Custom GraphQL backend (Node/TypeScript):** Express and Apollo Server. +- [x] **Database on the VM without Docker:** PostgreSQL, see the [backend README](../backend/README.md). +- [x] **Third-party libraries:** documented in [Infrastructure](./infrastructure.md). + +### Testing and quality control + +- [x] **Linting and formatting:** ESLint and Prettier scripts in the frontend and backend. +- [x] **Component tests:** Vitest and React Testing Library in the frontend. +- [x] **API tests:** Vitest tests of the GraphQL schema and resolvers against a test database. +- [x] **End-to-end tests:** Playwright tests in the frontend, run with `pnpm e2e`. + +### Documentation and hosting + +- [x] **Main choices and solutions documented:** README and `docs/`. +- [x] **Installation and running documented:** frontend and backend READMEs. +- [x] **Hosted on the project VM:** `http://it2810-37.idi.ntnu.no/project2/`. +- [x] **Backend on port 3001:** see [Infrastructure](./infrastructure.md). +- [x] **Backend and database setup documented:** [backend README](../backend/README.md) and [Deployment](./deployment.md). +- [x] **AI use and team practices documented:** [AI documentation](./ai-documentation.md) and [Contributing guide](../CONTRIBUTING.md). +- [x] **Systematic use of Git and GitHub:** the work is planned and tracked with issues, developed on branches, and merged through pull requests with code review. The history is visible in the repository, and the practices are described in the [Contributing guide](../CONTRIBUTING.md).