Kevin Crandall

Software Developer • Enterprise Applications • AI Solutions

CS 499 Capstone Enhancement

Database Enhancement

Completed

This enhancement revisits the Travlr Getaways full-stack travel management application originally developed in CS 465: Full Stack Development I. The application includes a customer-facing Express and Handlebars website, an Angular administrative single-page application, a RESTful Express API, and a MongoDB database managed through Mongoose.

The original application used a comparatively simple database structure centered primarily on trip records. Although the design supported the original course requirements, it offered limited support for relationships, customer-generated content, reporting, and more advanced data analysis.

This enhancement redesigned the MongoDB and Mongoose data model by introducing related Category and Review collections, stronger validation, database indexes, calculated review metrics, and MongoDB aggregation pipelines. These improvements support new customer review functionality, improved trip organization, and an administrative statistics dashboard.

Enhancement Objectives

Expand the Data Model

Transform the original database structure into a more robust architecture containing related Trip, Category, and Review collections.

Improve Data Integrity

Strengthen Mongoose schemas and request validation to ensure that properly formatted and complete information is stored in the database.

Support Customer Feedback

Add customer ratings and reviews while maintaining accurate average-rating and review-count values for each trip.

Provide Administrative Reporting

Use MongoDB aggregation pipelines to calculate meaningful pricing, duration, rating, review, and category statistics.

Major Improvements

Category Collection

  • Created a dedicated Category model
  • Added category names and descriptions
  • Connected trips through ObjectId references
  • Added a category retrieval endpoint
  • Integrated categories into trip forms

Review Collection

  • Created a dedicated Review model
  • Associated reviews with trip records
  • Stored customer names, ratings, and comments
  • Added timestamps for review history
  • Sorted reviews from newest to oldest

Database Relationships

  • Established one-to-many relationships
  • Used MongoDB ObjectId references
  • Separated reusable category information
  • Stored reviews independently from trips
  • Improved organization and maintainability

Schema Validation

  • Expanded Mongoose validation rules
  • Validated required trip fields
  • Restricted ratings to valid values
  • Validated review submissions
  • Protected database integrity

Database Indexing

  • Added indexes for commonly queried fields
  • Supported efficient trip lookups
  • Improved sorting and filtering performance
  • Prepared the application for larger datasets
  • Reduced unnecessary database scanning

Calculated Review Metrics

  • Added averageRating to trip documents
  • Added reviewCount to trip documents
  • Recalculated metrics after review submission
  • Reduced repeated calculations
  • Improved common trip-query performance

Aggregation Pipelines

  • Calculated overall trip statistics
  • Calculated pricing and duration summaries
  • Identified highest-rated trips
  • Identified most-reviewed trips
  • Generated category-based reporting

Full-Stack Integration

  • Updated REST API controllers and routes
  • Integrated data into the Angular SPA
  • Updated the Express customer website
  • Maintained synchronized review information
  • Tested functionality across application layers

Database Architecture

Categories

Category documents store reusable information that classifies travel packages. Each trip references a category through a MongoDB ObjectId, allowing multiple trips to share the same category without duplicating category data.

Trips

Trip documents remain the central records in the application. The enhanced schema includes category references, normalized duration values, average ratings, review counts, and indexes supporting common queries.

Reviews

Review documents contain customer feedback, numeric ratings, customer names, timestamps, and a reference to the associated trip. This allows each trip to support multiple independent review records.

Selective Denormalization

Average rating and review count values are stored directly on trip documents. These calculated values improve common read operations while remaining synchronized whenever a new review is submitted.

Customer Experience

Trip Detail Pages

  • Added individual trip-detail routes
  • Displayed destination information
  • Displayed category and duration
  • Displayed pricing information
  • Displayed rating summaries

Customer Reviews

  • Added a customer review form
  • Accepted names, ratings, and comments
  • Validated review information
  • Displayed successful submissions
  • Presented reviews newest first

Ratings and Review Counts

  • Displayed star ratings
  • Displayed numeric average ratings
  • Displayed total review counts
  • Handled trips without reviews
  • Updated values after new submissions

Consistent Presentation

  • Displayed ratings on trip listings
  • Displayed ratings on detail pages
  • Maintained consistent image dimensions
  • Improved review-form usability
  • Preserved the existing website design

Administrative Dashboard

Overall Statistics

The dashboard displays the number of trips, average price, lowest and highest prices, average duration, shortest and longest durations, total reviews, reviewed trip count, and overall average rating.

Highest-Rated Trips

A MongoDB aggregation pipeline identifies and ranks the destinations with the highest customer ratings, allowing administrators to recognize strongly performing travel packages.

Most-Reviewed Trips

The dashboard identifies trips receiving the largest number of customer reviews, providing insight into customer engagement and destination popularity.

Category Statistics

Category-based aggregation reports summarize the number of trips, average pricing, average duration, total reviews, and average ratings for each travel category.

Technical Skills Demonstrated

MongoDB Mongoose Database Design Schema Modeling ObjectId Relationships Data Validation Database Indexing Aggregation Pipelines Normalization Selective Denormalization REST API Development Express.js Angular Handlebars Full-Stack Integration Performance Optimization Technical Documentation

Course Outcomes Demonstrated

Database Design and Evaluation

Redesigned the application's database architecture to support related collections, efficient queries, stronger validation, improved scalability, and new customer and administrative functionality.

Innovative Computing Practices

Applied MongoDB ObjectId relationships, Mongoose schema modeling, database indexes, calculated metrics, and aggregation pipelines to deliver meaningful application features and reporting.

Software Engineering

Coordinated database changes across the REST API, Angular administrative interface, customer-facing Express website, validation middleware, and application documentation.

Professional Communication

Documented the database architecture, design decisions, technical trade-offs, implementation results, and user benefits through the repository README, capstone narrative, and ePortfolio.

Security Mindset

Preserved authenticated administrative operations, validated incoming data before database modifications, and strengthened database integrity by rejecting incomplete or improperly formatted requests.

Design Trade-Offs

A central design decision involved balancing normalization with application performance. Creating separate Category and Review collections improved organization, reduced unnecessary duplication, and allowed related information to be managed independently.

However, repeatedly recalculating average ratings and review counts during common trip queries would have introduced unnecessary processing. To address this concern, the enhancement uses selective denormalization by storing these calculated metrics directly on each trip document.

The original enhancement plan also included a customer favorites feature. During development, I determined that related collections, aggregation pipelines, customer reviews, reporting, validation, and indexing provided a stronger demonstration of advanced database concepts. Favorites were therefore retained as a possible future enhancement rather than expanding the current milestone's scope.

Reflection

This enhancement reinforced that effective database design extends beyond storing and retrieving information. Data modeling decisions directly influence application architecture, query performance, maintainability, scalability, and the user experience.

Introducing related collections strengthened my understanding of normalization, while storing calculated review statistics on trip documents demonstrated when selective denormalization can improve performance. This required balancing data organization against the efficiency of frequently performed read operations.

Implementing the customer review system also demonstrated how thoughtful database enhancements can produce visible value for users. Customers can now provide ratings and feedback, while administrators can use aggregated review metrics to better understand engagement and trip performance.

The greatest challenge involved maintaining consistency across every application layer. Database schema changes required corresponding updates to the REST API, Angular administrative application, customer-facing website, validation middleware, and reporting logic.

Overall, this work strengthened my ability to design database-driven applications, evaluate architectural trade-offs, implement advanced MongoDB features, and integrate related data across a complete full-stack application.

Project Repositories

The original repository contains the Travlr Getaways application as developed during CS 465. The Database Enhancement branch contains the completed data-modeling, validation, indexing, review, aggregation, dashboard, API, and interface enhancements.