Skip to content

The Simple Store API is a RESTful API built with Laravel, designed to manage a simple e-commerce platform. It supports user authentication, product management, cart functionality, order processing, and more. The API allows developers to create applications that interact with the e-commerce data effectively.

Notifications You must be signed in to change notification settings

Ziad-Abaza/simple-store-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Store API

Overview

The Simple Store API is a RESTful API built with Laravel, designed to manage a simple e-commerce platform. It supports user authentication, product management, cart functionality, order processing, and more. The API allows developers to create applications that interact with the e-commerce data effectively.

Features

  • User Authentication: Using Laravel Sanctum for API token management.
  • Product Management: CRUD operations for products, including categories and details.
  • Cart Management: Add, update, and delete items from the shopping cart.
  • Order Processing: Handle orders and their details.
  • Favorites Management: Save products to favorites for quick access.
  • Comment System: Users can leave comments on products.
  • Notifications: Send and manage user notifications.

Figma Design

For a more detailed view of the UI design for the app, you can check out the Figma prototype here: Shoes App Design


Interface Image

Shoes App Interface


Requirements

  • PHP >= 8.1
  • Laravel Framework 10.x
  • MySQL (or any other database supported by Laravel)

Installation

Clone the Repository

git clone https://github.com/Ziad-Abaza/simple-store-api.git
cd simple-store-api

Install Dependencies

Make sure you have Composer installed. Then run:

composer install

Environment Configuration

  1. Copy the .env.example file to .env:

    cp .env.example .env
  2. Update the .env file with your database and application configurations:

    APP_NAME=Laravel
    APP_ENV=local
    APP_KEY=base64:YOUR_APP_KEY
    APP_DEBUG=true
    APP_URL=http://localhost:8000
    
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=ecommerce
    DB_USERNAME=root
    DB_PASSWORD=

Generate Application Key

Run the following command to generate the application key:

php artisan key:generate

Run Migrations

Run the migrations to create the necessary database tables:

php artisan migrate

Start the Development Server

Start the Laravel development server:

php artisan serve

The API will be accessible at http://localhost:8000.

API Documentation

Authentication

  • Register User: POST /api/register
  • Login User: POST /api/login
  • Logout User: POST /api/logout

Products

  • List Products: GET /api/products
  • Create Product: POST /api/products
  • Show Product: GET /api/products/{id}
  • Update Product: POST /api/products/{id}
  • Delete Product: DELETE /api/products/{id}

Cart

  • View Cart: GET /api/cart
  • Add to Cart: POST /api/cart
  • Update Cart Item: POST /api/cart/{id}
  • Remove from Cart: DELETE /api/cart/{id}

Orders

  • List Orders: GET /api/order-details
  • Create Order: POST /api/order-details
  • Show Order: GET /api/order-details/{id}
  • Update Order: POST /api/order-details/{id}
  • Delete Order: DELETE /api/order-details/{id}

Favorites

  • List Favorites: GET /api/favorite
  • Add to Favorites: POST /api/favorite
  • Remove from Favorites: DELETE /api/favorite/{id}

Comments

  • List Comments: GET /api/comment
  • Add Comment: POST /api/comment
  • Update Comment: POST /api/comment/{id}
  • Delete Comment: DELETE /api/comment/{id}

API Documentation

Authentication

Feature Endpoint Method Request Body Response
Register /api/register POST { "name": "John Doe", "email": "john@example.com", "password": "123456", "password_confirmation": "123456" } { "token": "your_token_here" }
Login /api/login POST { "email": "john@example.com", "password": "123456" } { "token": "your_token_here" }
Logout /api/logout POST { "token": "Bearer your_token_here" } { "message": "Logged out successfully" }

User Profile

Feature Endpoint Method Request Body Response
Get Profile /api/profile GET {} { "name": "John Doe", "email": "john@example.com", "phone": "123456789" }
Update Profile /api/profile/{id} POST { "name": "John Doe", "email": "john@example.com", "phone": "987654321" } { "message": "Profile updated successfully" }
Delete Profile /api/profile/{id} DELETE {} { "message": "User account deleted successfully" }

Products

Feature Endpoint Method Request Body Response
List Products /api/products GET {} [ { "id": 1, "name": "Shoes", "price": 50 } ]
Create Product /api/products POST { "product_name": "Shoes", "price": 50 } { "message": "Product created successfully" }
Show Product /api/products/{id} GET {} { "id": 1, "name": "Shoes", "price": 50 }
Update Product /api/products/{id} POST { "product_name": "New Shoes", "price": 60 } { "message": "Product updated successfully" }
Delete Product /api/products/{id} DELETE {} { "message": "Product deleted successfully" }

Cart

Feature Endpoint Method Request Body Response
View Cart /api/cart GET {} [ { "id": 1, "product": "Shoes", "quantity": 2 } ]
Add to Cart /api/cart POST { "product_id": 1, "quantity": 2 } { "message": "Item added to cart" }
Update Cart Item /api/cart/{id} POST { "quantity": 3 } { "message": "Cart updated" }
Remove from Cart /api/cart/{id} DELETE {} { "message": "Item removed from cart" }

Orders

Feature Endpoint Method Request Body Response
List Orders /api/order-details GET {} [ { "id": 1, "total": 100 } ]
Create Order /api/order-details POST { "cart_id": 1, "shipping_address": "123 Street" } { "message": "Order placed successfully" }
Show Order /api/order-details/{id} GET {} { "id": 1, "total": 100, "status": "Shipped" }
Update Order /api/order-details/{id} POST { "status": "Delivered" } { "message": "Order updated successfully" }
Delete Order /api/order-details/{id} DELETE {} { "message": "Order deleted" }

Favorites

Feature Endpoint Method Request Body Response
List Favorites /api/favorite GET {} [ { "id": 1, "product": "Shoes" } ]
Add to Favorites /api/favorite POST { "product_id": 1 } { "message": "Added to favorites" }
Remove from Favorites /api/favorite/{id} DELETE {} { "message": "Removed from favorites" }

Comments

Feature Endpoint Method Request Body Response
List Comments /api/comment GET {} [ { "id": 1, "comment": "Great product!" } ]
Add Comment /api/comment POST { "product_id": 1, "comment": "Awesome!" } { "message": "Comment added successfully" }
Update Comment /api/comment/{id} POST { "comment": "Updated review" } { "message": "Comment updated successfully" }
Delete Comment /api/comment/{id} DELETE {} { "message": "Comment deleted successfully" }

Notifications

Feature Endpoint Method Request Body Response
List Notifications /api/notification GET {} [ { "id": 1, "title": "New Offer", "message": "50% off on shoes" } ]
Add Notification /api/notification POST { "title": "Discount", "message": "Limited time offer!" } { "message": "Notification added successfully" }
Clear All Notifications /api/notification/clear-all DELETE {} { "message": "All notifications cleared" }

Vendor Management

Feature Endpoint Method Request Body Response
List Vendors /api/vendor GET {} [ { "id": 1, "name": "Best Shoes" } ]
Create Vendor /api/vendor POST { "name": "Best Shoes", "email": "vendor@example.com" } { "message": "Vendor created successfully" }
Update Vendor /api/vendor/{id} POST { "name": "Updated Vendor" } { "message": "Vendor updated successfully" }
Delete Vendor /api/vendor/{id} DELETE {} { "message": "Vendor deleted successfully" }

About

The Simple Store API is a RESTful API built with Laravel, designed to manage a simple e-commerce platform. It supports user authentication, product management, cart functionality, order processing, and more. The API allows developers to create applications that interact with the e-commerce data effectively.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages