├── .gitignore ├── assets ├── storage │ ├── purchased.json │ └── clothes.json └── images │ ├── calça_band.jpg │ ├── camisa_fit.jpg │ ├── camisa_polo.jpg │ ├── calça_caiena.jpg │ ├── calça_skinny.jpg │ ├── calça_warrior.jpg │ ├── camisa_classic.jpg │ ├── camisa_floral.jpg │ ├── camisa_royal.jpg │ ├── camisa_xadrez.jpg │ ├── vestido_munich.jpg │ ├── calça_destroyed.jpg │ ├── calça_destroyed2.jpg │ └── camiseta_alkary.jpg ├── README.md ├── index.php ├── controller └── clotheController.php ├── model └── clothe.php ├── view ├── home.php ├── style.css └── final.php └── inc └── functions.php /.gitignore: -------------------------------------------------------------------------------- 1 | anotações.txt -------------------------------------------------------------------------------- /assets/storage/purchased.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /assets/images/calça_band.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_band.jpg -------------------------------------------------------------------------------- /assets/images/camisa_fit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_fit.jpg -------------------------------------------------------------------------------- /assets/images/camisa_polo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_polo.jpg -------------------------------------------------------------------------------- /assets/images/calça_caiena.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_caiena.jpg -------------------------------------------------------------------------------- /assets/images/calça_skinny.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_skinny.jpg -------------------------------------------------------------------------------- /assets/images/calça_warrior.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_warrior.jpg -------------------------------------------------------------------------------- /assets/images/camisa_classic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_classic.jpg -------------------------------------------------------------------------------- /assets/images/camisa_floral.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_floral.jpg -------------------------------------------------------------------------------- /assets/images/camisa_royal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_royal.jpg -------------------------------------------------------------------------------- /assets/images/camisa_xadrez.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camisa_xadrez.jpg -------------------------------------------------------------------------------- /assets/images/vestido_munich.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/vestido_munich.jpg -------------------------------------------------------------------------------- /assets/images/calça_destroyed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_destroyed.jpg -------------------------------------------------------------------------------- /assets/images/calça_destroyed2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/calça_destroyed2.jpg -------------------------------------------------------------------------------- /assets/images/camiseta_alkary.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rangel-pci/clothingRecommendation/HEAD/assets/images/camiseta_alkary.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # clothingRecommendation 2 | 3 | A simple clothing recommendation system based on purchased clothing, made with PHP. 4 | 5 |
purchase page preview
6 |
7 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /controller/clotheController.php: -------------------------------------------------------------------------------- 1 | showAll(); 11 | return $resp; 12 | } 13 | 14 | public function showAllPurchased(){ 15 | $clothe = new clothe(); 16 | 17 | $resp = $clothe->getAllPurchased(); 18 | return $resp; 19 | } 20 | 21 | public function getclothe($id){ 22 | $clothe = new clothe(); 23 | 24 | $resp = $clothe->findById($id); 25 | return $resp; 26 | } 27 | 28 | public function buy($id){ 29 | $clothe = new clothe(); 30 | 31 | $clothe->addToList($id); 32 | } 33 | 34 | public function destroy(){ 35 | $clothe = new clothe(); 36 | 37 | $clothe->removeAllPurchased(); 38 | } 39 | } 40 | 41 | ?> -------------------------------------------------------------------------------- /model/clothe.php: -------------------------------------------------------------------------------- 1 | id == $clothe->id) { 38 | $ok = false; 39 | } 40 | } 41 | 42 | if($ok){ 43 | array_push($list, $clothePurchased); 44 | 45 | $jsonList = json_encode($list); 46 | 47 | file_put_contents('./assets/storage/purchased.json', $jsonList); 48 | } 49 | } 50 | 51 | public function removeAllPurchased(){ 52 | 53 | file_put_contents('./assets/storage/purchased.json', '[]'); 54 | } 55 | 56 | } 57 | 58 | ?> -------------------------------------------------------------------------------- /view/home.php: -------------------------------------------------------------------------------- 1 | getAll()); 11 | shuffle($clothes); 12 | 13 | //realiza a "compra" de uma peça de roupa 14 | if(isset($_GET['clothe_id'])){ 15 | $id = $_GET['clothe_id']; 16 | 17 | $clotheController->buy($id); 18 | } 19 | 20 | //limpa a lista de comprados 21 | if (isset($_GET['clean'])) { 22 | $clotheController->destroy(); 23 | } 24 | 25 | ?> 26 | 27 | 28 | 29 | Home 30 | 31 | 32 | 33 | 34 |

Peças Disponíveis em Estoque

35 | Limpar lista de compra 36 |
37 | 38 | 41 | 42 |
43 | <?= $clothes[$i]->name ?> 44 |
name ?>
45 | 46 | alreadyPurchased($clothes[$i]->id)){ 48 | echo "

Comprado

"; 49 | }else{ 50 | echo "Comprar"; 51 | } 52 | ?> 53 | 54 | 55 |
56 |

Gênero - gender ?>

57 |

Material - material ?>

58 |

Cor - color ?>

59 |

Origem - origin ?>

60 |

Tipo - type ?>

61 |
62 |
63 | 64 | 65 | 68 |
69 | 70 | 72 | 73 | -------------------------------------------------------------------------------- /inc/functions.php: -------------------------------------------------------------------------------- 1 | showAllPurchased()); 13 | 14 | foreach ($list as $clothe) { 15 | if($clothe->id == $id){ 16 | return true; 17 | } 18 | } 19 | } 20 | 21 | public function getRecommendation($clothePurchased) 22 | { 23 | $clotheController = new clotheController(); 24 | 25 | $available = json_decode($clotheController->getAll()); 26 | 27 | //faz recomendações se tiver no mínino três peças de roupas disponíveis 28 | $purchasedCount = 0; 29 | foreach ($available as $clothe) { 30 | if ($this->alreadyPurchased($clothe->id)) { 31 | $purchasedCount++; 32 | } 33 | } 34 | $availableToRecommend = count($available) - $purchasedCount; 35 | if ($availableToRecommend < 3) { 36 | return false; 37 | } 38 | 39 | 40 | $points = []; 41 | $y = 0; 42 | //pontua as peças 43 | //as peças com maior quantidade de pontos são recomendadas 44 | do{ 45 | $tempPts = 0; 46 | $tempId = 999; 47 | $tempIndex = 999; 48 | $i = 0; 49 | 50 | foreach ($available as $clothe) { 51 | if($clothePurchased->id != $clothe->id && !$this->alreadyPurchased($clothe->id)){ 52 | $pts = 0; 53 | $pts += ($clothePurchased->gender == $clothe->gender)? 3 : 0; 54 | $pts += ($clothePurchased->material == $clothe->material)? 2 : 0; 55 | $pts += ($clothePurchased->color == $clothe->color)? 1 : 0; 56 | $pts += ($clothePurchased->origin == $clothe->origin)? 1 : 0; 57 | $pts += ($clothePurchased->type != $clothe->type)? 1 : 0; 58 | 59 | if($pts > $tempPts){ 60 | $tempPts = $pts; 61 | $tempId = $clothe->id; 62 | $tempIndex = $i; 63 | } 64 | } 65 | $i++; 66 | } 67 | array_push($points, $tempId); 68 | 69 | unset($available[$tempIndex]); 70 | 71 | $available = array_values($available); 72 | 73 | $y++; 74 | 75 | }while($y < 3); 76 | 77 | $top3 = []; 78 | 79 | $clothe1 = json_decode($clotheController->getclothe($points[0])); 80 | $clothe2 = json_decode($clotheController->getclothe($points[1])); 81 | $clothe3 = json_decode($clotheController->getclothe($points[2])); 82 | 83 | array_push($top3, $clothe1, $clothe2, $clothe3); 84 | 85 | return $top3; 86 | } 87 | } 88 | 89 | ?> -------------------------------------------------------------------------------- /view/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | padding: 0; 3 | margin: 0; 4 | box-sizing: border-box; 5 | 6 | color: #4f4f4f; 7 | } 8 | 9 | body{ 10 | background: #f1f1f1; 11 | display: flex; 12 | flex-direction: column; 13 | align-items: center; 14 | } 15 | 16 | .title{ 17 | text-align: center; 18 | margin: 10px 0; 19 | } 20 | 21 | .clean{ 22 | background: #fff; 23 | 24 | padding: 10px 50px; 25 | 26 | box-shadow: 2px 2px 5px #ddd; 27 | 28 | text-decoration: none; 29 | border: 2px solid transparent; 30 | } 31 | 32 | .container{ 33 | max-width: 90%; 34 | margin: 20px auto; 35 | } 36 | 37 | #clothes{ 38 | display: flex; 39 | flex-wrap: wrap; 40 | } 41 | 42 | .clothe-card{ 43 | font-family: sans-serif; 44 | 45 | width: 100%; 46 | max-width: 200px; 47 | padding: 20px; 48 | margin: 10px 10px; 49 | 50 | background: #fff; 51 | 52 | border-radius: 5px; 53 | border: 1px solid lightblue; 54 | 55 | display: flex; 56 | flex-direction: column; 57 | justify-content: space-between; 58 | 59 | box-shadow: 5px 5px 5px #ddd; 60 | 61 | position: relative; 62 | } 63 | 64 | .clothe-card img{ 65 | width: 100%; 66 | height: 200px; 67 | object-fit: cover; 68 | } 69 | 70 | .clothe-card h5{ 71 | text-align: center; 72 | font-size: 16px; 73 | 74 | padding: 10px; 75 | } 76 | 77 | .clothe-card a{ 78 | width: 100%; 79 | 80 | border: 2px solid #f1f1f1; 81 | 82 | background: #f1f1f1; 83 | padding: 10px 0; 84 | 85 | text-align: center; 86 | text-decoration: none; 87 | } 88 | 89 | a:hover{ 90 | border-color: lightblue; 91 | } 92 | a{ 93 | margin: 5px 0; 94 | } 95 | 96 | .clothe-card .info{ 97 | opacity: 0; 98 | 99 | position: absolute; 100 | top: 10px; 101 | left: 0; 102 | 103 | z-index: 1; 104 | 105 | background: #000; 106 | 107 | width: 100%; 108 | padding: 20px; 109 | } 110 | 111 | .clothe-card .info p{ 112 | color: #fff; 113 | } 114 | 115 | 116 | .clothe-card:hover .info{ 117 | opacity: 1; 118 | 119 | transition: 0.5s all; 120 | } 121 | 122 | .purchased{ 123 | background: lightgreen; 124 | text-align: center; 125 | 126 | width: 100%; 127 | padding: 10px 0; 128 | 129 | color: #fff; 130 | } 131 | 132 | /* Compra efetuada */ 133 | 134 | #final .clothe-card{ 135 | margin: 5px auto; 136 | border: 1px solid lightgreen; 137 | 138 | box-shadow: 0 0 5px lightgreen; 139 | } 140 | 141 | #final{ 142 | text-align: center; 143 | } 144 | 145 | #final a{ 146 | display: inline-block; 147 | margin-top: 10px; 148 | 149 | border: 2px solid #f1f1f1; 150 | 151 | background: #ddd; 152 | padding: 10px 50px; 153 | 154 | text-align: center; 155 | text-decoration: none; 156 | } 157 | 158 | #recommendation{ 159 | width: 90%; 160 | 161 | display: flex; 162 | justify-content: center; 163 | 164 | margin-bottom: 20px; 165 | } -------------------------------------------------------------------------------- /view/final.php: -------------------------------------------------------------------------------- 1 | getclothe($_GET['clothe_id'])); 14 | 15 | //realiza a "compra" 16 | $clotheController->buy($clothePurchased->id); 17 | 18 | //realiza a recomendação de 3 peças de roupa 19 | $top3 = $functions->getRecommendation($clothePurchased); 20 | 21 | ?> 22 | 23 | 24 | 25 | Final 26 | 27 | 28 | 29 | 30 |

Compra Efetuada

31 | 32 |
33 |
34 | <?= $clothePurchased->name ?> 35 |
name ?>
36 | 37 |
38 |

Gênero - gender ?>

39 |

Material - material ?>

40 |

Cor - color ?>

41 |

Origem - origin ?>

42 |

Tipo - type ?>

43 |
44 |
45 | 46 |

O item name ?> foi adicionado a sua lista de compras.

47 | Voltar 48 |
49 | 50 | Complete seu visual": '' ?> 51 | 52 |
53 | 58 |
59 | <?= $clotheRecommended->name ?> 60 |
name ?>
61 | 62 |
63 |

Gênero - gender ?>

64 |

Material - material ?>

65 |

Cor - color ?>

66 |

Origem - origin ?>

67 |

Tipo - type ?>

68 |
69 | 70 | alreadyPurchased($clotheRecommended->id)){ 72 | echo "

Comprado

"; 73 | }else{ 74 | echo "Comprar"; 75 | } 76 | ?> 77 | 78 |
79 | 83 |

Poucas peças disponíveis para recomendação

84 | 87 |
88 | 89 | 91 | 92 | -------------------------------------------------------------------------------- /assets/storage/clothes.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 0, 4 | "image":"./assets/images/camisa_fit.jpg", 5 | "name":"Camisa Slim Fit", 6 | "gender":"masculino", 7 | "material":"seda", 8 | "color":"azul", 9 | "origin":"nacional", 10 | "type":"superior" 11 | }, 12 | { 13 | "id": 1, 14 | "image":"./assets/images/camisa_floral.jpg", 15 | "name":"Camisa Floral Tov", 16 | "gender":"masculino", 17 | "material":"seda", 18 | "color":"branco", 19 | "origin":"internacional", 20 | "type":"superior" 21 | }, 22 | { 23 | "id": 2, 24 | "image":"./assets/images/calça_warrior.jpg", 25 | "name":"Calsa Jeans Skinny Warrior", 26 | "gender":"masculino", 27 | "material":"algodão", 28 | "color":"preto", 29 | "origin":"nacional", 30 | "type":"inferior" 31 | }, 32 | { 33 | "id": 3, 34 | "image":"./assets/images/calça_caiena.jpg", 35 | "name":"Calsa Jeans Caiena", 36 | "gender":"masculino", 37 | "material":"algodão", 38 | "color":"azul", 39 | "origin":"nacional", 40 | "type":"inferior" 41 | }, 42 | { 43 | "id": 4, 44 | "image":"./assets/images/calça_destroyed2.jpg", 45 | "name":"Calsa Jeans Skinny Destroyed", 46 | "gender":"masculino", 47 | "material":"algodão", 48 | "color":"azul", 49 | "origin":"nacional", 50 | "type":"inferior" 51 | }, 52 | { 53 | "id": 5, 54 | "image":"./assets/images/camisa_polo.jpg", 55 | "name":"Camisa Polo", 56 | "gender":"masculino", 57 | "material":"algodão", 58 | "color":"preto", 59 | "origin":"nacional", 60 | "type":"superior" 61 | }, 62 | { 63 | "id": 6, 64 | "image":"./assets/images/vestido_munich.jpg", 65 | "name":"Vestido Camisão Munich", 66 | "gender":"feminino", 67 | "material":"algodão", 68 | "color":"beige", 69 | "origin":"internacional", 70 | "type":"superior" 71 | }, 72 | { 73 | "id": 7, 74 | "image":"./assets/images/camisa_classic.jpg", 75 | "name":"Camisa Polo Classic", 76 | "gender":"feminino", 77 | "material":"algodão", 78 | "color":"preto", 79 | "origin":"nacional", 80 | "type":"superior" 81 | }, 82 | { 83 | "id": 8, 84 | "image":"./assets/images/calça_skinny.jpg", 85 | "name":"Calça Jeans Skinny", 86 | "gender":"feminino", 87 | "material":"algodão", 88 | "color":"preto", 89 | "origin":"nacional", 90 | "type":"inferior" 91 | }, 92 | { 93 | "id": 9, 94 | "image":"./assets/images/calça_band.jpg", 95 | "name":"Calça Slide Band", 96 | "gender":"masculino", 97 | "material":"seda", 98 | "color":"preto", 99 | "origin":"nacional", 100 | "type":"inferior" 101 | }, 102 | { 103 | "id": 10, 104 | "image":"./assets/images/camisa_royal.jpg", 105 | "name":"Camisa Polo Royal", 106 | "gender":"masculino", 107 | "material":"algodão", 108 | "color":"azul", 109 | "origin":"nacional", 110 | "type":"superior" 111 | }, 112 | { 113 | "id": 11, 114 | "image":"./assets/images/camiseta_alkary.jpg", 115 | "name":"Camiseta Alkary Manga 3/4", 116 | "gender":"masculino", 117 | "material":"algodão", 118 | "color":"branco", 119 | "origin":"nacional", 120 | "type":"superior" 121 | }, 122 | { 123 | "id": 12, 124 | "image":"./assets/images/camisa_xadrez.jpg", 125 | "name":"Camisa Xadrez Manga Longa", 126 | "gender":"feminino", 127 | "material":"algodão", 128 | "color":"branco", 129 | "origin":"nacional", 130 | "type":"superior" 131 | } 132 | ] --------------------------------------------------------------------------------