About / User Stories

Viewpoint: Admin, alle pagina’s worden server-side gerenderd met EJS en MySQL, zonder ORM en zonder async/await.

Epic A — Admin: Actors catalogue
US-A1 — List & Search actors with pagination

As an Admin, I want to search actors by name and paginate results, so that I can quickly find the right person.

  • GET /actors shows table sorted by last name, then first name.
  • Query filters: q matches first_name OR last_name (LIKE %q%).
  • Pagination via page (≥1); out-of-range clamps to valid pages; empty results render friendly “no results”.
US-A2 — Create a new actor

As an Admin, I want to add a new actor, so that the catalogue stays up to date.

  • GET /actors/new renders form; POST /actors validates (first_name, last_name required).
  • On success insert + redirect to details; on validation error re-render with messages, keep entered values.
US-A3 — View actor details

As an Admin, I want to see an actor’s details, so that I can inspect and verify records.

  • GET /actors/:id shows first_name, last_name, last_update and films the actor appears in.
  • 404 page if the id does not exist.
US-A4 — Edit an actor

As an Admin, I want to update names, so that data remains correct.

  • GET /actors/:id/edit pre-fills form; POST /actors/:id/update validates & updates.
  • last_update=NOW(); redirect to details on success, otherwise re-render with errors.
US-A5 — Delete an actor (with safeguards)

As an Admin, I want to remove actors that are no longer needed, so that the catalogue stays tidy.

  • POST /actors/:id/delete attempts to delete.
  • If actor is linked in film_actor, show a friendly error and do not delete.
  • On success redirect to list, keeping pagination/search context where possible.
Epic B — Admin: Films catalogue
US-B1 — List, filter & paginate films

As an Admin, I want to browse films with quick filters, so that I can find and manage titles.

  • GET /films lists films with poster, title, language, price and short description.
  • Filters: q (title, LIKE), category_id; pagination like actors list.
  • “Edit/Delete” buttons only when authenticated.
US-B2 — Create a new film (assign actors)

As an Admin, I want to add a film—including linked actors—so that the catalogue grows consistently.

  • GET /films/new shows form with Title, Description, Language, Category, Rental rate (€), Release year, Rating, and multi-select Actors.
  • Client-side actor search (filter box on the multi-select) to quickly find names.
  • POST /films inserts into film and related rows in film_category & film_actor within a single connection (callbacks only).
  • Validation: title required; rental_rate ≥ 0; release_year 1900–2100; rating in allowed set (e.g. G/PG/PG-13/R/NC-17).
US-B3 — View film details

As an Admin, I want to see a film’s details, so that I can verify metadata and cast.

  • GET /films/:id shows all film fields, assigned category, and the list of actors.
  • 404 if film id does not exist.
US-B4 — Edit a film (incl. cast)

As an Admin, I want to update film data and its cast, so that information stays correct.

  • GET /films/:id/edit pre-fills form; search-to-filter for actors; selected items persist.
  • POST /films/:id/update updates film and replaces joins in film_actor/film_category (delete + bulk insert).
US-B5 — Delete a film (safe detach)

As an Admin, I want to delete a film safely, so that the list stays relevant.

  • POST /films/:id/delete first deletes join rows in film_actor and film_category, then the film.
  • If the film is referenced by rentals, show a friendly message (no crash) and do not delete.
Implementation map (routes → stories)
MethodPathRelates to
GET/actorsUS-A1
GET/actors/newUS-A2
POST/actorsUS-A2
GET/actors/:idUS-A3
GET/actors/:id/editUS-A4
POST/actors/:id/updateUS-A4
POST/actors/:id/deleteUS-A5
GET/filmsUS-B1
GET/films/newUS-B2
POST/filmsUS-B2
GET/films/:idUS-B3
GET/films/:id/editUS-B4
POST/films/:id/updateUS-B4
POST/films/:id/deleteUS-B5
Non-functional & Randvoorwaarden
  • NF-01 Modulariteit — Gelaagde architectuur (routes → controllers → services → repositories), geen cross-layer afhankelijkheden.
  • NF-02 Onderhoudbaarheid — DRY: geen duplicatie van SQL/logic; herbruikbare helpers.
  • RV-01 JavaScript + MySQL.
  • RV-02 SSR met EJS.
  • RV-03 Bootstrap-achtig CSS (custom theme).
  • RV-04 Open-source waar mogelijk; RV-05 Geen ORM (handgeschreven SQL via npm-package);
  • RV-06 Alleen callbacks (geen async/await/Promises) in DB-laag; RV-07 About-pagina (deze) met user-stories & acceptatiecriteria.
How to test (instructor)
  1. Open /actors en verifieer search en pagination (US-A1).
  2. Maak een nieuwe actor via /actors/new (US-A2); valideer lege invoer.
  3. Open details, pas aan (US-A3/US-A4); probeer te verwijderen (US-A5).
  4. Bezoek /films; filter op titel/categorie en pagina’s (US-B1).
  5. Maak een film met cast (US-B2); controleer details en bewerken (US-B3/US-B4); verwijder (US-B5).
  6. (Optioneel) /me/rentals toont historie voor ingelogde gebruiker (Epic C).