Dalam Arsitektur yang dibangun untuk membangun sebuah backend aplikasi stylomate menggunakan MVC (Model View Controller), dengan pendekatan clean code arsitektur dan juga monolitic berikut adalah code bagian backend dari aplikasi staylo mate:
- config
- controller
- repository
- service
- model
- router
main.py
.envHal yang perlu dilakukan untuk menjalankan code ini pastikan instalasi python di laptop atau komputer anda. berikut adalah langkah pertama:
git clone https://github.com/codename-error/stylomate-be.gitSelanjutnya ke dalam direktory yang sudah di tentukan
cd stylemate-beselanjutnya adalah melakukan instalasi package
pip install -t requirements.txtselanjutnya adalah menjalankan dengan menjalankan berikut di terminal anda:
uvicorn main:app --reloadsetelah berhasil maka port default dari project ini adalah 8000
URI = http://localhost:8000/
diikuti dengan Enpoint setelahnya, contoh = http://localhost:8000/v2/login
End Poin : /v2/login
Methode : POST
Request:
{
"email": "string",
"password": "string"
}Response:
- 200 → OK
{
"message": "User registered successfully",
"user": {
"user": "",
"access_token": ""
"token_type": "bearer"
}
}- 500 → Internal Server Error
Endpoint: /v2/register
Methode : POST
request Body:
{
"username": "string",
"email": "string",
"password": "string",
"validate_password": "string",
"profile_picture": "string",
"preference": [
"string"
],
"image_model": "string"
}response Body:
- 200 → OK
{
"message": "User registered successfully",
"user": {
"user": "",
"access_token": ""
"token_type": "bearer"
}
}
- 500 → Internal Server Error
Endpoint: /v2/user/preference
Methode: PUT
request Body:
{
"username": "string",
"profile_picture": "string",
"preference": [
"string"
],
"image_model": "string"
}response Body:
- 201 → Created
- 400 → internal server error
Endpoint : /v2/user/image_model
Methode: PUT
request_body:
from-data
file *string($binary)Response Body:
- 201 Created
- 400 Not Found
End point: /wardrobe
method: GET
Response:
{ "message": "Succesfult Get Wardrobe item",
"data": [
{"type": "T-Shirt",
"length": "Hip",
"id": 1,
"category": "Top",
"image_url":base64,
"color": "White",
"pattern": "Plain"}
]
}method: PUT
params:
/id → wardobe/1body:
class UpdateClothesModel(BaseModel):
type: Optional[str] = None
category: Optional[str] = None
color: Optional[str] = None
pattern: Optional[str] = None
length: Optional[str] = None
image_base64: Optional[str] = NoneResponse: 202 → No Conten
methode: DELETE
params:
/id → wardobe/1Response:
202 → No Content
methode: POST
body:
multipart/form data: file image (jpg/png)response:
201 → created
Endpoint : /v2/recomendation
Methode: POST
Request Body:
{
"id": 0,
"kondisi": "string",
"activity": "string"
}Response:
- 200 → OK
- 400 → Not Found
Endpoint : /v2/styleme/category
Methode : GET
Request Body:
{
"category": "string"
}
input = ["Top"/ "Bottom"]Response Body:
- 200 → Oke
- 500 → Internal Server Error
Endpoint : /v2/styleme/random
Methode: GET
Request Body:
{
"cari": "string"
}
input = ["Top" / "Bottom" / "None"]Response Body:
- 200 → Ok
- 500 → Internal Server error
Endpoint : /v2/styleme/{id}
Methode: GET
Parameters:
id = ....(int)Response Body
- 200 → Ok
- 500 → Internal Server Error
Endpoint : /v2/url
Methode: GET
Request Body:
Form Data Response Body:
- 200 → OK
- 500 → Internal Server Error
Endpoint : /v2/stylo/wardrobe
Methode: GET
response Body:
{ "message": "Succesfult Get Wardrobe item",
"data": [
{"type": "T-Shirt",
"length": "Hip",
"id": 1,
"category": "Top",
"image_url":base64,
"color": "White",
"pattern": "Plain"}
]
} Endpoint: /v2/styloai
Methode: POST
Request Body:
{
"image": base64,
"image": base64
}response Body:
hasilnya image