부모 티켓
1개 티켓

백로그

0
티켓 없음

할 일

0
티켓 없음

진행 중

0
티켓 없음

리뷰

1
높음 49797882
서브 티켓 [P3] Ai::BlueprintGeneratorService

Ai::BlueprintGeneratorService — Claude API + build_steps 자동 생성 + dev_level 스택 분기 + 테스트

## 목표 PRD Section 13.2 기반 Ai::BlueprintGeneratorService 구현. 개발 수준별 스택 추천, blueprint 필드 업데이트, build_steps 6단계 자동 생성. ## 현재 상태 - Ai::IdeaAnalyzerService 패턴 참고 가능 (app/services/ai/idea_analyzer_service.rb) - Project 모델: tech_stack, tech_stack_reason, db_schema_draft(jsonb), pages_list(jsonb), dev_priority(jsonb) 필드 존재 - BuildStep 모델: belongs_to :project, step_number, title, description, prompt_template, completed - User: dev_level enum (none: 0, basic: 1, intermediate: 2, developer: 3) ## PRD 코드 (Section 13.2) ```ruby class Ai::BlueprintGeneratorService TECH_STACKS = { "none" => "Rails 8.1 + PostgreSQL + Hotwire + Tailwind CSS", "basic" => "Rails 8.1 + PostgreSQL + Hotwire + Tailwind CSS", "intermediate" => "Rails 8.1 + PostgreSQL + Hotwire + Tailwind CSS", "developer" => "Rails 8.1 API + Next.js 15 + PostgreSQL + Tailwind CSS" }.freeze def initialize(project:, user:) @project = project @user = user @client = Anthropic::Client.new(api_key: ENV["ANTHROPIC_API_KEY"]) end def call response = @client.messages( model: "claude-sonnet-4-6", max_tokens: 3000, system: system_prompt, messages: [{ role: "user", content: user_prompt }] ) data = JSON.parse(response.content.first.text.strip) save_blueprint(data) create_default_build_steps end private # system_prompt, user_prompt, save_blueprint, create_default_build_steps # (PRD 코드 그대로 구현) def save_blueprint(data) @project.update!( tech_stack: data["tech_stack"], tech_stack_reason: data["tech_stack_reason"], db_schema_draft: data["db_schema"], pages_list: data["pages"], dev_priority: data["dev_priority"] ) end def create_default_build_steps steps = [ { step_number: 1, title: "프로젝트 초기화", prompt_template: "Rails 8.1.2 프로젝트를 생성하고 CLAUDE.md를 프로젝트에 적용해줘" }, { step_number: 2, title: "DB 구조 생성", prompt_template: "CLAUDE.md의 DB 스키마대로 모델과 마이그레이션을 생성해줘" }, { step_number: 3, title: "인증 구현", prompt_template: "Rails 8 내장 Authentication Generator로 이메일 로그인을 구현해줘" }, { step_number: 4, title: "핵심 기능 구현", prompt_template: "가장 중요한 핵심 기능 1개를 먼저 구현해줘" }, { step_number: 5, title: "랜딩페이지", prompt_template: "다크 테마, 라임 포인트 컬러로 랜딩페이지를 만들어줘" }, { step_number: 6, title: "배포", prompt_template: "Kamal 2 + Vultr으로 배포 설정을 완료해줘" }, ] steps.each do |step_attrs| @project.build_steps.find_or_create_by(step_number: step_attrs[:step_number]) do |step| step.assign_attributes(step_attrs) end end end end ``` ### 구현 사항 1. **app/services/ai/blueprint_generator_service.rb** — PRD 코드 기반 2. **IdeaAnalyzerService와 동일한 패턴**: 의존성 주입(client:), 에러 처리, JSON 코드블록 strip 3. **에러 처리**: JSON::ParserError, API 에러, API 키 미설정 4. **테스트** (API mock): - 성공: project blueprint 필드 업데이트 + build_steps 6개 생성 - TECH_STACKS 상수 확인 - dev_level별 분기 - JSON 파싱 실패 - 기존 build_steps 있을 때 find_or_create_by 동작 (중복 방지) ### ⚠️ 주의 - app/services/ai/ 범위만 수정 (developer-1은 learn/ 작업 중) - Project, User, BuildStep 모델 건드리지 않기 - IdeaAnalyzerService 패턴과 일관성 유지 ### 완료 기준 - 서비스 호출 시 blueprint 필드 업데이트 - build_steps 6개 자동 생성 - 개발 수준별 스택 분기 - 서비스 테스트 통과 (API mock) - bin/rails test 전체 통과

D
developer-2
25 days

완료 (전체)

0
티켓 없음