Skip to content

chore: AI 서버 구조 및 CI/CD 설정 정비#2

Merged
deli-minju merged 4 commits into
developfrom
chore/#1-ci-cd-setup
May 18, 2026
Merged

chore: AI 서버 구조 및 CI/CD 설정 정비#2
deli-minju merged 4 commits into
developfrom
chore/#1-ci-cd-setup

Conversation

@deli-minju
Copy link
Copy Markdown
Contributor

@deli-minju deli-minju commented May 18, 2026

📌 작업 요약

  • 요약:
    • GACHI-AI 서버 구조를 router, schema, service 중심으로 정리
    • 날짜 후보 기반 항목 추출 baseline과 prompt-preview API 추가
    • CodeRabbit 설정과 GitHub Actions quality/Docker/deploy workflow 정비
    • AI 서버 환경변수, 배포 방식, 가정통신문 추출/라벨링 기준 문서 정리
    • 일반 PR 템플릿과 릴리즈 PR 템플릿 분리
  • 관련 이슈: closes [TASK] AI 서버 구조 및 CI/CD 설정 정비 #1

🌿 브랜치 정보

  • Source: chore/#1-ci-cd-setup
  • Target: develop (기본)

✅ 체크리스트

  • 브랜치 컨벤션 준수 (feat/refac/hotfix/chore/design/bugfix)
  • 커밋 컨벤션 준수 (feat/fix/refactor/docs/style/chore)
  • self-review 완료
  • 테스트 및 로컬 실행 확인 완료

🧪 테스트 결과

  • 로컬 가상환경 생성 후 의존성 설치 확인
  • ruff check .
    • 결과: 통과
  • ruff format --check .
    • 결과: 통과
  • python -m compileall app
    • 결과: 통과
  • pytest
    • 결과: tests 디렉터리가 없어 실행 대상 없음
  • git diff --check
    • 결과: 통과
  • secret scan
    • 결과: GitHub token, OpenAI API key, DockerHub token, AWS secret key 패턴 매칭 없음

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 뉴스레터 항목 자동 추출 API 추가 - 규칙 기반 일정, 마감, 체크리스트, 알림 항목 추출
    • 프롬프트 미리보기 API 추가 - 추출 전 AI 프롬프트 및 예상 결과 확인 가능
    • 서버 헬스 체크 엔드포인트 추가
  • 문서

    • README 개선 - 로컬 실행 방법 및 주요 엔드포인트 문서화
    • 배포 가이드 및 환경 설정 문서 추가
    • 뉴스레터 추출 규칙 및 라벨링 가이드 문서 추가
  • Chores

    • GitHub Actions 워크플로우 최적화 및 EC2 배포 자동화 강화

Review Change Stack

@deli-minju deli-minju self-assigned this May 18, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@deli-minju has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 52 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4af0b5d7-2991-4839-8f93-c45fc3b5fa97

📥 Commits

Reviewing files that changed from the base of the PR and between ffa82ee and 4a0ba84.

📒 Files selected for processing (5)
  • .github/PULL_REQUEST_TEMPLATE/release.md
  • .github/workflows/docker-ai.yml
  • .github/workflows/quality-ai.yml
  • README.md
  • app/schemas.py
📝 Walkthrough

개요

FastAPI 애플리케이션을 라우터 중심 구조로 재구성하고, Pydantic 스키마 기반 뉴스레터 추출 서비스를 구현했으며, GitHub Actions를 통한 CI/CD 파이프라인과 EC2 자동 배포 워크플로우를 설정하고, 프로젝트 문서 및 설정을 정비했습니다.

변경 사항

AI 서버 구조 및 CI/CD 정비

레이어 / 파일(들) 설명
데이터 스키마 및 의존성 정의
requirements.txt, app/schemas.py
Pydantic >=2.0 의존성을 추가하고 ExtractedItemType, DateStatus, DateCandidate, NewsletterExtractionRequest, ExtractedItem, NewsletterExtractionResponse, PromptMessage, PromptPreviewResponse 등 9개의 스키마를 정의해 뉴스레터 추출 API의 데이터 계약을 수립합니다.
FastAPI 라우터 구조 재구성
app/main.py, app/routers/health.py, app/routers/newsletters.py
main.py의 인라인 엔드포인트를 독립 라우터 모듈로 분리하고, /ai 프리픽스 하위에 /health, /ping, /newsletters/extract-items, /newsletters/prompt-preview 엔드포인트를 등록합니다.
뉴스레터 추출 및 프롬프트 서비스
app/services/newsletter_extractor.py, app/services/newsletter_prompt.py
규칙 기반 뉴스레터 항목 추출(마감/일정/체크리스트/알림 분류, 증거 텍스트 추출, 신뢰도 계산), 누락 항목 검출, LLM 프롬프트 생성(시스템/사용자 프롬프트, JSON 스키마 정의)을 구현합니다.
품질 검사 및 Docker CI 워크플로우
.github/workflows/quality-ai.yml, .github/workflows/docker-ai.yml
ruff check/format, python -m compileall, 조건부 pytest 실행을 포함한 품질 워크플로우를 구성하고, PR 빌드 검증과 push 시 이미지 배포를 분리한 Docker CI 파이프라인을 설정합니다.
EC2 배포 워크플로우 및 AWS 인증
.github/workflows/deploy-ai-ec2.yml
workflow_run 또는 workflow_dispatch 트리거로 EC2 인스턴스 SSM 커맨드를 실행해 .envAI_IMAGE 갱신, docker compose pull/up, 헬스 체크, nginx 재시작을 자동화하며, OIDC 또는 액세스 키 기반 AWS 인증을 조건부 구성합니다.
프로젝트 문서 및 설정
.coderabbit.yaml, .github/PULL_REQUEST_TEMPLATE/release.md, .github/pull_request_template.md, README.md, docs/env.md, docs/deploy.md, docs/newsletter-extraction.md, docs/newsletter-labeling-guide.md
CodeRabbit 설정(docstring 검사 비활성화, pre-merge checks), PR 템플릿(일반/릴리즈), README(서버 역할, 로컬 실행, 주요 엔드포인트), 환경 변수 문서(한국어), 배포 절차(SSM 자동 배포), 뉴스레터 추출 설계(목표/엔드포인트/규칙), 라벨링 가이드(분류/상태 정의)를 정리합니다.

Sequence Diagrams

sequenceDiagram
  participant Client
  participant NewsletterRouter
  participant NewsletterExtractor
  participant NewsletterPrompt
  participant Response

  Client->>NewsletterRouter: POST /ai/newsletters/extract-items
  NewsletterRouter->>NewsletterExtractor: extract_newsletter_items(request)
  NewsletterExtractor->>NewsletterExtractor: 날짜 후보 기반 항목 추출
  NewsletterExtractor->>NewsletterExtractor: 누락 체크리스트 항목 검출
  NewsletterExtractor->>Response: NewsletterExtractionResponse (항목 + 메타데이터)
  Response-->>Client: 규칙 기반 baseline 결과 반환

  Client->>NewsletterRouter: POST /ai/newsletters/prompt-preview
  NewsletterRouter->>NewsletterPrompt: build_prompt_messages(request)
  NewsletterPrompt->>NewsletterPrompt: 시스템 프롬프트 생성
  NewsletterPrompt->>NewsletterPrompt: 사용자 프롬프트 + 날짜 후보 포맷
  Response-->>Client: PromptPreviewResponse (메시지 + 응답 스키마)
Loading
sequenceDiagram
  participant GitHub as GitHub<br/>Actions
  participant Push as Push Event<br/>(develop/main)
  participant PullRequest as Pull Request<br/>Event
  participant QualityJob as Quality Job
  participant DockerJob as Docker Job
  participant DeployJob as Deploy Job<br/>(main only)

  Push->>QualityJob: 트리거 (develop/main)
  QualityJob->>QualityJob: ruff check, format, compileall, pytest
  QualityJob-->>GitHub: 품질 검사 결과

  PullRequest->>DockerJob: PR 생성 시 트리거
  DockerJob->>DockerJob: Docker 이미지 빌드 (푸시 안함)
  DockerJob-->>GitHub: 빌드 검증 완료

  Push->>DockerJob: main push 시 트리거
  DockerJob->>DockerJob: Docker 이미지 빌드 & 푸시
  DockerJob-->>GitHub: latest/develop 태그 푸시 완료

  GitHub->>DeployJob: upstream docker-ai 성공<br/>또는 workflow_dispatch
  DeployJob->>DeployJob: AWS 인증 (OIDC/Access Key)
  DeployJob->>DeployJob: EC2 SSM 커맨드 전송
  DeployJob->>DeployJob: .env AI_IMAGE 갱신
  DeployJob->>DeployJob: docker compose pull/up
  DeployJob->>DeployJob: 헬스 체크 & nginx 재시작
  DeployJob-->>GitHub: 배포 완료
Loading

예상 코드 리뷰 비용

🎯 3 (Moderate) | ⏱️ ~25 분

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive PR 설명이 요약, 브랜치 정보, 체크리스트를 포함하고 있으나, 제공된 템플릿의 '변경 타입' 섹션이 누락되어 있습니다. PR 설명에 '## 🧩 변경 타입' 섹션을 추가하여 chore 타입을 명시적으로 표시하면 템플릿 준수가 완전해집니다.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 PR의 주요 변경 사항인 AI 서버 구조 정리 및 CI/CD 설정 개선을 명확하게 요약하고 있습니다.
Linked Issues check ✅ Passed PR의 모든 코드 레벨 변경사항이 이슈 #1의 완료 조건을 충족합니다. 라우터/스키마/서비스 구조 정리, API 구현, 워크플로우 분리, compileall 검증, 문서화가 모두 포함되어 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #1의 범위 내에 포함됩니다. 구조 정리, 설정 업데이트, 워크플로우 정비, 문서화 등이 명확하게 목표와 연결되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/#1-ci-cd-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@deli-minju deli-minju added the chore 빌드, 설정, 의존성, 운영성 작업 label May 18, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/PULL_REQUEST_TEMPLATE/release.md:
- Line 21: Update the workflow identifier text on line 21 to match the actual
deployment workflow for this PR: replace the current `deploy-ec2` reference with
the real workflow id/name used in the repo (`deploy-ai-ec2` or the workflow
display name `Deploy AI to EC2`) so the template accurately points to the
correct GitHub Actions workflow when verifying `workflow_dispatch` on `main`;
adjust the string in .github/PULL_REQUEST_TEMPLATE/release.md to exactly match
the workflow file name `deploy-ai-ec2.yml` or its canonical identifier.
- Line 1: 현재 템플릿의 최상위 제목이 '## 📌 작업 요약'으로 되어 있어 markdownlint MD041 경고를 발생시키므로 상단
헤더 토큰을 '##'에서 H1인 '#'로 변경하세요; 즉 파일의 최상위 제목 문자열 '## 📌 작업 요약'을 '# 📌 작업 요약'으로 바꾸고
변경 후 markdownlint/CI에서 MD041 경고가 사라지는지 확인하세요.

In @.github/workflows/docker-ai.yml:
- Around line 49-53: 현재 GITHUB_REF_NAME 검사 로직은 main이 아닌 모든 ref에 대해 :develop 태그를
붙여 workflow_dispatch로 feature 브랜치에서 실행하면 develop 이미지가 덮어써질 수 있으므로,
GITHUB_REF_NAME을 기준으로 분기해 main일 때는
tags="${IMAGE}:latest,${IMAGE}:sha-${SHORT_SHA}", develop일 때는
tags="${IMAGE}:develop,${IMAGE}:sha-${SHORT_SHA}"로 별도 처리하고, 그 외 브랜치(예:
feature/*)는
tags="${IMAGE}:branch-${GITHUB_REF_NAME},${IMAGE}:sha-${SHORT_SHA}"처럼 브랜치명 기반
태그만 생성하도록 수정하세요; 또한 푸시 단계(docker push 사용하는 곳)는 main 또는 develop에 대해서만
:latest/:develop 를 푸시하도록 제한하거나 푸시할 태그 목록을 위에서 생성한 tags 변수에 따라 결정하도록 변경하여 feature
브랜치가 develop 태그를 덮어쓰지 않게 하세요.

In `@app/schemas.py`:
- Around line 21-27: The DateCandidate model lacks offset validation causing bad
evidence slicing; add Pydantic validation (e.g., `@root_validator` or field
validators) in DateCandidate to enforce that start_offset and end_offset are
non-negative, that end_offset >= start_offset, and that end_offset does not
exceed len(original_text) (and start_offset <= len(original_text)) and raise a
ValueError with a clear message when invalid; reference the DateCandidate class
and the start_offset, end_offset and original_text fields when implementing the
checks.
- Around line 29-31: Replace the Pydantic v1-style class Config block (the class
named Config that sets allow_population_by_field_name and populate_by_name) with
the v2 configuration pattern by adding a module or model attribute named
model_config that uses ConfigDict(populate_by_name=True); remove
allow_population_by_field_name and populate_by_name from the class Config and
ensure any models using class Config now define model_config = ConfigDict(...)
so the models use Pydantic v2 config API.

In `@README.md`:
- Line 36: Update the branch example to match the repository's branch naming
convention by replacing the inconsistent example
`chore-issue-1-ai-server-ci-cd-setup` with the slash-separated pattern
`chore/issue-1-ai-server-ci-cd-setup` so it aligns with the existing `feat/...`
example and the checklist conventions in README (update the example text where
`feat/issue-1-feature-name` and the chore example appear).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d0c44c86-f18d-4b21-8979-fb8b7a34c720

📥 Commits

Reviewing files that changed from the base of the PR and between db4278f and ffa82ee.

📒 Files selected for processing (18)
  • .coderabbit.yaml
  • .github/PULL_REQUEST_TEMPLATE/release.md
  • .github/pull_request_template.md
  • .github/workflows/deploy-ai-ec2.yml
  • .github/workflows/docker-ai.yml
  • .github/workflows/quality-ai.yml
  • README.md
  • app/main.py
  • app/routers/health.py
  • app/routers/newsletters.py
  • app/schemas.py
  • app/services/newsletter_extractor.py
  • app/services/newsletter_prompt.py
  • docs/deploy.md
  • docs/env.md
  • docs/newsletter-extraction.md
  • docs/newsletter-labeling-guide.md
  • requirements.txt

@@ -0,0 +1,31 @@
## 📌 작업 요약
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

최상위 제목 레벨을 H1으로 맞춰 주세요.

Line 1은 ##로 시작해서 markdownlint MD041 경고를 유발합니다. #로 올리는 게 맞습니다.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 1-1: First line in a file should be a top-level heading

(MD041, first-line-heading, first-line-h1)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/PULL_REQUEST_TEMPLATE/release.md at line 1, 현재 템플릿의 최상위 제목이 '## 📌
작업 요약'으로 되어 있어 markdownlint MD041 경고를 발생시키므로 상단 헤더 토큰을 '##'에서 H1인 '#'로 변경하세요; 즉
파일의 최상위 제목 문자열 '## 📌 작업 요약'을 '# 📌 작업 요약'으로 바꾸고 변경 후 markdownlint/CI에서 MD041
경고가 사라지는지 확인하세요.

Comment thread .github/PULL_REQUEST_TEMPLATE/release.md Outdated
Comment thread .github/workflows/docker-ai.yml Outdated
Comment thread app/schemas.py
Comment thread app/schemas.py Outdated
Comment thread README.md Outdated
@deli-minju deli-minju requested a review from Hminkyung May 18, 2026 15:01
Copy link
Copy Markdown
Collaborator

@Hminkyung Hminkyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인 완료했습니당!!! 고생하셨습니다ㅏㅏㅏㅏ

@deli-minju deli-minju merged commit 629ad96 into develop May 18, 2026
3 checks passed
@deli-minju deli-minju deleted the chore/#1-ci-cd-setup branch May 18, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore 빌드, 설정, 의존성, 운영성 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] AI 서버 구조 및 CI/CD 설정 정비

2 participants