How pxldigital/1eai-webtech-eindopdracht-rizzlers-matteo-dries-1 works
1. Overall shape
FilmTracker is a small, request-driven PHP monolith: each major feature is exposed as its own .php entrypoint, with shared state coming from PostgreSQL and shared session/auth behavior across pages.
2. Core runtime boundaries
The app runs on Apache/PHP 8+ and uses a single database connection file (db.php) plus shared styling (style.css). There is no separate application server, queue, or background worker layer.
3. Authentication and user boundary
register.php, login.php, and logout.php form the identity boundary. They create and use the logged-in user session that gates access to watchlist, reviews, stats, and export behavior.
4. Film management subsystem
search.php, watchlist.php, and film-detail.php are the film-centric workflows. They let a user search movies/series via the TMDB API, add items to a personal watchlist, update status/rating/review, and view detailed film data.
5. Statistics and reporting subsystem
stats.php is the analytics/reporting page. It aggregates watchlist data per user, renders charts in the browser, and also doubles as a lightweight REST-style JSON endpoint for external clients via ?api=1.
6. Export subsystem
export.php generates a PDF export of the user’s watchlist using the bundled FPDF library. This is the main “document generation” boundary in the repository.
7. Persistence model
The data model is simple and centered on two tables: users and watchlist. users holds account identity and credentials; watchlist stores per-user film records including TMDB ID, title, poster, status, rating, review, and timestamps.
8. Data flow for film search
A typical flow is: browser searches in search.php → PHP calls TMDB → results are shown client-side → selected film is inserted into watchlist in PostgreSQL. This is the main integration path between the external movie service and local persistence.
9. Data flow for watchlist updates
watchlist.php acts as the user’s control panel for changing item state. Updates such as status changes, deletions, and rating/review edits are persisted server-side and usually reflected back through Ajax-driven UI updates.
10. Client-side interaction layer
The front end uses jQuery 3.7 for Ajax and DOM updates, plus custom JavaScript for features like debounce, star rating, and input escaping. stats.php also uses Chart.js to visualize aggregated data.
11. External-device/API boundaries
The repo exposes two small integration points for non-browser clients:
- search.php supports action=remote_add to add a film via POST
- stats.php?api=1&user_id=... returns summary statistics as JSON
These are the only explicit API-style endpoints in an otherwise page-based app.
12. Vendored dependency boundary
The fpdf/ directory is a vendored third-party library, not core app logic. It contributes the PDF generation capability and should be treated as an external dependency boundary in any architecture diagram.
13. Practical architecture summary
The cleanest diagram is: browser/UI → PHP page/controller → shared session/db layer → PostgreSQL, with side integrations to TMDB for film metadata and to FPDF/Chart.js/jQuery for export and interactive UI/reporting.
Main entry points: stats.php Stats · style.css Styles · search.php Search · export.php Export PDF
Components 21
Page layer
Browser-facing PHP entrypoints and client-side interaction surfaces.
- Home · Landing page for the app.
index.php - Register · Creates new user accounts and initializes identity state.
register.php - Login · Authenticates users and establishes the session.
login.php - Logout · Ends the current user session.
logout.php - Search · Searches TMDB and adds selected titles to the watchlist.
search.php - Watchlist · Lets users review and update saved films.
watchlist.php - Film detail · Shows detailed information for a film record.
film-detail.php - Stats · Aggregates watchlist data and serves chart data and JSON summaries.
stats.php - Export PDF · Generates a PDF export of the user's watchlist.
export.php
App core
Shared runtime, session, and data access logic used across pages.
Persistence
Local PostgreSQL-backed tables and the data they store.
- Watchlist data · Per-user film records with status, rating, review, and timestamps.
- Users table · Stores account identity and credentials.
- Watchlist table · Stores saved films and per-user metadata.
- PostgreSQL · Primary persistent datastore for users and watchlist records.
External services
Third-party APIs and vendored libraries integrated by the app.
- TMDB API · Remote movie metadata source used by search and detail flows.
- jQuery · Provides Ajax requests and DOM updates in the browser.
- Chart.js · Renders statistics visualizations in the stats page.
- FPDF · Vendored library used to generate PDF exports.
fpdf/fpdf.php
Other components
- Browser · User-facing UI that loads pages, submits forms, and triggers Ajax updates.
Connections 32
- Browser → Home: open · User loads the landing page.
- Browser → Register: submit · User creates an account.
- Browser → Login: submit · User signs in.
- Browser → Logout: submit · User ends the session.
- Browser → Search: search/add · User searches films and adds selected results.
- Browser → Watchlist: manage · User edits saved films.
- Browser → Film detail: view · User opens a detailed film page.
- Browser → Stats: inspect · User views aggregated stats and charts.
- Browser → Export PDF: download · User requests a PDF export.
- Register → DB layer: persist user · Stores new account data.
- Login → DB layer: check creds · Verifies login against stored users.
- Logout → Session auth: clear · Ends the authenticated session.
- Search → TMDB API: query · Fetches movie metadata from TMDB.
- Search → Watchlist table: insert · Adds selected titles to the user's watchlist.
- Watchlist → Watchlist table: update · Edits status, rating, review, and deletions.
- Film detail → TMDB API: fetch · Loads remote film details.
- Stats → Watchlist table: aggregate · Summarizes watchlist data per user.
- Stats → Chart.js: render · Draws charts in the browser.
- Stats → PostgreSQL: query · Reads stored records for statistics and API output.
- Export PDF → FPDF: generate · Builds the PDF document.
- Export PDF → Watchlist table: read · Collects items to export.
- DB layer → PostgreSQL: connect · Provides the shared database connection.
- Watchlist data → Users table: belongs to · Watchlist records are scoped to a user.
- Watchlist data → Watchlist table: stored in · Film records live in the watchlist table.
- Session auth → Login: establishes · Login creates the authenticated session.
- Session auth → Watchlist: guards · Authenticated session gates watchlist access.
- Session auth → Stats: guards · Authenticated session gates stats access.
- Session auth → Export PDF: guards · Authenticated session gates export access.
- Styles → Home: styles · Shared visual styling for the app pages.
- Styles → Search: styles · Shared visual styling for the app pages.
- Styles → Watchlist: styles · Shared visual styling for the app pages.
- Styles → Stats: styles · Shared visual styling for the app pages.