An online marketplace that allows users to buy and sell products. Users can register for an account, browse products, add products to their cart, and checkout using a payment gateway. Sellers can create and manage their own product listings, including setting the price, description, and uploading product images. Admins can manage user accounts, product listings, and orders.
- User registration and login with password hashing
- User roles: buyer, seller, and admin
- Sellers can create and manage their own product listings
- Product listings include title, description, price, category, and images
- Users can browse products by category and search for products by keyword
- Users can add products to their cart and checkout using a payment gateway (e.g., PayPal)
- Orders are tracked and stored in a database
- Admins can manage user accounts, product listings, and orders
- Proper use of security measures, such as input validation, SQL injection prevention, and CSRF protection
- Efficient use of caching mechanisms, such as Redis or Memcached, to improve performance
- Use of an MVC architecture (Not Laravel or CodeIgniter)
POST /api/login: Authenticate user and generate access token
{
"JWT_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"email": "ali@gmail.com",
"password": "$2y$10$ChXlwPFkN6U/YCTQikrYeu4pRlxx6ZLe.mj0mKwkQC/UJLjfYMsZa"
}POST /api/register: Register a new user account
{
"id": 1,
"name": "ali",
"email": "ali@gmail.com",
"password": "$2y$10$ChXlwPFkN6U/YCTQikrYeu4pRlxx6ZLe.mj0mKwkQC/UJLjfYMsZa",
"remember_token": "sskjdh2fudn1"
}GET /api/products: Retrieve all productsGET /api/products/{id}: Retrieve a specific product by IDPOST /api/products: Create a new product listingPUT /api/products/{id}: Update a product listingDELETE /api/products/{id}: Delete a product listing
GET /api/orders: Retrieve all ordersGET /api/orders/{id}: Retrieve a specific order by IDPOST /api/orders: Create a new orderPUT /api/orders/{id}: Update an existing orderDELETE /api/orders/{id}: Delete an order
GET /api/users: Retrieve all usersGET /api/users/{id}: Retrieve a specific user by IDPUT /api/users/{id}: Update a user accountDELETE /api/users/{id}: Delete a user account
GET /api/categories: Retrieve all categoriesGET /api/categories/{id}: Retrieve a specific category by IDPOST /api/categories: Create a new categoryPUT /api/categories/{id}: Update a categoryDELETE /api/categories/{id}: Delete a category
POST /api/payments: Process payment using payment gateway (With a good structure that allows us to add more gateways in the future)
Example Response:
{
"payment_uri": "https://nextpay.org/nx/gateway/payment/267a5387-af3a-4063-8d41-87df73f38f60",
"trans_id": "267a5387-af3a-4063-8d41-87df73f38f60"
}Note: This is just an example, and you may need to modify the routes and methods based on the specific requirements.
id: int (primary key)name: varchar(255)email: varchar(255)password: varchar(255)remember_token: varchar(100)role: enum('buyer', 'seller', 'admin')created_at: timestampupdated_at: timestamp
id: int (primary key)name: varchar(255)created_at: timestampupdated_at: timestamp
id: int (primary key)title: varchar(255)description: textprice: decimal(8,2)category_id: int (foreign key to Categories table)seller_id: int (foreign key to Users table)created_at: timestampupdated_at: timestamp
id: int (primary key)buyer_id: int (foreign key to Users table)product_id: int (foreign key to Products table)quantity: intamount: decimal(8,2)status: enum('pending', 'completed', 'cancelled')created_at: timestampupdated_at: timestamp
id: int (primary key)order_id: int (foreign key to Orders table)amount: decimal(8,2)status: enum('pending', 'completed', 'failed')payment_gateway: varchar(255)transaction_id: varchar(255)created_at: timestampupdated_at: timestamp
- Correctness and completeness of the implementation
- Efficient use of caching mechanisms
- Proper use of security measures
- Clean and maintainable code
- Proper use of error handling and logging
- Good coding practices, such as adherence to coding standards and proper documentation
First step, You need to clone this repository from GitHub to your local environment:
git clone https://github.com/BaseMax/OnlineMarketplacePHP.gitNow you must run some command to install dependecies and create .env file:
composer installcp .env.example .envNow open .env file and fill the things that are needed.
Navigate to public folder and run below command to start serving on the localhost:
php -S localhost:5000- Ali Ahmadi
- Max Base
Copyright 2023, Max Base