Overview

Dark Souls CRUD REST API is a team project implementing a two-tier web service architecture around a Dark Souls-themed darksouls MySQL database. The PHP provider exposes a single unified API endpoint (API_200.php) that handles read, insert, update, and delete operations across three relational tables — characters, factions, and weapons — dispatching by an action request parameter and returning JSON. The JavaScript client consumes the API via AJAX, renders live data tables, and provides per-table CRUD forms with audio feedback and row-level animations.

Features

  • Single REST endpoint (API_200.php) routing all CRUD operations via an action parameter
  • Full Create, Read, Update, and Delete support for Characters, Factions, and Weapons tables
  • DB_200 OOP class encapsulating all MySQL read, insert, update, and delete operations
  • Dedicated OOP model classes (Character, Faction, Weapon) each with a toArray() method for JSON serialization
  • Live table refresh after every mutation without full page reload
  • Row-level CSS animations — fade-in on insert, fade-out on delete, flash on update
  • Sound effects (insert.mp3, update.mp3, delete.mp3) triggered on each mutating action
  • Floating ember particle system rendered via particles.js for atmospheric theming
  • Standalone PHP tester page rendering all three tables server-side for development verification
  • UML class diagram documenting the provider-side OOP model

Screenshots

Home Page: CRUD Home Page: CRUD

Home Page: Live Data Viewer Home Page: Live Data Viewer

Code Highlights

// Provider_200/API_200.php — unified CRUD dispatcher returning JSON
header('Content-Type: application/json');

include_once('classes/DB_200.php');
$db = new DB_200();

$action = $_REQUEST['action'];
$table  = $_REQUEST['table'];

if ($action == "read") {
    $id     = !empty($_REQUEST['id']) ? $_REQUEST['id'] : null;
    $result = $db->read($table, $id);
    $data   = [];
    while ($row = $result->fetch_assoc()) { $data[] = $row; }
    echo json_encode($data);
}

if ($action == "insert") {
    $data = $_POST;
    unset($data['action'], $data['table']);
    $db->insert($table, $data);
    echo json_encode(["status" => "inserted"]);
}

if ($action == "update") {
    $id   = $_POST['id'];
    $data = $_POST;
    unset($data['action'], $data['table'], $data['id']);
    $data = array_filter($data, fn($v) => $v !== "");
    $db->update($table, $id, $data);
    echo json_encode(["status" => "updated"]);
}

if ($action == "delete") {
    $db->delete($table, $_REQUEST['id']);
    echo json_encode(["status" => "deleted"]);
}

Challenges & Solutions

Challenge: Supporting CRUD for three structurally different tables through a single API endpoint without duplicating logic.
Solution: The DB_200 class accepts a $table string parameter on every method, building queries dynamically — the API endpoint routes by action only, keeping all three tables fully supported with no redundant code paths.

Challenge: Keeping the client UI in sync with the database after every insert, update, or delete without a full page reload.
Solution: A refreshAllTables() helper in app.js calls loadTable() for all three tables after any mutation, re-rendering each live table via AJAX and triggering the appropriate CSS row animation before the refresh completes.