QAP 3 - Database and Backend Integration

QAP 3 - Database and Backend Integration

Objective

  • Refactor an existing Express backend to use MongoDB (via Mongoose) to manage a collection of CDs
  • Replace in-memory storage with MongoDB
  • Add RESTful API routes to interact with the CD collection
  • Due date: July 28th, 2025 @ 11:59 PM NDT

Getting Started

  • To help you get started, a base repository has been provided for you to work from. The repository is set up as a GitHub Assignment to help you quickly get started.

Steps to Create Your Own Repository

  1. Click the link above, and select your name on the list that appears, if you haven’t already

  2. Click the “Accept this assignment” button

  3. Once your repository is created, clone your new repo to your local machine:

    git clone <your-repo-url>
  4. Navigate to the project folder and install dependencies:

    cd <your-project>
    npm install
  5. Run the server:

    npm start

If you’re unable to connect to a local MongoDB instance, you may use MongoDB Atlas as a free cloud-hosted alternative.

Functional Requirements

MongoDB Integration

  • Use Mongoose to connect to MongoDB and define a CD model
  • Replace all in-memory logic with Mongoose database queries
  • CD records must persist across server restarts

Core REST API

Update and implement the following standard routes for managing CDs:

MethodRouteDescription
GET/cdsRetrieve all CDs
POST/cdsAdd a new CD
PUT/cds/:idUpdate an existing CD (any field)
DELETE/cds/:idDelete a CD by ID

Query Functionality

You must implement the following features using proper RESTful design:

FeatureHow to Implement
Retrieve titles onlyGET /cds?fields=title - use a query param to return only CD titles
Filter by artistGET /cds?artist=Linkin Park - return all CDs by a given artist via query param
Filter by genreGET /cds?genre=Pop - return all CDs of a given genre via query param
CDs released before a certain yearGET /cds?before=2000 - return all CDs released before the given year

Note: The values in the query params above (like the specific genre “Pop” or the specific year “2000”) are examples and any values for the query param should be supported. e.g. We should also support “Rock” or “Rap” as genres, as the query parameter should take any genre.

Sample Data

The following is a sample of the kind of data your application should be able to support. You are not required to insert this data into your database, and you do not need to write code to do so unless you wish to make testing easier.

TitleArtistGenreRelease Year
Hybrid TheoryLinkin ParkRock2000
ThrillerMichael JacksonPop1982
The Eminem ShowEminemHip-Hop2002
Back in BlackAC/DCRock1980
21AdeleSoul2011
FearlessTaylor SwiftCountry2008
NevermindNirvanaGrunge1991
Future NostalgiaDua LipaPop2020
American IdiotGreen DayPunk Rock2004
Good Kid, M.A.A.D CityKendrick LamarHip-Hop2012

This variety of records is designed to help you test features like filtering by artist, genre, and release year.

Submission Guidelines

  • Submit a single GitHub repository containing:
    • All source code for the Express + Mongoose app
    • Your completed route implementations
  • Submit a link to the repository on Teams under the appropriate assignment
  • Use a tool like Thunder Client, Postman, or curl to test your endpoints
  • Reach out before the deadline if you need an extension
  • Submissions are subject to the Keyin late assessment policy found here

Grading Rubric

CategoryCriteriaPoints
MongoDB IntegrationMongoose Setup & Integration: App connects to MongoDB using Mongoose and replaces all in-memory logic10
Schema Design: Mongoose schema is correctly defined and used10
Core REST RoutesGET /cds: Successfully retrieves all CDs5
POST /cds: Successfully adds a new CD5
PUT /cds/:id: Successfully updates CD data10
DELETE /cds/:id: Successfully deletes a CD5
Query FeaturesTitles Only: GET /cds?fields=title returns only CD titles5
Filter by Artist: GET /cds?artist=... returns all CDs by the given artist5
Filter by Genre: GET /cds?genre=... returns all CDs in a given genre5
Released Before: GET /cds?before=... returns all CDs released before a given year5
Code QualityReadability: Code is well-organized and easy to read (proper indentation, clear variable/function names)5
Modularity: Functions are properly modularized5
Error Handling: Routes include meaningful input validation and respond to bad requests appropriately5
Git HygieneCommit Frequency: Regular commits reflecting meaningful progress throughout development5
Commit Quality: Commit messages are clear, concise, and descriptive5
Total Points90