Backend Coding Challenge #1: Design a Library Catalog API

This is the first in our series of backend coding challenges designed to test your skills in API design, data modeling, and system architecture. Your task is to build the backend for a simple library catalog system from scratch.

This problem is framework-agnostic. You can solve this backend coding challenge using any technology you prefer, such as Spring Boot, Node.js (Express), Python (Django/Flask), or Ruby on Rails.

The goal is to design a clean API, a key skill tested in any backend coding challenge.

## 1. Problem Description

A local library needs a backend system to manage its catalog of authors and books. The core of this system is a REST API that will power future applications like a public website or an internal management tool.

The system’s data model must be built around a fundamental relationship:

  • An author can write multiple books.
  • A book is written by only a single author.

This represents a classic one-to-many relationship, and your database schema and API structure must correctly implement it.

Modeling a one-to-many relationship is a common task in a backend coding challenge.tionship that your database schema and API structure must correctly implement.


## 2. Functional Requirements

Your application must provide a way to perform the following actions:

  1. Manage Authors: Add new authors to the library catalog.
  2. Manage Books: Add new books to the catalog.
  3. Establish Relationships: When a new book is added, it must be explicitly linked to an existing author.
  4. Retrieve Data: Fetch a complete author profile, including their personal details and a full list of all books they have written.

## 3. API Endpoint Specifications

To meet the requirements, you must implement the following RESTful API endpoints:

ActionHTTP Method & URLDescription
Create an AuthorPOST /api/authorsAccepts an author’s details (e.g., name) and creates a new, unique entry in the database.
Add a BookPOST /api/authors/{authorId}/booksAccepts a book’s details (e.g., title) and associates it with the author specified by {authorId}.
Get an Author’s ProfileGET /api/authors/{authorId}Retrieves the details for a single author, including a nested list of all their associated books.

## 4. Technical Guidelines & Constraints

  • Database: Your solution must persist data in a relational database (e.g., MySQL, PostgreSQL, H2).
  • Architecture: Your code should be well-structured. Using a standard architectural pattern like MVC or a Layered Architecture is highly recommended.
  • API Format: All data exchange between the client and your API must be in JSON (learn more at MDN Web Docs) format.
  • Error Handling: The API should handle basic error scenarios, such as when a requested authorId does not exist.

## Next Steps

Think you’ve got a working solution?

Ready for more? Try our Backend Challenge #2: User Authentication System.

Compare your work with our official Solution for the Library Catalog API Challenge.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top