Complete_Shopping_API_Spec
Complete_Shopping_API_Spec
Models:
🏬 Store Model
Field Name Data Type Primary Key Foreign Key Comments
id Integer Yes
name String Unique
ownerObj Object User Admin user
location String Optional
👤 User Model
Field Name Data Type Primary Key Foreign Key Comments
id Integer Yes
username String
email String Unique
password String
role String admin or
customer
stores List Stores owned
(if admin)
orders List Orders placed
(if customer)
📦 Product Model
Field Name Data Type Primary Key Foreign Key Comments
id Integer Yes
name String
description Text Optional
price Decimal
availableStock Integer
storeObj Object Store Belongs to
store
🧾 Order Model
Field Name Data Type Primary Key Foreign Key Comments
id Integer Yes
userObj Object User Customer who
placed the
order
orderDate DateTime Default = now
status String Pending /
Shipped /
Delivered
totalAmount Decimal Calculated
🧺 OrderItem Model
Field Name Data Type Primary Key Foreign Key Comments
id Integer Yes
productObj Object Product
orderObj Object Order
quantity Integer
priceAtPurchase Decimal Copied from
product
🧩 API Endpoints
🔐 Authentication
Method Endpoint Description
POST /api/register/ Register a new user
(admin/customer)
POST /api/login/ Login to obtain access token
POST /api/logout/ Logout and revoke token
🏬 Store Endpoints
Method Endpoint Description
GET /api/stores/ List all stores
POST /api/stores/ Create a new store (admin
only)
GET /api/stores/{store_id}/ Retrieve details of a specific
store
PUT /api/stores/{store_id}/ Update store details (admin
only)
DELETE /api/stores/{store_id}/ Delete a store (admin only)
GET /api/my-stores/ List stores owned by the
authenticated admin
📦 Product Endpoints
Method Endpoint Description
GET /api/products/ List all products
GET /api/products/{product_id}/ Get details of a product
POST /api/products/ Add a new product to
store (admin only)
PUT /api/products/{product_id}/ Update product details
(admin only)
DELETE /api/products/{product_id}/ Delete product (admin
only)
GET /api/store-products/{store_id}/ Get all products in a
store
GET /api/search/?q={term} Search products by
keyword
POST /api/products/{product_id}/restock/ Restock inventory
(admin only)
🧾 Order Endpoints
Method Endpoint Description
GET /api/orders/ List all orders (admin or
user)
GET /api/orders/{order_id}/ View details of an order
POST /api/orders/ Create new order (user
only)
PUT /api/orders/{order_id}/status/ Update order status (admin
only)
GET /api/my-orders/ Get orders placed by
authenticated customer
🧺 Cart Endpoints
Method Endpoint Description
GET /api/cart/ Get current cart items
POST /api/cart/add/ Add product to cart
PUT /api/cart/update/ Update cart item quantity
DELETE /api/cart/remove/ Remove item from cart
POST /api/cart/checkout/ Checkout cart and create
order