Personal information
Name: Ansh Goyal
IRC nick: ansh
Email: anshg1214@gmail.com
GitHub: anshg1214
Time Zone: UTC+05:30
CritiqueBrainz reviews for BookBrainz entities
Project Overview
Book reviews are a glimpse into a world you may or may not choose to enter. Reviews give books greater visibility and a greater chance of getting found by more readers. BookBrainz and CritiqueBrainz should enable users to rate and write reviews directly through the website using the CritiqueBrainz API. BookBrainz currently lacks this feature. This project aims to extend the infrastructure of CritiqueBrainz to support reviews and ratings for BookBrainz entities.
My PRs: Check Out
My Commits: Check Out
Implementation:
I would first complete the project for the EditionGroup entity. After I complete the work for this functionality, I will begin expanding it for other entities.
Connect the BookBrainz database to CritiqueBrainz:
-
Create a new Docker container for saving the BookBrainz database
bookbrainz_db: image: postgres:12.3 environment: POSTGRES_USER: critiquebrainz POSTGRES_PASSWORD: critiquebrainz POSTGRES_DB: bookbrainz PGDATA: /var/lib/postgresql/data/bbdata volumes: - ../data/bbdata:/var/lib/postgresql/data/bbdata:z - ./pg_custom:/docker-entrypoint-initdb.d/ ports: - "127.0.0.1:35432:5432"
-
Write scripts to download and import data dumps to PostgreSQL.
Add support for bookbrainz entity types Author, Work, Edition Group and Series.
-
Modify the existing CB database and existing functions to support new entity types.
For this, I would add BB entity types in create_types.CREATE TYPE entity_types AS ENUM ( "release_group", "event", "place", "work", "artist", "label", "recording", "Author", "EditionGroup", "Publisher", "Series", "Work" );
-
Write and modify existing functions to fetch data from BB DB to get the required information from existing views in the database:
I will create functions for every entity_type to bulk lookup its information using SQL queries. It would take a list of dictionaries with entity_type and BBID of the entity and then return the related information.
-
Create functions for fetching relations between various entity types:
I will create functions that take in the BBID and return all the necessary details of entities with a relationship with it. As for Author, It would return the details of his works and series.
-
For searching BB items, I would make the following changes:
a. I would add support in the code to search for BB entities and then make UI changes to allow users to search.
b. Then would add backed support to fetch the search results from the BB search endpoint and return the data in the required format.def search_entity(query, entity_type, limit, offset): baseURL = 'https://bookbrainz.org/search/search' params = {'q': query, 'type': entity_type, 'size': limit, 'from': offset} data = requests.get(baseURL, params=params) return data.json()
-
Then will update the APIs and functions fetching reviews from the CB database.
-
Update APIs to allow users to fetch, write and delete reviews for BookBrainz entities.
Display the reviews, ratings, and other identifiers for a BBID in CB.
-
Add BB entities to the ​​reviews page by updating the front-end code.
-
Add pages for all entity types which would show the following:
a. Reviews and Ratings
b. External links
c. Discography => Edition for Edition Group, Work and Series for Author, Edition for WorkExample: The author’s page would look like this.
- Then would update the page for writing a review and modifying the existing review to support BookBrainz entities.
Documentations:
- I will add the setup process of the BookBrainz database.
- Update API documentation to include submission of BB reviews.
Show CB reviews in BB via API without authentication:
-
I would add functions to get reviews from CB associated with BBID.
const getReviewsFromCB = async (entity_id, limit, offset) => { const url = `https://critiquebrainz.org/ws/1/review?entity_id=${entity_id}&limit=${limit}&offset=${offset}`; const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json;charset=UTF-8", }, }); return response.json(); };
-
Then, I would show reviews and ratings on the entity pages.
Implement OAuth login from BB to CB:
-
Connect to CB through OAuth2:
a. I would add functions to get the authorised URL, fetch access token, and refresh access token from CB.
b. Then I will write functions to fetch and save these tokens in the database.
c. Then I would create API routes for CB callback, getting tokens, refreshing tokens, and connecting and disconnecting users, which the React front-end components would call. -
Add front-end components to support connecting to CB:
a. I will first add UI components for connecting CB.
b. Then I will add functions in react to call the API to support connecting to CB.
Allow users to post ratings and reviews:
-
Add functions to post reviews associated with a BBID.
const submitReviewToCB = async (accessToken, review) => { const url = `https://critiquebrainz.org/ws/1/review/`; const response = await fetch(url, { method: "POST", headers: { Authorization: `Bearer ${accessToken}`, "Content-Type": "application/json;charset=UTF-8", }, body: JSON.stringify({ is_draft: false, entity_id: review.entity_id, entity_type: review.entity_type, text: review.text, license_choice: "CC BY-SA 3.0", language: review.languageCode, rating: review.rating, }), }); return response.json(); };
-
Add front-end components to allow users to post ratings.
Timeline:
Here is a detailed week-by-week timeline for the 175 hours of the GSoC coding period, which I intend to maintain and follow.
Pre-Community Bonding Period ( April ):
I plan to work on tickets and features to get more understanding of the workflow, code structure, and related technical skills.
Community Bonding Period ( May - June ):
I plan to fix existing bugs, help to merge pending PRs and close the issues. Also, I will discuss with my mentors regarding the roadmap, Finalising the UI and get a clear sight of the plan of action for the project.
Week 1:
I will begin by creating a Postgres database in a docker container and writing scripts to import the BB data dumps.
Week 2-3:
Then will write functions to fetch data from the BB database. Then would implement the search feature.
Week 4:
I’ll update the front-end code in CB to show reviews and other associated information for BB entities. Then I will add support for new entity types in the CB database. Update existing functions and features to support them.
Week 5:
I will update the CritiqueBrainz APIs to allow users to get and post BB reviews.
Week 6:
Add backend functionality in BB to get reviews from CB.
Week 7:
Create front-end components to show reviews and ratings in BB.
Week 8:
In BookBrainz, I would implement an OAuth login to CB. (Backend)
Week 9:
I would create front-end components and routes to allow users to connect to CB.
Week 10:
I will add backend functionality to post reviews and ratings in BB.
Week 11:
I will update the frontend to allow users to post reviews and ratings in BB.
Week 12:
Clean up the code and write documentation. Discuss with my mentors and make the relevant changes before the final submission of the work.
Stretch Goals:
- Expand this functionality for other entity types also.
- Allow users to view all their reviews and ratings on one page in BB.
- Unify the reviews where an entity in BB also exists in MB.
Detailed information about yourself
My name is Ansh Goyal. I am currently a freshman in my B.E from Birla Institute of Technology and Science (BITS), Pilani, India.
Tell us about the computer(s) you have available for working on your SoC project!
I own an Apple Macbook Air, M1 Chip with 8 GB RAM.
When did you first start programming?
I remember writing my first code in C++ back in my 9th standard.
What type of music do you listen to? (Please list a series of MBIDs as examples.)
I generally listen to rock music like one’s from Linkin Park and Nirvana.
If applying for a BookBrainz project: what type of books do you read?
I enjoy reading works of mystery and thrillers like Panama Red and The Da Vinci Code.
Have you ever used MusicBrainz to tag your files?
Yes, I have!
What aspects of the project you’re applying for (e.g., MusicBrainz, AcousticBrainz, etc.) interest you the most?
BookBrainz provides an open and free database and enables avid book readers like me to make full use of collections and retrieve corresponding details of books.
Have you contributed to other Open Source projects? If so, which projects and can we see some of your code?
I am relatively new to open source.
If you have not contributed to open source projects, do you have other code we can look at?
Yeah, over the past year, I’ve played with Python, NodeJS, PostgreSQL and Redis by building some personal and hackathon projects. A few of them are available here: FridgeToTable, Taapmaan.
What sorts of programming projects have you done on your own time?
As a hobbyist, I have done various python and javascript projects.
How much time do you have available, and how would you plan to use it?
I plan to devote 30 hours per week starting July. My university classes will end in June.