์น ํ๋ก ํธ์๋
ev-motor-reliability๋ Python/C ๊ธฐ๋ฐ ์์คํ
์ด์ง๋ง, ๋ถ์ ๊ฒฐ๊ณผ ๋์๋ณด๋์ ์ํ ๋ชจ๋ํฐ๋ง์ ์ํ ์น ํ๋ก ํธ์๋๋ฅผ ์ ๊ณตํฉ๋๋ค. ํ๋ก ํธ์๋๋ ํ๋ก์ ํธ์ web/ ๋๋ ํ ๋ฆฌ์ ์์นํฉ๋๋ค.
๊ตฌ์กฐ
ev-motor-reliability/
โโโ web/
โโโ src/
โ โโโ app/ # Next.js App Router ํ์ด์ง
โ โโโ components/ # UI ์ปดํฌ๋ํธ
โ โโโ lib/ # API ํด๋ผ์ด์ธํธ, ์ ํธ๋ฆฌํฐ
โโโ public/ # ์ ์ ํ์ผ
โโโ package.json
โโโ next.config.js
โโโ tsconfig.json์ฃผ์ ๊ธฐ๋ฅ
| ๊ธฐ๋ฅ | ์ค๋ช |
|---|---|
| ๋์๋ณด๋ | ๋ถ์ ํํฉ, ์ต๊ทผ ์ํ ๊ฒฐ๊ณผ ์์ฝ |
| ๋ฐ์ดํฐ ์ ๋ก๋ | CSV/Excel ํ์ผ ๋๋๊ทธ ์ค ๋๋กญ ์ ๋ก๋ |
| ๋ถ์ ์ค์ | Weibull ํ๋ผ๋ฏธํฐ, ๊ณ ์ฅ ๊ธฐ์ค ์ค์ UI |
| ๊ฒฐ๊ณผ ์๊ฐํ | Weibull ํ๋กฏ, ์ ๋ขฐ๋ ๊ณก์ ๋ฑ ์ธํฐ๋ํฐ๋ธ ์ฐจํธ |
| ์ค์๊ฐ ๋ชจ๋ํฐ๋ง | ์๋ฆฌ์ผ ์์ง ์ค ์ค์๊ฐ ๋ฐ์ดํฐ ์คํธ๋ฆผ ํ์ |
| ๋ณด๊ณ ์ ๋ค์ด๋ก๋ | HTML/PDF ๋ณด๊ณ ์ ์์ฑ ๋ฐ ๋ค์ด๋ก๋ |
๊ฐ๋ฐ ํ๊ฒฝ ์ค์
์ฌ์ ์๊ตฌ์ฌํญ
- Node.js 18 ์ด์
- Python ์๋ฎฌ๋ ์ด์ ์๋ฒ๊ฐ ์คํ ์ค์ด์ด์ผ ํฉ๋๋ค (API ํต์ )
์ค์น
cd ev-motor-reliability/web
npm installํ๊ฒฝ ๋ณ์
web/.env.local ํ์ผ์ ์์ฑํฉ๋๋ค:
# Python API ์๋ฒ ์ฃผ์
NEXT_PUBLIC_API_URL=http://localhost:8000
# WebSocket ์ฃผ์ (์ค์๊ฐ ๋ชจ๋ํฐ๋ง)
NEXT_PUBLIC_WS_URL=ws://localhost:8000/ws๊ฐ๋ฐ ์๋ฒ ์คํ
Python API ์๋ฒ์ ์น ํ๋ก ํธ์๋๋ฅผ ํจ๊ป ์คํํฉ๋๋ค.
# ํฐ๋ฏธ๋ 1: Python API ์๋ฒ
cd ev-motor-reliability
source venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# ํฐ๋ฏธ๋ 2: ์น ํ๋ก ํธ์๋
cd ev-motor-reliability/web
npm run dev๋ธ๋ผ์ฐ์ ์์ http://localhost:3000์ผ๋ก ์ ์ํฉ๋๋ค.
API ์ฐ๋
์น ํ๋ก ํธ์๋๋ Python FastAPI ์๋ฒ์ REST API๋ฅผ ํธ์ถํฉ๋๋ค.
์ฃผ์ API ์๋ํฌ์ธํธ
| ๋ฉ์๋ | ๊ฒฝ๋ก | ์ค๋ช |
|---|---|---|
POST | /api/upload | ์ํ ๋ฐ์ดํฐ ํ์ผ ์ ๋ก๋ |
GET | /api/datasets | ์ ๋ก๋๋ ๋ฐ์ดํฐ์ ๋ชฉ๋ก |
POST | /api/analysis/run | ๋ถ์ ์คํ (๋น๋๊ธฐ) |
GET | /api/analysis/{id}/status | ๋ถ์ ์งํ ์ํ |
GET | /api/analysis/{id}/result | ๋ถ์ ๊ฒฐ๊ณผ ์กฐํ |
GET | /api/analysis/{id}/plot/{type} | ์ฐจํธ ์ด๋ฏธ์ง ์์ฒญ |
GET | /api/analysis/{id}/report | ๋ณด๊ณ ์ ๋ค์ด๋ก๋ |
WS | /ws/monitor | ์ค์๊ฐ ๋ฐ์ดํฐ ์คํธ๋ฆผ |
์ค์๊ฐ ๋ชจ๋ํฐ๋ง
์๋ฆฌ์ผ ํฌํธ์์ ๋ฐ์ดํฐ๋ฅผ ์์งํ๋ ๋์, WebSocket์ ํตํด ์ค์๊ฐ์ผ๋ก ํ๋ก ํธ์๋์ ๋ฐ์ดํฐ๋ฅผ ์คํธ๋ฆฌ๋ฐํฉ๋๋ค. ์ฐจํธ๋ ์์ ๋ฐ์ดํฐ๋ฅผ ์ค์๊ฐ์ผ๋ก ๊ฐฑ์ ํฉ๋๋ค.
๋น๋ ๋ฐ ์คํ
ํ๋ก๋์ ๋น๋
cd ev-motor-reliability/web
npm run build๋น๋ ๊ฒฐ๊ณผ๋ฌผ์ web/.next/ ๋๋ ํ ๋ฆฌ์ ์์ฑ๋ฉ๋๋ค.
ํ๋ก๋์ ์คํ
cd ev-motor-reliability/web
npm start๊ธฐ๋ณธ ํฌํธ๋ 3000์
๋๋ค. PORT ํ๊ฒฝ ๋ณ์๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
Python API ์๋ฒ์ ๋์ ์คํ
ํ๋ก๋์ ํ๊ฒฝ์์๋ ๋ ์๋ฒ๋ฅผ ๋ชจ๋ ํ๋ก์ธ์ค ๊ด๋ฆฌ์๋ก ์คํํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.
# PM2 ์ฌ์ฉ ์์
pm2 start "uvicorn app.main:app --host 0.0.0.0 --port 8000" --name ev-api
pm2 start "cd web && npm start" --name ev-web
pm2 saveํ๋ก์ ์ค์
ํ๋ก ํธ์๋์ API ์๋ฒ๋ฅผ ๋์ผ ๋๋ฉ์ธ์์ ์๋น์คํ๋ ค๋ฉด Nginx ๋ฆฌ๋ฒ์ค ํ๋ก์๋ฅผ ์ค์ ํฉ๋๋ค.
server {
listen 80;
server_name ev-motor.local;
# ์น ํ๋ก ํธ์๋
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
# API ์๋ฒ
location /api/ {
proxy_pass http://localhost:8000/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# WebSocket
location /ws/ {
proxy_pass http://localhost:8000/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}