https://github.com/hoaian2/tech-store
Yo, this is demo version for my system design class
https://github.com/hoaian2/tech-store
mysql mysql2 nodejs online-shop
Last synced: 7 months ago
JSON representation
Yo, this is demo version for my system design class
- Host: GitHub
- URL: https://github.com/hoaian2/tech-store
- Owner: HOAIAN2
- Created: 2023-01-15T08:07:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-12T10:13:58.000Z (over 2 years ago)
- Last Synced: 2025-01-14T14:27:22.741Z (9 months ago)
- Topics: mysql, mysql2, nodejs, online-shop
- Language: JavaScript
- Homepage:
- Size: 35.3 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tech-store
## Prerequisites
- Nodejs v 18.11.0 or later (yarn or npm)
- MySQL
## Installation
- `git clone https://github.com/HOAIAN2/tech-store.git`
- `cd tech-store`
- Run `prepare.bat` to generate .env file and install libs for server and client.
- `yarn start` or `npm start`
## Build
- Run `build.bat` to build ReactJS and start server
## Database Diagram

## API
### User routes: /api/user/
>[GET] /: JWT require
- Response
``` json
{
"username": "username",
"firstName": "first name",
"lastName": "last name",
"birthDate": "2023-02-09T01:18:02.135Z",
"sex": "M",
"address": "province, city, etc",
"email": "username@email.com", // NULLABLE
"phoneNumber": "+84....", // phone number in Vietnam, CHAR(12) NULLABLE
}
```
### Auth routes: /api/auth/
>[POST] login
- Request
```json
{
"username": "username",
"password": "password"
}
```
- Response
```json
{
"accessToken": "string",
"refreshToken": "string"
}
```
>[POST] logout: JWT require
- Request
```json
{
"refreshToken": "string"
}
```
- Response
```json
{
"message": "message"
}
```
>[POST] change-password: JWT require
- Request
```json
{
"oldPassword": "string",
"newPassword": "string",
"refreshToken": "string"
}
```
- Response
>[POST] register
- Request
```json
{
"username": "username",
"firstName": "first name",
"lastName": "last name",
"birthDate": "2023-02-09T01:18:02.135Z",
"sex": "M",
"address": "province, city, etc",
"email": "username@email.com", // NULLABLE
"phoneNumber": "+84....", // phone number in Vietnam, CHAR(12) NULLABLE
"password": "password"
}
```
- Response
```json
{
"accessToken": "string",
"refreshToken": "string"
}
```
>[POST] refresh
- Request
```json
{
"refreshToken": "string"
}
```
- Response
```json
{
"message": "message"
}
```
>[POST] edit: JWT require
- Request
```json
{
"username": "username",
"firstName": "first name",
"lastName": "last name",
"birthDate": "2023-02-09T01:18:02.135Z",
"sex": "M",
"address": "province, city, etc",
"email": "username@email.com", // NULLABLE
"phoneNumber": "+84....", // phone number in Vietnam, CHAR(12) NULLABLE
}
```
- Response
>[POST] upload
- Request: formData(file: yourImage) (accept: png, jpeg, jpg)
- Response: HTTP status code
### Product routes: /api/products/
>[GET]
- Response
```json
{
"category": [
{
"productID": 1,
"productName": "string",
"supplier": "string",
"category": "string",
"price": 100000,
"discount": null,
"images": ["string"],
"description": null
}
]
}
```
>[GET] product?id=number
- Response
```json
{
"productID": 1,
"productName": "string",
"supplier": "string",
"category": "string",
"price": 100000,
"discount": null,
"images": ["string"],
"description": null
}
```
>[GET] suppliers-categories
- Response
```json
{
"categories": [
"category"
],
"suppliers": [
"supplier"
]
}
```
>[GET] search
- Request: query params
- _name_ : product name
- Response
- _less_
```json
[
{
"productID": 1,
"productName": "string",
"price": 100000,
"discount": null,
"images": ["string"],
}
]
```
>[GET] search-more
- _more_
- _sortBy_: price, hot, top-sell
- _star_: 1->5
- _brand_
- _address_
- _sortMode_: asc, desc
- _indexToStart_:
```json
{
"index": 5,
"data": [
{
"productID": 1,
"productName": "string",
"supplier": "string",
"category": "string",
"price": 100000,
"discount": null,
"images": ["string"],
"description": null
}
]
}
```
>[POST] add-product: JWT require (token admin)
- Request
- form data: only send String so server gonna parse data type
```json
{
"productName": "string",
"supplier": "string",
"category": "string",
"price": "100000",
"quantity": "100",
"description": ""
}
```
- images "files": accept: jpeg, jpg, png, =< 500kbs
- Response
```json
{
"productID": 1,
"productName": "string",
"supplier": "string",
"category": "string",
"price": 100000,
"discount": null,
"images": ["string"],
"description": null
}
```
### Order routes: /api/order/
>[POST] create-order: JWT require
- Request
- Response
```json
{
"orderID": 1,
"userID": 1,
"orderDate": null,
"paidMethod": null,
"paid": false,
"products": [
{
"productID": 3,
"productName": "Laptop Lenovo IdeaPad Gaming 3 15IHU6 82K100FBVN (Core i7-11370H/8GB RAM/512GB SSD/15.6-in - Hàng chính hãng",
"quantity": 6
}
],
"total": 0,
"voucher": null
}
```
>[POST] add-product, remove-product (Same input output) JWT require
- Request
```json
{
"productID": 1,
"quantity": 2
}
```
- Response
```json
{
"orderID": 1,
"userID": 1,
"orderDate": null,
"paidMethod": null,
"paid": false,
"products": [
{
"productID": 3,
"productName": "Laptop Lenovo IdeaPad Gaming 3 15IHU6 82K100FBVN (Core i7-11370H/8GB RAM/512GB SSD/15.6-in - Hàng chính hãng",
"quantity": 6
},
{
"productID": 4,
"productName": "Laptop Acer Nitro 5 AN515-45-R6EV R5-5600H |8GB|512GB|GTX 1650 4GB|156 FHD 144Hz|Win 11 Hàng chính hãng",
"quantity": 3
},
{
"productID": 7,
"productName": "Laptop Lenovo Legion 5 15IAH7 82RC003WVN |i5-12500H|8GB|512GB|RTX 3050 Ti|Win11- Hàng chính hãng",
"quantity": 3
}
],
"total": 0,
"voucher": null
}
```
>[POST] make-payment: JWT require
- Request
```json
{
"paymentMethod": 1
}
```
- Response
```json
{
"orderID": 1,
"userID": 1,
"orderDate": "2023-04-21T11:28:22.000Z",
"paidMethod": "Electronic bank transfers",
"paid": true,
"products": [
{
"productID": 4,
"productName": "Laptop Acer Nitro 5 AN515-45-R6EV R5-5600H |8GB|512GB|GTX 1650 4GB|156 FHD 144Hz|Win 11 Hàng chính hãng",
"quantity": 3,
"price": 18790000,
"discount": null
},
{
"productID": 7,
"productName": "Laptop Lenovo Legion 5 15IAH7 82RC003WVN |i5-12500H|8GB|512GB|RTX 3050 Ti|Win11- Hàng chính hãng",
"quantity": 3,
"price": 32150400,
"discount": null
}
],
"total": 152821200,
"voucher": null
}
```
>[POST] set-voucher JWT require
- Request
```json
{
"voucherID": "string"
}
```
- Response
```json
{
"orderID": 1,
"userID": 1,
"orderDate": null,
"paidMethod": null,
"paid": 0,
"products": [
{
"productID": 3,
"productName": "Laptop Lenovo IdeaPad Gaming 3 15IHU6 82K100FBVN (Core i7-11370H/8GB RAM/512GB SSD/15.6-in - Hàng chính hãng",
"quantity": 6
},
{
"productID": 4,
"productName": "Laptop Acer Nitro 5 AN515-45-R6EV R5-5600H |8GB|512GB|GTX 1650 4GB|156 FHD 144Hz|Win 11 Hàng chính hãng",
"quantity": 3
},
{
"productID": 7,
"productName": "Laptop Lenovo Legion 5 15IAH7 82RC003WVN |i5-12500H|8GB|512GB|RTX 3050 Ti|Win11- Hàng chính hãng",
"quantity": 3
}
],
"total": 0,
"voucher": {
"voucherID": "string",
"voucherName": "string",
"voucherDiscount": 0.2,
"expiryDate": "date time",
"description": "date"
}
}
```
### Comment routes: /api/comment/
>[GET] ?productID=1&sortMode=DESC
- Respone
```json
[
{
"commentID":1,
"userID": 1,
"avatar":"1682648528080-hoaian_admin.jpeg",
"userFirstName":"Hoài Ân",
"userLastName":"Lê",
"productID":1,
"comment":"test comment xem nó hiển thị ra sao\n:))))))))",
"rate":null,
"commentDate":"2023-04-27T17:00:00.000Z"
}
]
```
>[POST] /:id JWT require
- Request
```json
{
"content": "string"
}
```
>[DELETE] / JWT require
- Request: ?commentID?productID
- Respone: HTTP status code
### Rating routes: /api/rating/
>[GET] /:productID JWT require
- Respone
```json
{
"rate": 3
}
```
>[POST] JWT require
- Request
```json
{
"productID": 1,
"rate": 3
}
```