[Full e-commerce flow — Frontend API Contract] This document lists every backend API endpoint consumed by the frontend application.
| Variable | Location | Default |
|---|---|---|
NEXT_PUBLIC_API_URL |
.env.local |
https://api.example.com |
All requests are made through the centralized Axios instance.
Source: src/services/axiosInstance.ts
All protected routes require a Bearer token:
Authorization: Bearer <token>
Token is read automatically from localStorage via the Axios request interceptor.
Source: src/store/slices/authSlice.ts
| Field | Value |
|---|---|
| Endpoint | /auth/login |
| Method | POST |
Request Body:
| Field | Type | Notes |
|---|---|---|
identifier |
string |
Email or phone number |
password |
string |
User's password |
Expected Response:
{ "token": "string", "user": { ... } }| Field | Value |
|---|---|
| Endpoint | /auth/register |
| Method | POST |
Request Body:
| Field | Type | Notes |
|---|---|---|
name |
string |
Full name |
email |
string |
Email address |
phone |
string |
Mobile number |
password |
string |
Should be min 6 chars |
Expected Response:
{ "token": "string", "user": { ... } }| Field | Value |
|---|---|
| Endpoint | /auth/forgot-password |
| Method | POST |
Request Body:
| Field | Type | Notes |
|---|---|---|
email |
string |
Email or phone number used at registration |
| Field | Value |
|---|---|
| Endpoint | /auth/verify-otp |
| Method | POST |
Request Body:
| Field | Type | Notes |
|---|---|---|
email |
string |
Email or phone used for OTP request |
otp |
string |
6-digit one-time password |
| Field | Value |
|---|---|
| Endpoint | /auth/reset-password |
| Method | POST |
Request Body:
| Field | Type | Notes |
|---|---|---|
email |
string |
User's email/phone |
otp |
string |
6-digit verified OTP |
newPassword |
string |
New password, min 6 chars |
Source: src/store/slices/userSlice.ts
| Field | Value |
|---|---|
| Endpoint | /user/profile |
| Method | GET |
| Auth Required | ✅ Yes (Bearer token) |
No request body. Returns the logged-in user's profile data.
| Field | Value |
|---|---|
| Endpoint | /user/profile |
| Method | PUT |
| Auth Required | ✅ Yes (Bearer token) |
Request Body:
| Field | Type | Notes |
|---|---|---|
name |
string |
(optional) Updated full name |
email |
string |
(optional) Updated email |
phone |
string |
(optional) Updated phone number |
avatar |
string |
(optional) Profile image URL |
Source: src/store/slices/productSlice.ts
| Field | Value |
|---|---|
| Endpoint | /products |
| Method | GET |
Query Parameters:
| Param | Type | Notes |
|---|---|---|
?category |
string |
(optional) Filter by category slug (e.g. panjabi, t-shirt) |
?search |
string |
(optional) Search keyword to filter by product name |
Example: GET /products?category=panjabi&search=eid
| Field | Value |
|---|---|
| Endpoint | /products/:id |
| Method | GET |
Path Parameters:
| Param | Type | Notes |
|---|---|---|
:id |
string |
Unique product ID or slug |
Source: src/store/slices/orderSlice.ts
| Field | Value |
|---|---|
| Endpoint | /orders |
| Method | POST |
| Auth Required | ✅ Yes (Bearer token) |
Request Body (orderData object):
| Field | Type | Notes |
|---|---|---|
items |
array |
Cart items — each with productId, name, size, quantity, price |
shippingAddress |
object |
firstName, lastName, streetAddress, city, district, phone, email |
shippingCost |
number |
60 (inside Dhaka) or 120 (outside Dhaka) |
totalPrice |
number |
Subtotal + shippingCost |
paymentMethod |
string |
e.g. "cash_on_delivery" |
notes |
string |
(optional) Special delivery notes |
| Field | Value |
|---|---|
| Endpoint | /orders |
| Method | GET |
| Auth Required | ✅ Yes (Bearer token) |
Returns an array of the authenticated user's past orders.
| # | Feature | Endpoint | Method | Auth |
|---|---|---|---|---|
| 1 | Login | /auth/login |
POST | ❌ |
| 2 | Register | /auth/register |
POST | ❌ |
| 3 | Forgot Password | /auth/forgot-password |
POST | ❌ |
| 4 | Verify OTP | /auth/verify-otp |
POST | ❌ |
| 5 | Reset Password | /auth/reset-password |
POST | ❌ |
| 6 | Get Profile | /user/profile |
GET | ✅ |
| 7 | Update Profile | /user/profile |
PUT | ✅ |
| 8 | Get Products | /products?category=&search= |
GET | ❌ |
| 9 | Get Single Product | /products/:id |
GET | ❌ |
| 10 | Place Order | /orders |
POST | ✅ |
| 11 | Get Orders | /orders |
GET | ✅ |