58fcae647a606387c6af5ab50aad1ce62b191b2b
HackMyCart
The most hackable Web Shop!
How to use
Prepare development environment
- Install node.js
sudo apt install npm
# If outdated version:
sudo npm install -g n
sudo n stable
- Download + extract the project
- Open the root folder with VS Code (recommended)
- Open the bash inside VS Code, navigate to the
software/folder and install all necessary packages:
npm i
Test/development
There are multiple commands to test parts or the whole project:
npm run dev: Starts the Vue frontend onlynpm run server: Starts the ExpressJs backend onlynpm run serve: Starts front- and backend
The frontend runs on http://localhost:5173/ and the backend on http://localhost:3000/
Compile for production
TODO
Structure
Database
Backend API endpoints
The application host it's data in a SQLite database. The access is managed by an ExpressJs server which offers many REST-API endpoints for the frontend. The REST-API server runs on port 3000.
/api
Server check
Description
Check if server is availableRequest
GET /api
| Parameter | Required? | Description |
|---|---|---|
| - | - | - |
Database reset
Description
Delete and refill the database with example valuesRequest
GET /api/resetdatabase
| Parameter | Required? | Description |
|---|---|---|
| - | - | - |
/categories
All categories
Description
Get all categoriesRequest
GET /categories
| Parameter | Required? | Description |
|---|---|---|
| - | - | - |
Example Response
[
{
"id": 0,
"name": "Electronic",
"icon": "mdi-chip",
"createdAt": "2024-09-13T07:51:40.118Z",
"updatedAt": "2024-09-13T07:51:40.118Z"
},
{
"id": 1,
"name": "Sports",
"icon": "mdi-soccer",
"createdAt": "2024-09-13T07:51:40.118Z",
"updatedAt": "2024-09-13T07:51:40.118Z"
}
]
Add new category
Description
Add a new categoryRequest
POST /categories
| Body Parameters | Required? | Description |
|---|---|---|
name |
Yes | Name of the category |
icon |
Yes | Material Design Icon |
Delete category
Description
Delete a category by it's idRequest
DELETE /categories/:id
| Parameter | Required? | Description |
|---|---|---|
id |
Yes | Database ID of CategoryModel |
/products
All products
Description
Get all productsRequest
GET /products
| Parameter | Required? | Description |
|---|---|---|
| - | - | - |
Example Response
[
{
"id": 0,
"brand": "Lenovo",
"name": "Thinkpad T14",
"categoryId": 0,
"price": 799.99,
"discount": 10,
"rating": 4.6,
"imageUrl": "thinkpad-t14s.jpg",
"description": "Die stabile Arbeitsmaschine. Mit AMD Ryzen 7 89029U, 128 GB RAM und 8 TB M.2 SSD!",
"createdAt": "2024-09-13T07:51:40.119Z",
"updatedAt": "2024-09-13T07:51:40.119Z",
"category": {
"id": 0,
"name": "Electronic",
"icon": "mdi-chip",
"createdAt": "2024-09-13T07:51:40.118Z",
"updatedAt": "2024-09-13T07:51:40.118Z"
}
}
]
Request one product
Description
Get a specific product by it's idRequest
GET /products/:id
| Parameter | Required? | Description |
|---|---|---|
id |
Yes | ID of the product in the database table |
Example Response
{
"id": 0,
"brand": "Lenovo",
"name": "Thinkpad T14",
"categoryId": 0,
"price": 799.99,
"discount": 10,
"rating": 4.6,
"imageUrl": "thinkpad-t14s.jpg",
"description": "Die stabile Arbeitsmaschine. Mit AMD Ryzen 7 89029U, 128 GB RAM und 8 TB M.2 SSD!",
"createdAt": "2024-09-13T07:51:40.119Z",
"updatedAt": "2024-09-13T07:51:40.119Z",
"category": {
"id": 0,
"name": "Electronic",
"icon": "mdi-chip",
"createdAt": "2024-09-13T07:51:40.118Z",
"updatedAt": "2024-09-13T07:51:40.118Z"
}
}
Add new product
Description
Add a new product to the databaseRequest
POST /products
| Body Parameters | Required? | Description |
|---|---|---|
brand |
Yes | Brand of the product |
name |
Yes | Name of the product |
description |
No | Description of the product |
categoryId |
Yes | ID of a Category from database |
price |
No | Name of the product |
discount |
No | Procentual discount, 0 to 100 |
rating |
No | Product rating from 1 to 5 |
imageUrl |
No | Name of the uploaded image file |
Delete product
Description
Delete a product by it's idRequest
DELETE /products/:id
| Parameter | Required? | Description |
|---|---|---|
id |
Yes | Database ID of ProductModel |
/orders
Request orders of user
Description
Get all orders from a userRequest
GET /orders/:id
| Parameter | Required? | Description |
|---|---|---|
id |
Yes | ID of the user in the database table |
Example Response
[
{
"id": 1,
"accountId": 3,
"totalPrice": 7.99,
"shippingProgress": 5,
"createdAt": "2024-09-09T12:24:24.225Z",
"updatedAt": "2024-09-13T07:51:40.120Z",
"orderItem": [
{
"id": 1,
"orderId": 1,
"quantity": 1,
"productId": 6,
"createdAt": "2024-09-13T07:51:40.120Z",
"updatedAt": "2024-09-13T07:51:40.120Z",
"product": {
"id": 6,
"brand": "Aldous Huxley",
"name": "Brave New World",
"categoryId": 3,
"price": 7.99,
"discount": 0,
"rating": 4.4,
"imageUrl": "brave-new-world.jpg",
"description": "Brave New World beschreibt eine genormte Gesellschaft, in der Föten genetisch manipuliert und Menschen konditioniert werden. Ziel des Staates ist Zufriedenheit und Stabilität, und dies wird durch Gleichheit, Drogen und Propaganda erreicht. Gott und Religion...",
"createdAt": "2024-09-13T07:51:40.119Z",
"updatedAt": "2024-09-13T07:51:40.119Z"
}
}
]
}
]
Place a new order
Description
Place a new order to the databaseRequest
POST /orders
| Query Parameters | Required? | Description |
|---|---|---|
accountId |
Yes | ID of account who created this order |
shippingProgress |
No | Progress of shipping, 1 to 5 |
orderItem |
Yes | List of ordered items (objects). Needs parameter quantity and productId |
/accounts
Login user
Description
Login process for userRequest
GET /accounts
| Query Parameters | Required? | Description |
|---|---|---|
username |
Yes | Name of user account |
password |
Yes | Password of user account |
Example Response
{
"loginSuccessful": true,
"userId": 3,
"message": ""
}
Add an user
Description
Place a new account to the databaseRequest
POST /accounts
| Body Parameters | Required? | Description |
|---|---|---|
username |
Yes | Login username |
password |
Yes | Login password |
firstName |
No | First name of user |
lastName |
No | Last name of user |
street |
No | Street where the user lives |
houseNumber |
No | House number of user |
postalCode |
No | Postal code of users home |
city |
No | Name of users city |
Update account
Description
Updating values of an existing accountRequest
PATCH /account
| Body Parameters | Required? | Description |
|---|---|---|
id |
Yes | Identifier of dataset |
username |
No | Login username |
password |
No | Login password |
firstName |
No | First name of user |
lastName |
No | Last name of user |
street |
No | Street where the user lives |
houseNumber |
No | House number of user |
postalCode |
No | Postal code of users home |
city |
No | Name of users city |
Languages
Vue
51.1%
TypeScript
48.6%
JavaScript
0.2%
