Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md

This file was deleted.

5 changes: 5 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
__pycache__/
*.pyc
.venv/
node_modules/
1 change: 1 addition & 0 deletions backend/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
File renamed without changes.
3 changes: 0 additions & 3 deletions backend/api/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions backend/api/apps.py

This file was deleted.

3 changes: 0 additions & 3 deletions backend/api/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions backend/api/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions backend/api/views.py

This file was deleted.

27 changes: 27 additions & 0 deletions backend/app/api/routes/take_measurements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'''
Receive body measurements and save them to Supabase. Add any other logic in
services. Right now, we need to take those measurements and figure out what
best clothing fits the user.
'''

from fastapi import APIRouter, HTTPException
from app.db.supabase import create_supabase_client

router = APIRouter()

#Now I'm assuming passing in like a JSON Object with Body Measurements
@router.post("/")
def take_measurements(body_measurements: dict[str, float]):
if not body_measurements or len(body_measurements) <1:
raise HTTPException(status_code=400, detail="Empty body measurements list")
#validate that all values are numbers
for key, val in body_measurements.items():
if not isinstance(val, (int, float)):
raise HTTPException(status_code=400, detail=f"Measurement for {key} must be a number")

#save body measurements in supabase
supabase_client = create_supabase_client()
for key, val in body_measurements.items():
supabase_client.table("body_measurements").insert({key: key, "measurement":val}).execute()

print("Saved body measurements to Supabase")
File renamed without changes.
26 changes: 26 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pydantic_settings import BaseSettings, SettingsConfigDict
from functools import lru_cache

#Pydantic BaseSettings already reads from environment variables into class attributes
#extra ensures other vars in .env file are ignored

class Settings(BaseSettings):

model_config = SettingsConfigDict(env_file = ".env", extra = "ignore")

supabase_url: str
supabase_publishable_key: str

app_env: str = "development"
#frontend urls
allowed_origins: list[str]=["http://localhost:3000", "http://172.26.40.195:3000"]


#checks if the app is running in production environment
@property
def is_production(self) -> bool:
return self.app_env == "production"

@lru_cache()
def get_settings():
return Settings()
File renamed without changes.
11 changes: 11 additions & 0 deletions backend/app/db/supabase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from functools import lru_cache
from supabase import create_client, Client
from app.core.config import get_settings

@lru_cache()
def create_supabase_client() -> Client:
settings = get_settings()
return create_client(settings.supabase_url, settings.supabase_publishable_key)



26 changes: 26 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import get_settings
from app.api.routes.take_measurements import router as take_measurments_router

app = FastAPI(title = "Fit Style Backend",
version = "0.1.0",
docs_url = None if get_settings().is_production else "/docs",
redoc_url = None if get_settings().is_production else "/redoc")

settings = get_settings()

#Add to middleware to allow requests from frontend from my .env file
app.add_middleware(
CORSMiddleware,
allow_origins = settings.allowed_origins,
allow_credentials = True,
allow_methods = ["*"],
allow_headers = ["*"],
)

app.include_router(take_measurments_router, prefix = "/take-measurements", tags = ["take-measurements"])

@app.get("/health")
def health_check():
return {"status": "ok", "env": settings.app_env, "version": app.version}
Empty file.
Empty file added backend/app/utils/__init__.py
Empty file.
Binary file removed backend/backend/__pycache__/__init__.cpython-313.pyc
Binary file not shown.
Binary file removed backend/backend/__pycache__/settings.cpython-313.pyc
Binary file not shown.
16 changes: 0 additions & 16 deletions backend/backend/asgi.py

This file was deleted.

128 changes: 0 additions & 128 deletions backend/backend/settings.py

This file was deleted.

22 changes: 0 additions & 22 deletions backend/backend/urls.py

This file was deleted.

16 changes: 0 additions & 16 deletions backend/backend/wsgi.py

This file was deleted.

22 changes: 0 additions & 22 deletions backend/manage.py

This file was deleted.

17 changes: 17 additions & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[project]
name = "backend"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"aiosqlite>=0.22.1",
"fastapi>=0.135.1",
"fastapi-users[sqlalchemy]>=15.0.4",
"imagekitio>=5.2.0",
"pydantic-settings>=2.13.1",
"python-dotenv>=1.2.2",
"supabase>=2.28.3",
"torch>=2.11.0",
"uvicorn[standard]>=0.41.0",
]
Loading