An ecommerce application consisting of a Backend API (PHP) and a Flutter mobile app for customers.
A RESTful API that provides all necessary functions for the ecommerce application.
A Flutter app for customers to interact with the API.
- ✅ Authentication: Login, Sign up, Code verification, Password recovery
- ✅ Products: View products, Search, Categories
- ✅ Shopping Cart: Add, Remove, View products
- ✅ Orders: Create orders, View pending and archived orders
- ✅ Favorites: Add and remove favorite products
- ✅ Addresses: Manage shipping addresses
- ✅ Coupons: Validate coupon codes
- ✅ Promotions: Display promotional offers
ecommerce/
├── address/ # Address management
│ ├── add.php
│ ├── delete.php
│ ├── edit.php
│ └── view.php
├── auth/ # Authentication
│ ├── login.php
│ ├── signup.php
│ └── verfiycode.php
├── cart/ # Shopping cart
│ ├── add.php
│ ├── delete.php
│ ├── getcountitems.php
│ └── view.php
├── categories/ # Categories
│ └── view.php
├── coupon/ # Coupons
│ └── checkcoupon.php
├── favorite/ # Favorites
│ ├── add.php
│ ├── deletefromfavroite.php
│ ├── remove.php
│ └── view.php
├── forgetpassword/ # Password recovery
│ ├── checkemail.php
│ ├── resetpassword.php
│ └── verifycode.php
├── items/ # Products
│ ├── items.php
│ └── search.php
├── orders/ # Orders
│ ├── archive.php
│ ├── checkout.php
│ ├── delete.php
│ ├── details.php
│ └── pending.php
├── connect.php # Database connection
├── functions.php # Helper functions
├── home.php # Home page
├── view.sql # Database file
└── test.php
- PHP 7.4 or higher
- MySQL 5.7 or higher
- Apache/Nginx Web Server
-
Clone the repository
git clone https://github.com/yourusername/ecommerce-app.git cd ecommerce -
Setup Database
- Create a new database
- Import the
view.sqlfile into your database
mysql -u username -p database_name < view.sql
-
Configure Database Connection
- Open
connect.phpfile - Update connection details:
$dsn = "mysql:host=localhost;dbname=your_database_name"; $user = "your_username"; $pass = "your_password";
- Open
-
Setup Upload Directory
- Create an
uploadfolder in the root directory for image uploads
mkdir upload chmod 755 upload
- Create an
POST /auth/signup.php- Register new accountPOST /auth/login.php- User loginPOST /auth/verfiycode.php- Verify code
POST /forgetpassword/checkemail.php- Verify emailPOST /forgetpassword/verifycode.php- Verify recovery codePOST /forgetpassword/resetpassword.php- Reset password
GET /home.php- Home page (Promotions, Categories, Products)GET /categories/view.php- View all categories
GET /items/items.php- View productsGET /items/search.php- Search products
POST /cart/add.php- Add product to cartGET /cart/view.php- View cart contentsPOST /cart/delete.php- Remove product from cartGET /cart/getcountitems.php- Get cart items count
POST /orders/checkout.php- Create new orderGET /orders/pending.php- View pending ordersGET /orders/archive.php- View archived ordersGET /orders/details.php- Order detailsPOST /orders/delete.php- Delete order
POST /favorite/add.php- Add product to favoritesGET /favorite/view.php- View favorite productsPOST /favorite/remove.php- Remove from favoritesPOST /favorite/deletefromfavroite.php- Remove from favorites (alternative)
POST /address/add.php- Add addressGET /address/view.php- View addressesPOST /address/edit.php- Edit addressPOST /address/delete.php- Delete address
POST /coupon/checkcoupon.php- Validate coupon
The project includes ready-to-use helper functions:
filterRequest()- Sanitize input datagetAllData()- Fetch all data from a tablegetData()- Fetch single record from a tableinsertData()- Insert new dataupdateData()- Update datadeleteData()- Delete dataimageUpload()- Upload imagesdeleteFile()- Delete filescheckAuthenticate()- Authentication checkprintSuccess()- Print success messageprintFailure()- Print failure message
All endpoints return JSON responses in a standardized format:
Success:
{
"status": "success",
"data": {...}
}Failure:
{
"status": "failure"
}⚠️ Important: Do not uploadconnect.phpfile to GitHub as it contains sensitive information- Use
.gitignoreto protect sensitive files - Use HTTPS in production
- Enable
checkAuthenticate()in admin files
- All responses are in JSON format
- Database uses UTF-8 encoding
- Uploaded images are limited to 2MB
- Uploaded images are saved in the
upload/folder
This project was developed as part of an Ecommerce course.
This project is for educational purposes.
Note: Make sure to update database credentials in connect.php before use.