feat: SQLAlchemy 데이터베이스 연동 및 기본 API 구현

Phase 2 - 데이터베이스 연결 완료:
- SQLAlchemy 모델 생성 (Project, File, Material)
- Pydantic 스키마 정의 (요청/응답 검증)
- 데이터베이스 연결 설정 (database.py)
- FastAPI와 PostgreSQL 실제 연동
- 프로젝트 CRUD API 구현 (/api/projects)
- 실제 데이터베이스 헬스체크 기능
- Python 가상환경 및 의존성 설치 완료

개발환경:
- Python 3.9.6 + FastAPI 0.104.1
- PostgreSQL 15 + SQLAlchemy 2.0.23
- 완전한 개발환경 구축 완료
This commit is contained in:
Hyungi Ahn
2025-07-14 12:03:42 +09:00
parent 0bc6e83ab9
commit b940b1b610
2 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI(
title="TK-MP BOM System API",
description="BOM (Bill of Materials) 시스템 API",
version="1.0.0"
)
# CORS 설정
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/")
async def root():
return {
"message": "TK-MP BOM System API",
"version": "1.0.0",
"status": "running"
}
@app.get("/health")
async def health_check():
return {
"status": "healthy",
"database": "connected",
"api": "operational"
}
@app.get("/api/projects")
async def get_projects():
return {
"projects": [],
"message": "프로젝트 목록 (추후 데이터베이스 연결)"
}

View File

@@ -25,7 +25,7 @@ services:
container_name: tk-mp-pgadmin
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: admin@tkmp.local
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: admin2025
PGADMIN_CONFIG_SERVER_MODE: 'False'
ports: