How huuhau235/gleamcraft works
Project Type and Purpose
• This is a monolithic, server-rendered PHP web application following an MVC (Model-View-Controller) pattern.
• Purpose: an e-commerce jewelry store with features for browsing products, managing a shopping cart, processing payments, and user administration.
File Structure
• Top-level directories:
• app/controllers – HTTP request handlers (Admin, Cart, Detail, Homepage, Payment, Product, User, Shared)
• app/models – Data models (Admin, CartModel, PaymentModel, ProductsModel, Reviews, UserModel)
• app/views – Templates (organized by feature: aboutUs, admin, brands, cart, collection, detail, homepage, payment, product, shared, user)
• app/core – Framework core (Controller.php, Db.php, app.php, init.php)
• assets – Static files (CSS, JS, images)
• database – SQL schema and migration stubs
• index.php – Single entry point
• composer.json/lock – Dependency management
• .htaccess – URL rewriting
• Patterns:
• MVC separation (controllers → models → views)
• Front controller (index.php + app/core/app.php dispatch requests)
• Static assets served from /assets
README for Additional Insights
• Team workflow notes (branch naming, commits, Bootstrap usage)
a. Client / Browser
– UI in HTML/CSS/JS, served via HTTP.
– Uses Bootstrap and custom CSS/JS under /assets.
b. Web Server / PHP Runtime
– Apache or Nginx with PHP-FPM, invoking index.php.
– .htaccess defines URL rewrites to index.php.
c. Front Controller & Router
– app/init.php and app/core/app.php parse the request URI.
– Maps to the appropriate Controller.
d. Controllers
– app/controllers/*.php handle input, invoke Models, select Views.
e. Models & Database
– app/models/*.php interface with Db.php (MySQL via PDO).
– database/jewelry_store.sql holds schema; migrations in database/migrations.
f. Views / Templating
– app/views/* generate the HTML response using data from Models.
g. Static Asset Delivery
– CSS, JS, Images are served directly or via a CDN link (Bootstrap).
h. External Services
– Payment gateway integration within PaymentController/PaymentModel.
Relationships & Data Flow
• Web Server → Front Controller (index.php).
• Front Controller → Controller classes.
• Controller → Model (calls to Db, queries).
• Model → Database (SQL operations).
• Controller ← Model (data returned).
• Controller → View (rendering).
• View → Browser (HTTP response).
• Browser → Assets (CSS/JS/images).
• Payment flow: Controller → External Payment API → Controller.
Architectural Patterns & Principles
• MVC Separation: group components into distinct layers.
• Single entry-point: index.php as front controller.
• Dependency injection: Db.php config passed into models.
• Configuration externalization: composer.json for dependencies.
• Modularity: separate controllers for each functional area.
Technologies & Frameworks
• PHP 7+ (custom micro-framework in app/core).
• MySQL (or MariaDB) via PDO.
• Bootstrap 5.3 for UI.
• Composer for autoloading.
• Apache/Nginx + .htaccess for URL rewriting.
• Vanilla JS for interactivity.
Final Checklist
• All components included and labeled.
• Annotations for technologies (e.g., “MySQL via PDO”, “Bootstrap 5.3”, “Composer autoload”).