You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# .env.local (로컬 개발용)# ─────────────────────────────────────────# AI API 키 (필수)# ─────────────────────────────────────────GEMINI_API_KEY=AIzaSy...# Google Gemini API# ─────────────────────────────────────────# 외부 서비스 (선택)# ─────────────────────────────────────────TRIPO_API_KEY=tsk_...# Tripo 3D 생성HYPER3D_API_KEY=hyper_...# Hyper3D 대안# ─────────────────────────────────────────# 데이터베이스# ─────────────────────────────────────────DATABASE_URL="file:./prisma/dev.db"# SQLite (로컬)# DATABASE_URL="postgres://..." # PostgreSQL (프로덕션)# ─────────────────────────────────────────# 앱 설정# ─────────────────────────────────────────NEXT_PUBLIC_API_URL=http://localhost:3000# API 베이스 URLNODE_ENV=development# 환경
Vercel 환경 변수 설정
# Vercel CLI로 환경 변수 설정
vercel env add GEMINI_API_KEY production
vercel env add GEMINI_API_KEY preview
vercel env add GEMINI_API_KEY development
# 또는 Vercel Dashboard에서 설정:# Settings > Environment Variables
변수명
환경
암호화
GEMINI_API_KEY
Production, Preview, Development
✅
TRIPO_API_KEY
Production, Preview
✅
DATABASE_URL
Production
✅
📋 배포 체크리스트
배포 전 점검
# 1. 로컬 빌드 테스트
npm run build
# 2. 린트 검사
npm run lint
# 3. 타입 체크
npx tsc --noEmit
# 4. 환경 변수 확인echo$GEMINI_API_KEY# 설정 여부 확인
예상 출력
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 5.24 kB 105 kB
├ ○ /gallery 2.31 kB 102 kB
├ ○ /studio 156 kB 261 kB
├ λ /api/generate 0 B 0 B
└ λ /api/resources/match 0 B 0 B
○ (Static) prerendered as static content
λ (Dynamic) server-rendered on demand
✓ Build completed in 45s
🚀 Vercel CLI 배포
초기 설정
# Vercel CLI 설치
npm i -g vercel
# 로그인
vercel login
# 프로젝트 링크
vercel link
# 배포에서 제외할 파일
# 개발 관련
node_modules
.git
*.log
.env.local
.env.development
# 백업/임시
_backup_legacy
temp_*
*.bak
# 테스트
__tests__
*.test.ts
*.spec.ts
# 문서
docs/
*.md
!README.md
# IDE
.vscode
.idea
# 에이전트 설정
.agent/data
graph LR
A[Push/PR] --> B{Branch?}
B -->|main| C[Lint & Build]
B -->|feature| D[Lint & Build]
C --> E[Deploy Production]
D --> F[Deploy Preview]
E --> G[✅ webpilot-engine.vercel.app]
F --> H[✅ PR Preview URL]
Loading
🗄️ 데이터베이스 운영
로컬 개발
# Prisma 설정
npx prisma init
# 마이그레이션 생성
npx prisma migrate dev --name init
# 마이그레이션 적용
npx prisma migrate dev
# Prisma Studio (DB GUI)
npx prisma studio
# DB 시드
npx prisma db seed
시드 스크립트
// prisma/seed.tsimport{PrismaClient}from'@prisma/client';importfsfrom'fs';importpathfrom'path';constprisma=newPrismaClient();asyncfunctionmain(){// 에셋 스캔 및 등록constmodelsDir=path.join(process.cwd(),'public/models');constglbFiles=scanGLBFiles(modelsDir);for(constfileofglbFiles){awaitprisma.asset3D.upsert({where: {filePath: file.relativePath},create: {name: file.name,filePath: file.relativePath,category: file.category,tags: JSON.stringify(file.tags),keywords: JSON.stringify(file.keywords),source: file.source},update: {}});}console.log(`✅ ${glbFiles.length}개 에셋 시드 완료`);}main().catch(console.error).finally(()=>prisma.$disconnect());
프로덕션 마이그레이션
# 프로덕션 DB 마이그레이션 (주의!)
npx prisma migrate deploy
# 스키마 동기화 (데이터 손실 주의)
npx prisma db push
📊 모니터링
Vercel Analytics
// app/layout.tsximport{Analytics}from'@vercel/analytics/react';import{SpeedInsights}from"@vercel/speed-insights/next";exportdefaultfunctionRootLayout({ children }){return(<html><body>{children}<Analytics/><SpeedInsights/></body></html>);}
성능 지표 목표
메트릭
목표값
현재
상태
FCP (First Contentful Paint)
< 1.5s
~1.2s
✅
LCP (Largest Contentful Paint)
< 2.5s
~2.0s
✅
CLS (Cumulative Layout Shift)
< 0.1
~0.05
✅
FID (First Input Delay)
< 100ms
~50ms
✅
빌드 시간
< 3min
~45s
✅
로깅
// 서버 로그console.log('[Pipeline] 씬 생성 시작:',prompt);console.log('[MCTS] 배치 완료:',stats);console.error('[API Error]:',error);// 클라이언트 로그console.log('[PreviewCanvas] 노드 렌더링:',nodes.length);console.log('[ScaleResolver] 스케일 계산:',result);
🔒 보안 고려사항
API 키 보호
// ❌ 절대 하지 말 것constAPI_KEY="AIzaSy...";// 하드코딩 금지!// ✅ 환경 변수 사용constAPI_KEY=process.env.GEMINI_API_KEY;// ✅ 서버 사이드에서만 사용exportasyncfunctionPOST(request: NextRequest){constapiKey=process.env.GEMINI_API_KEY;if(!apiKey){returnNextResponse.json({error: 'API key not configured'},{status: 500});}// ...}