JS

DC Hub

Type: Full-Stack Knowledge Repository Role: Full-Stack Developer Team: Group Project Year: 2025
PHP MySQL PDO JavaScript Apache .htaccess REST API

Overview

DC Hub is a collaborative group project built for Durham College — a full-stack knowledge repository where faculty upload course materials (PDFs, topics, and notes) organized by semester and course, and students browse and access them through a clean, role-based interface.

Originally developed on Durham College's internal server, the project has since been migrated to a personal hosting environment at dchub.jaswant.dev, requiring a full server migration including database export/import, path fixes, and authentication system overhaul.

Key Features

  • Role-based access control — separate admin and student interfaces protected by Apache HTTP Basic Authentication
  • Admin panel for managing semesters, courses, topics, and PDF uploads
  • Student-facing browsing interface organized by semester → course → topic → PDFs
  • Faculty "Switch to Student" toggle — admins can preview the student view without logging out
  • Secure PDF and image streaming via PHP — files served through API endpoints, not exposed directly
  • Full-text keyword search across topics and course materials
  • RESTful PHP API powering all frontend data fetching with JSON responses
  • PDO-based MySQL queries with prepared statements throughout

Architecture

The frontend is a vanilla JavaScript SPA-style interface consuming a PHP REST API. All data (semesters, courses, topics, PDFs) is fetched asynchronously via fetch() calls to endpoint handlers in the /api/ directory. PHP sessions track the authenticated user's role and faculty status across page loads.

Authentication is handled entirely by Apache's HTTP Basic Auth via .htaccess — replacing the original PHP login system. Two separate protected directories (/admin/ and /student/) act as entry points that validate credentials and bootstrap the PHP session before redirecting into the application.

Server Migration

Migrating the project from Durham College's shared server to personal hosting involved resolving several real-world challenges: fixing MySQL collation mismatches (utf8mb4_0900_ai_ci vs utf8mb4_unicode_ci), correcting foreign key import ordering, re-pathing all file includes using __DIR__, and adapting the auth system for a PHP-FPM environment where REMOTE_USER is not passed from Apache to PHP.

What I Learned

This project gave me hands-on experience with the realities of collaborative development and real server deployments — from debugging foreign key constraint errors during database migration to understanding how Apache and PHP-FPM interact around authentication headers. Building and then replacing the login system with .htaccess Basic Auth deepened my understanding of how web server–level authentication differs from application-level auth.