How diegoburgos616/oaw-2025 works
Project type and purpose
• This is a full‐stack, monolithic PHP web application (“RSS Reader”) that runs on XAMPP (Apache + PHP), backed by a MySQL database.
• It uses the SimplePie library to fetch and parse external RSS/Atom feeds, caches feed data, and persists selected items in a local “news” table.
File structure
• Top‐level files
• index.php – main entry point, renders the UI and/or triggers feed loads
• feed_handler.php – back‐end endpoint (possibly for AJAX) for retrieving/parsing feeds
• index.css – front‐end styling
• cache/ – local filesystem cache of feed data (SimplePie generated .spc files)
• test_*.php – utility scripts for debugging and validation
• SimplePie directory (third‐party library)
• autoloader.php & composer.json – PSR-4 autoload setup
• src/ – namespaced PHP classes (SimplePie, HTTP clients, Cache adapters, parsers)
• library/ – legacy code compatibility
• db.sql – sample schema for “news” table
• README.md
• Describes how to set up XAMPP, create the “rss_reader” database & “news” table
• Lists project prerequisites (PHP 7.2+, libxml2, cURL/fsockopen, PCRE, iconv/mbstring/intl)
• Mentions PSR-18 HTTP client support and PSR-16 cache support in SimplePie
README for architectural insights
• The app stores feed items in a MySQL “news” table (fields: id, title, url, description, category, pub_date, source_url, image_url).
• Caching can be handled by SimplePie’s file cache (cache/) or by alternate PSR-16 adapters (e.g., Redis, Memcached).
• HTTP requests to external feeds can go through cURL, fsockopen or any PSR-18 client (Guzzle, etc.).
a. Main components
• Client (Web Browser)
• Web Server (Apache + PHP – XAMPP)
• Application Layer
• index.php (UI + controller)
• feed_handler.php (API endpoint)
• SimplePie Library
• HTTP layer (PSR-18 / cURL)
• Parsing layer (XML analyzers, Date parsers, Content sanitizers)
• Caching layer (FileCache, DBCache, PSR-16 adapters)
• Data Stores
• Cache directory (filesystem)
• MySQL “rss_reader.news” table
• External Services
• RSS/Atom feed providers (HTTP endpoints)
b. Interactions & data flow
1. User → HTTP GET index.php → Web Server
2. index.php loads UI, may fire AJAX to feed_handler.php
3. feed_handler.php calls SimplePie::set_feed_url(...)
4. SimplePie HTTP client → External RSS URL
5. SimplePie Parser → builds in-memory feed objects
6. Before/after parse → Cache adapter reads/writes to cache/ or DB
7. Parsed items → optionally inserted/queried from MySQL “news” table
8. feed_handler.php returns JSON or HTML response → Browser renders
c. Architectural patterns & design principles
• Layered architecture: Presentation (index.php, CSS), Application (feed_handler.php), Integration (SimplePie HTTP + Cache), Data (MySQL, filesystem).
• Dependency Inversion via PSR-18 (HTTP client) and PSR-16 (cache) interfaces.
• Single Responsibility: feed_handler only handles feed retrieval, index.php deals with UI.
• Caching Strategy: reduce external HTTP calls via file or DB cache.
• Monolith: all code runs in one PHP process but uses well-separated modules (namespace + class structure in src/).
d. Key technologies & frameworks
• PHP 7.2+ (XAMPP)
• SimplePie library (PSR‐4 autoloader, HTTP/Parser/Cache classes)
• MySQL (news table)
• PSR-18 HTTP Clients (cURL, Guzzle if configured)
• PSR-16 Cache (file system by default; optional Redis/Memcached)
• Apache (serving PHP scripts)
• Browser UI (HTML/CSS, possible JavaScript in index.php)
Detail
• Key modules in SimplePie (HTTP client, XML parser, Date/IRI handlers, Cache adapters).
• Both filesystem caching (cache/*.spc files) and database caching options.
• Conditional flow: “If cached, skip HTTP; else fetch and store in cache.”
• Don’t forget the MySQL “news” table where parsed items are persisted for later display.