Projects
Fantasy Through Time
Description
This project is an interactive React dashboard that explores fantasy literature through data from the Open Library API. Users can search and filter books, compare publication periods and popular authors through charts, and open a dedicated detail page for each title.
Features
- Search books by title or author and filter by publication period
- Summary cards for total books, authors, oldest year, and average year
- Bar charts for publication periods and top authors that update with filters
- Unique detail routes for each book with extra fields like subjects and page count
- Cover images with a fallback when no cover is available
- Loading, error, no-results, and book-not-found states
Fetches fantasy books from Open Library and keeps only the fields the dashboard needs:
const url =
'https://openlibrary.org/search.json?subject=fantasy&limit=50&fields=key,title,author_name,first_publish_year,edition_count,cover_i,subject,person,place,language,number_of_pages_median,ebook_access'
const response = await fetch(url)
const result = await response.json()
const cleanedBooks = result.docs
.filter((book) => book.title && book.first_publish_year)
.map((book) => ({
id: book.key.replace('/works/', ''),
title: book.title,
author: book.author_name ? book.author_name[0] : 'Unknown author',
year: book.first_publish_year,
editions: book.edition_count || 0,
coverId: book.cover_i || null,
}))
.sort((a, b) => a.year - b.year)
Filters the list by search text and publication period, then recalculates the summary stats:
const filteredBooks = data.filter((book) => {
const searchText = searchQuery.toLowerCase()
const titleMatches = book.title.toLowerCase().includes(searchText)
const authorMatches = book.author.toLowerCase().includes(searchText)
return (titleMatches || authorMatches) && matchesPublicationPeriod(book)
})
const totalBooks = filteredBooks.length
const totalAuthors = new Set(filteredBooks.map((book) => book.author)).size
Groups the current results into publication-period buckets for the first chart:
const periodData = [
{ period: 'Before 1900', books: data.filter((book) => book.year < 1900).length },
{ period: '1900–1949', books: data.filter((book) => book.year >= 1900 && book.year <= 1949).length },
{ period: '1950–1979', books: data.filter((book) => book.year >= 1950 && book.year <= 1979).length },
{ period: '1980–1999', books: data.filter((book) => book.year >= 1980 && book.year <= 1999).length },
{ period: '2000–Present', books: data.filter((book) => book.year >= 2000).length },
]
Outcome
A dashboard that makes a book dataset easier to explore through search, charts, and detail pages. Sharing one fetch across the dashboard and every detail route kept loading and error states consistent without extra API calls.
Visit this project's GitHub repository here: GitHub Repository