소형 건설업체(100억 미만)를 위한 AI 기반 토목공사 통합관리 플랫폼 Backend (FastAPI): - SQLAlchemy 모델 13개 (users, projects, wbs, tasks, daily_reports, reports, inspections, quality, weather, permits, rag, settings) - API 라우터 11개 (auth, projects, tasks, daily_reports, reports, inspections, weather, rag, kakao, permits, settings) - Services: Claude AI 래퍼, CPM Gantt 계산, 기상청 API, RAG(pgvector), 카카오 Skill API - Alembic 마이그레이션 (pgvector 포함) - pytest 테스트 (CPM, 날씨 경보) Frontend (Next.js 15): - 11개 페이지 (대시보드, 프로젝트, Gantt, 일보, 검측, 품질, 날씨, 인허가, RAG, 설정) - TanStack Query + Zustand + Tailwind CSS 인프라: - Docker Compose (PostgreSQL pgvector + backend + frontend) - 한국어 README 및 설치 가이드 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import uuid
|
|
from sqlalchemy import String, Integer, Text, ForeignKey, Enum as SAEnum
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
|
from app.core.database import Base
|
|
from app.models.base import TimestampMixin, UUIDMixin
|
|
import enum
|
|
|
|
|
|
class RagSourceType(str, enum.Enum):
|
|
KCS = "kcs"
|
|
LAW = "law"
|
|
REGULATION = "regulation"
|
|
GUIDELINE = "guideline"
|
|
|
|
|
|
class RagSource(Base, UUIDMixin, TimestampMixin):
|
|
__tablename__ = "rag_sources"
|
|
|
|
title: Mapped[str] = mapped_column(String(300), nullable=False)
|
|
source_type: Mapped[RagSourceType] = mapped_column(
|
|
SAEnum(RagSourceType, name="rag_source_type"), nullable=False
|
|
)
|
|
source_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
file_s3_key: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
|
|
# relationships
|
|
chunks: Mapped[list["RagChunk"]] = relationship("RagChunk", back_populates="source", cascade="all, delete-orphan")
|
|
|
|
|
|
class RagChunk(Base, UUIDMixin, TimestampMixin):
|
|
__tablename__ = "rag_chunks"
|
|
|
|
source_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("rag_sources.id"), nullable=False)
|
|
chunk_index: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
# Note: embedding column (VECTOR) added via Alembic migration with pgvector extension
|
|
metadata_: Mapped[dict | None] = mapped_column("metadata", JSONB, nullable=True)
|
|
|
|
# relationships
|
|
source: Mapped["RagSource"] = relationship("RagSource", back_populates="chunks")
|