The Project Scope & Architecture
This project is a full-featured, scalable e-commerce engine designed from scratch using the Model-View-Controller (MVC) design pattern in pure PHP and MySQL.
Delivering a blazing-fast user shopping experience while providing store administrators with an intuitive backend to manage inventory and orders.
Security-First Database & Session Management
- SQL Injection Prevention: 100% of database queries utilize PDO prepared statements with strict parameter type binding.
- Authentication & Hashing: Passwords encrypted using industry-standard
PASSWORD_BCRYPTalgorithms. - CSRF & XSS Protection: Cryptographically generated per-session CSRF tokens validated on all state-changing POST requests.
- Role-Based Access Control: Granular separation between customers and administrative staff.
Architectural Code Snippet (PDO Transactions)
// Transactional Checkout Controller
public function processOrder(int $userId, array $cartItems, float $total): int {
$this->db->beginTransaction();
try {
$stmt = $this->db->prepare("INSERT INTO orders (user_id, total, status) VALUES (?, ?, 'pending')");
$stmt->execute([$userId, $total]);
$orderId = (int)$this->db->lastInsertId();
$itemStmt = $this->db->prepare("INSERT INTO order_items (order_id, product_id, qty, unit_price) VALUES (?, ?, ?, ?)");
$stockStmt = $this->db->prepare("UPDATE products SET stock = stock - ? WHERE id = ? AND stock >= ?");
foreach ($cartItems as $item) {
$stockStmt->execute([$item['qty'], $item['id'], $item['qty']]);
if ($stockStmt->rowCount() === 0) {
throw new Exception("Insufficient stock for product ID " . $item['id']);
}
$itemStmt->execute([$orderId, $item['id'], $item['qty'], $item['price']]);
}
$this->db->commit();
return $orderId;
} catch (Exception $e) {
$this->db->rollBack();
throw $e;
}
}
Features & User Experience
- AJAX-Powered Cart: Add, remove, and adjust item counts without full page reloads.
- Faceted Filtering: Filter by categories, price ranges, brand, and in-stock availability instantly.
- Admin Dashboard: Real-time sales charts, pending order badges, and customer management.
Conclusion
Demonstrates how high performance, ironclad security, and elegant user experience can be achieved without relying on bulky external dependencies.