A modern eCommerce web application built with React (frontend) and PHP with GraphQL (backend). This project demonstrates clean architecture, and OOP principles.
- Product Catalog - Browse products by category (All, Clothes, Tech)
- Product Details - View product images, attributes, and descriptions
- Attribute Selection - Choose size, color, capacity, and other product variants
- Shopping Cart - Add/remove items, adjust quantities, view totals
- Quick Shop - Add in-stock products directly from the listing page
- React 18 with TypeScript
- Vite (build tool)
- Apollo Client (GraphQL)
- React Router DOM
- SCSS for styling
- PHP 8.2 (no frameworks)
- GraphQL (webonyx/graphql-php)
- MySQL/MariaDB
- FastRoute for routing
fullstack-ecommerce/
βββ frontend/ # React application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ context/ # React Context (Cart)
β β βββ graphql/ # GraphQL queries
β β βββ types/ # TypeScript interfaces
β β βββ styles/ # Global styles
β βββ package.json
βββ src/ # PHP backend
β βββ Controller/ # Request handlers
β βββ Database/ # Database connection (Singleton)
β βββ GraphQL/ # Schema and resolvers
β βββ Model/ # Domain models (Abstract classes)
β βββ Repository/ # Data access layer
βββ config/ # Configuration files
βββ database/ # SQL schema and seed data
βββ public/ # Entry point (index.php)
βββ vendor/ # Composer dependencies
- PHP 8.0 or higher
- MySQL/MariaDB
- Node.js 18+ and npm
- Composer
- XAMPP (recommended) or similar local server
-
Clone the repository
git clone https://github.com/ertancurri/fullstack-ecommerce.git cd fullstack-ecommerce -
Install PHP dependencies
composer install
-
Create the database
- Open phpMyAdmin (http://localhost/phpmyadmin)
- Create a new database named
ecommerce_db
-
Run database migrations
- Import
database/schema.sqlto create tables - Import
database/seed.sqlto populate sample data
- Import
-
Configure database connection
- Edit
config/database.phpwith your credentials:
return [ 'host' => 'localhost', 'dbname' => 'ecommerce_db', 'username' => 'root', 'password' => '' ];
- Edit
-
Start the backend server
- Place project in
htdocsfolder (for XAMPP) - Access GraphQL endpoint at:
http://localhost/fullstack-ecommerce/public/graphql
- Place project in
-
Navigate to frontend directory
cd frontend -
Install dependencies
npm install
-
Start development server
npm run dev
-
Open in browser
- Navigate to
http://localhost:5173
- Navigate to
# Get all categories
query {
categories {
name
}
}
# Get products (optionally by category)
query {
products(category: "clothes") {
id
name
brand
inStock
gallery
prices {
amount
currency {
symbol
}
}
attributes {
id
name
type
items {
id
displayValue
value
}
}
}
}
# Get single product
query {
product(id: "huarache-x-stussy-le") {
id
name
description
# ... other fields
}
}# Create an order
mutation {
createOrder(products: ["product-id-1", "product-id-2"])
}- Abstract Classes:
AbstractProductandAbstractAttributeSetfor polymorphism - Factory Pattern:
ProductFactoryandAttributeFactoryfor object creation - Repository Pattern: Separation of data access from business logic
- Singleton Pattern: Database connection management
Product and attribute types are handled through class maps and polymorphism:
private static array $categoryMap = [
'clothes' => ClothesProduct::class,
'tech' => TechProduct::class,
];| Product | Category | Attributes |
|---|---|---|
| Nike Air Huarache Le | Clothes | Size (40-43) |
| Canada Goose Jacket | Clothes | Size (S/M/L/XL) |
| PlayStation 5 | Tech | Color, Capacity |
| Xbox Series S | Tech | Color, Capacity |
| iMac 2021 | Tech | Capacity, USB 3, Touch ID |
| iPhone 12 Pro | Tech | Capacity, Color |
| AirPods Pro | Tech | None |
| AirTag | Tech | None |
- Browse products on the home page
- Filter by category (All, Clothes, Tech)
- Click a product to view details
- Select required attributes
- Add to cart
- View cart overlay
- Adjust quantities or remove items
- Place an order
This project is ready for 100% FREE deployment using:
- Backend: InfinityFree (PHP + MySQL)
- Frontend: Vercel (React + Vite)
- Backend: Sign up at infinityfree.com, upload files, create database
- Frontend: Push to GitHub, deploy to vercel.com
- DEPLOYMENT-SUMMARY.md - Start here! Quick overview and next steps
- QUICK-START-DEPLOYMENT.md - TL;DR deployment steps
- DEPLOYMENT.md - Complete step-by-step guide
- INFINITYFREE-NOTES.md - InfinityFree-specific tips
- DEPLOYMENT-CHECKLIST.md - Track your deployment progress
Total Cost: $0/month π
This project is open source and available for learning purposes.
Ertan Curri
- Portfolio: ertancurri.com
- GitHub: @ertancurri
- LinkedIn: Ertan Curri