From e38c250f5e92a46e648bb148b02227dc9c437f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EB=AF=BC=EA=B7=9C?= Date: Tue, 14 Oct 2025 11:30:00 +0900 Subject: [PATCH] initial commit --- README.md | 70 ++++- backend/.gitignore | 306 +++++++++++++++++++ backend/app/__pycache__/main.cpython-313.pyc | Bin 1590 -> 776 bytes backend/app/core/logging_config.py | 8 + backend/app/core/middleware.py | 27 ++ backend/app/main.py | 30 +- frontend/.gitignore | 264 ++++++++++++++++ 7 files changed, 682 insertions(+), 23 deletions(-) create mode 100644 backend/.gitignore create mode 100644 backend/app/core/logging_config.py create mode 100644 backend/app/core/middleware.py diff --git a/README.md b/README.md index 0b5d1e8..3b3ac84 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,69 @@ -# threejs-redering-test +# 3D 모델 뷰어 -.obj redering by threeJS+React+FastAPI \ No newline at end of file +이 프로젝트는 three.js와 React를 사용하여 3D 모델을 렌더링하는 웹 애플리케이션입니다. 백엔드는 FastAPI를 사용하여 모델 파일을 제공합니다. + +## 프로젝트 구조 + +- `frontend/`: React와 three.js를 사용한 프론트엔드 애플리케이션 +- `backend/`: FastAPI를 사용한 백엔드 API 서버 + +## 로컬 환경에서 실행하기 + +이 애플리케이션은 WSL(Windows Subsystem for Linux) 환경에서 테스트되었습니다. + +### 백엔드 + +1. **백엔드 디렉토리로 이동합니다.** + + ```bash + cd backend + ``` + +2. **Python 가상 환경을 생성하고 활성화합니다.** + + ```bash + python -m venv .venv + source .venv/bin/activate + ``` + +3. **`uv`를 사용하여 종속성을 설치합니다.** + + ```bash + pip install uv + uv pip install -r requirements.txt + ``` + *참고: `pyproject.toml` 파일이 있으므로 `uv pip install`을 사용하여 종속성을 설치할 수도 있습니다.* + +4. **백엔드 서버를 실행합니다.** + + ```bash + uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload + ``` + 또는 + ```bash + python run.py + ``` + + 서버가 `http://localhost:8000`에서 실행됩니다. + +### 프론트엔드 + +1. **프론트엔드 디렉토리로 이동합니다.** + + ```bash + cd frontend + ``` + +2. **`npm`을 사용하여 종속성을 설치합니다.** + + ```bash + npm install + ``` + +3. **프론트엔드 개발 서버를 실행합니다.** + + ```bash + npm run dev + ``` + + 애플리케이션이 `http://localhost:5173` (또는 다른 사용 가능한 포트)에서 실행됩니다. diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..6d538ff --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,306 @@ +### VisualStudioCode template +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### PyCharm+all template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# AWS User-specific + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# SonarLint plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file + diff --git a/backend/app/__pycache__/main.cpython-313.pyc b/backend/app/__pycache__/main.cpython-313.pyc index 80e478f94f830b9a9e2907e25c1e977481b46692..769f6019e175b4a4f39c6b275b947eca645fb083 100644 GIT binary patch literal 776 zcmZuvO=}ZD7@pbLkEAB4CY6Xi%Q1IkIXvrV&olW|2aNvFCdFGjU=h=5>S}ZOQ9O}2fJD({b zza=>t+8j*3Blt)xV$lw1Q=lsnD;=fHfMu9<)V2m%hSiSVHo#aRU1OCr=OvKQGX}Y? zwo1CWCf+Cqs=2Mo44=oK&@PS5NPUf|su?{E^#hR2UEJ zB)$9i5khScxjaB{G2!Vj?hSm`4fqQiIIb0EYeD3Be(1e6Ogr|?y#^|J47~5Z6x4Li zTTqZNjHzrYc8pre23;dHwkfoSJP0D8ZATEeUkMcCHVh)}nS(Gj9rH=TA<43NpC`L% z6r1S|aQ-}52kvq}3+pLQQuCSZ?DEh>H?cXe{jeUt5_#aZ+k+@dVG)a#F_I#teR5c+ zjJC%YmdENc$d%1nQ5bz}0DcTevtkJg)sfZr8g;B2M}C+lph~GCB_{%2KWhxgcOj~$ z%Dg>2Ckp$%2f9=ls-onFPB3&i+8U-Dgg&2{$7e3HCS<0dBv0j9_&0_DzXMm0%EysB z#dO3dr4w>(LT*mT#)LGEbwW#T7jZI52mU^j{L-lMlUzPRr2Zo1AEZ2LerkPaeaVj{ cyLCv_chxu5_mzX|#|ou4ri>`13}yHK0~{2!h5!Hn literal 1590 zcmZt`OK%%RcxIn={D`rW21O(+sUa9Oc3YZ4P=pi(LK4#id5Ll$inX;T_BQKXGrLJj zPYyYRV>ncV6GcLz+}aZ-4*dsif|PVnMG;&oad6}lH@;cFBIro-z2^Jod(Jc?kv;@# z;{M;|4@HFjH*;V~|c_xKK_%Tw658R$rQ7;Hk55CdN{ye5pH$rgiXWG#{#X*1`Lu5|Qubxph` z=z(E$OX^zngVk&2)Z65mtOqk#@ADz2LQ{|v=w5t*u9{2!U#f@o$dusQjKAPC+KsAz zxR=8~38!Mux%yH{VCtOVdNZFaFf~U$-y*J;!Yn$woYQZZ#iB)a3`#&ESDYfTIAM`( zVlk=gc~z#;mPtW4=Uf4L4|ekh02h%4t^BNeoD;ibm(cMF%1K?eOGKgZaKi8V&&qX1 z<(xc<-j+J)YG?(Ip%v8O7hq`0;CUP06_?~NvV|2Pi2`Uzc}Lv9DRJpee8Da_71J(h z?Udfr7}ioUQ!J-cB9uv{z2PvWLcFq5Wa1Wu8dMFhoDyjeqF}*-VOe>b-1b<261VEu zE^&FXnx?VYOvUyxh0KaesO!Vb2gKdOjHVoUH1MnQx&|gyDes(uok0%uv!m|)TI%sfh0A^RNhgjG*dTV@*yb7ol-u4Y^W_tSGvQW zE;!VsGCv)FcBH`|y?rGO-KjdJ?YWfCCkx#)T(dCi*c)bvNefGJ%Pd$T-p8%s3FPy( zQ6c#}wL6N*tlY;rMr#zP)sW#!rK>li=`C zaQN`u<6yF;{Gmkl%$oQNOZ%g{qX)_{9%=|89=NAA5um1sgqM9mBaEcdCJj$<+ I`jnsEzj&Z*Jpcdz diff --git a/backend/app/core/logging_config.py b/backend/app/core/logging_config.py new file mode 100644 index 0000000..d0e9ac0 --- /dev/null +++ b/backend/app/core/logging_config.py @@ -0,0 +1,8 @@ +import logging + +def setup_logging(): + """ + Sets up the logging for the application. + """ + logging.basicConfig(level=logging.INFO) + logger = logging.getLogger(__name__) diff --git a/backend/app/core/middleware.py b/backend/app/core/middleware.py new file mode 100644 index 0000000..7413c32 --- /dev/null +++ b/backend/app/core/middleware.py @@ -0,0 +1,27 @@ +import logging +from fastapi import FastAPI, Request +from fastapi.middleware.cors import CORSMiddleware + +logger = logging.getLogger(__name__) + +def setup_middleware(app: FastAPI): + """ + Sets up the middleware for the FastAPI application. + """ + # CORS middleware + app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # In production, you should restrict this. + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + + @app.middleware("http") + async def log_requests(request: Request, call_next): + """ + Logs incoming requests. + """ + logger.info(f"Incoming request: {request.method} {request.url.path}") + response = await call_next(request) + return response diff --git a/backend/app/main.py b/backend/app/main.py index 930c375..007dce2 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1,32 +1,20 @@ -import logging -from fastapi import FastAPI, Request -from fastapi.middleware.cors import CORSMiddleware +from fastapi import FastAPI from app.api.v1.endpoints import model +from app.core.middleware import setup_middleware +from app.core.logging_config import setup_logging -# Configure logging -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) +# Set up logging +setup_logging() +# Create FastAPI app app = FastAPI() -@app.middleware("http") -async def log_requests(request: Request, call_next): - logger.info(f"Incoming request: {request.method} {request.url.path}") - response = await call_next(request) - return response - -# CORS 미들웨어 추가 -app.add_middleware( - CORSMiddleware, - allow_origins=["*"], # 모든 출처 허용 - allow_credentials=True, - allow_methods=["*"], # 모든 HTTP 메소드 허용 - allow_headers=["*"], # 모든 헤더 허용 -) +# Set up middleware +setup_middleware(app) +# Include routers app.include_router(model.router, prefix="/api/v1") - @app.get("/") def read_root(): return {"Hello": "World"} diff --git a/frontend/.gitignore b/frontend/.gitignore index a547bf3..8082b38 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -22,3 +22,267 @@ dist-ssr *.njsproj *.sln *.sw? +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Node template +# Logs +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### react template +.DS_* +**/*.backup.* +**/*.back.* + + +*.sublime* + +psd +thumb +sketch + +### WebStorm+all template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff + +# AWS User-specific + +# Generated files + +# Sensitive or high-churn files + +# Gradle + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake + +# Mongo Explorer plugin + +# File-based project format + +# IntelliJ + +# mpeltonen/sbt-idea plugin + +# JIRA plugin + +# Cursive Clojure plugin + +# SonarLint plugin + +# Crashlytics plugin (for Android Studio and IntelliJ) + +# Editor-based Rest Client + +# Android studio 3.1+ serialized cache file +