Skip to content

[Feat] 자소서 분석 API 구현 (#24)#61

Merged
whc9999 merged 1 commit into
mainfrom
feat/#24-analysis
May 22, 2026
Merged

[Feat] 자소서 분석 API 구현 (#24)#61
whc9999 merged 1 commit into
mainfrom
feat/#24-analysis

Conversation

@whc9999
Copy link
Copy Markdown
Collaborator

@whc9999 whc9999 commented May 22, 2026

✨ 어떤 이유로 PR를 하셨나요?

  • feature 병합
  • 버그 수정(아래에 issue #를 남겨주세요)
  • 코드 개선
  • 코드 수정
  • 배포
  • 기타(아래에 자세한 내용 기입해주세요)

📋 세부 내용 - 왜 해당 PR이 필요한지 작업 내용을 자세하게 설명해주세요

  • 자소서 분석 실행 API 추가
  • 자소서 분석 결과 조회 API 추가
  • 저장된 문항 답변과 공고 정보를 기반으로 LLM 분석 프롬프트 구성
  • LLM JSON 응답을 Analysis 및 QuestionAnalysis 엔티티로 저장
  • 재분석 시 기존 분석 결과와 문항 분석 결과를 교체하도록 처리
  • 분석 완료 시 MockApply 상태를 COMPLETED로 변경
  • 원문에 존재하지 않는 분석 sentence는 저장하지 않도록 검증
  • start/end index를 서버에서 answer 기준으로 계산
  • 점수를 0~100 범위로 보정
  • 분석 결과 응답 DTO 및 LLM 응답 DTO 추가
  • 분석 결과 없음 예외 코드 추가
  • 로컬 실행 기본 프로필을 dev로 설정하고 dev JWT 기본값 추가
  • 자소서 분석 서비스 테스트 추가

📸 작업 화면 스크린샷

⚠️ PR하기 전에 확인해주세요

  • 로컬테스트를 진행하셨나요?
  • 머지할 브랜치를 확인하셨나요?
  • 관련 label을 선택하셨나요?

🚨 관련 이슈 번호 [#24]

Summary by CodeRabbit

  • New Features

    • Added analysis functionality for mock applications, enabling users to run AI-powered reviews of self-introduction letters and retrieve detailed feedback including overall scores, job fit assessment, impact rating, and completeness evaluation with sentence-level analysis for each question.
  • Tests

    • Added comprehensive test coverage for the new analysis feature.
  • Chores

    • Updated configuration to support environment-based profile activation and JWT secret management.

Review Change Stack

- 자소서 분석 실행 API 추가
- 자소서 분석 결과 조회 API 추가
- 저장된 문항 답변과 공고 정보를 기반으로 LLM 분석 프롬프트 구성
- LLM JSON 응답을 Analysis 및 QuestionAnalysis 엔티티로 저장
- 재분석 시 기존 분석 결과와 문항 분석 결과를 교체하도록 처리
- 분석 완료 시 MockApply 상태를 COMPLETED로 변경
- 원문에 존재하지 않는 분석 sentence는 저장하지 않도록 검증
- start/end index를 서버에서 answer 기준으로 계산
- 점수를 0~100 범위로 보정
- 분석 결과 응답 DTO 및 LLM 응답 DTO 추가
- 분석 결과 없음 예외 코드 추가
- 로컬 실행 기본 프로필을 dev로 설정하고 dev JWT 기본값 추가
- 자소서 분석 서비스 테스트 추가
@whc9999 whc9999 merged commit 02a543c into main May 22, 2026
1 of 2 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c57684b3-325a-4eaa-9bf9-f468acb788bf

📥 Commits

Reviewing files that changed from the base of the PR and between c2b7e77 and a43c451.

📒 Files selected for processing (14)
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/llm/AnalysisLlmResponse.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/AnalysisQuestionResponse.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/AnalysisResponse.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/QuestionAnalysisResponse.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/entity/Analysis.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisAiClient.java
  • src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisService.java
  • src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApply.java
  • src/main/java/com/jobdri/jobdri_api/global/apiPayload/code/GeneralErrorCode.java
  • src/main/resources/application-dev.yaml
  • src/main/resources/application.yaml
  • src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java

📝 Walkthrough

Walkthrough

This PR introduces a complete AI-powered analysis feature for mock job applications. It enables users to request AI-generated feedback on their self-introduction answers against job postings, persists analysis results with question-level insights, and provides endpoints to retrieve prior analyses. The feature integrates with OpenAI using structured output, validates user ownership, and includes comprehensive test coverage.

Changes

AI-Powered Mock Application Analysis

Layer / File(s) Summary
Analysis Response Contracts
src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/llm/AnalysisLlmResponse.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/QuestionAnalysisResponse.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/AnalysisQuestionResponse.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/dto/response/AnalysisResponse.java
Defines response DTOs capturing LLM analysis output (scores, feedback, per-question insights) and nested response structures with factory methods for mapping from entities.
OpenAI Integration Client
src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisAiClient.java
Integrates with OpenAI Responses API, builds structured prompts from job posting and questions, calls OpenAI with typed output expectations, and extracts results with error handling (converts non-GeneralException failures to SERVICE_UNAVAILABLE).
Analysis Service Orchestration
src/main/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisService.java
Orchestrates full analysis workflow: validates answer content, invokes AI client, replaces prior analysis (clearing old question-level records), persists new Analysis and QuestionAnalysis entries with clamped scores and normalized feedback, updates MockApply status to COMPLETED, and retrieves results grouped by question with ownership enforcement.
REST Controller
src/main/java/com/jobdri/jobdri_api/domain/analysis/controller/AnalysisController.java
Exposes POST /api/mock-applies/{mockApplyId}/analysis to trigger analysis and GET to retrieve saved results; extracts and validates authenticated user context; wraps responses in ApiResponse.onSuccess.
Data Persistence & Configuration
src/main/java/com/jobdri/jobdri_api/domain/analysis/entity/Analysis.java, src/main/java/com/jobdri/jobdri_api/domain/analysis/repository/QuestionAnalysisRepository.java, src/main/java/com/jobdri/jobdri_api/domain/mockapply/entity/MockApply.java, src/main/java/com/jobdri/jobdri_api/global/apiPayload/code/GeneralErrorCode.java, src/main/resources/application*.yaml
Updates Analysis.create(...) to return directly without explicit mockApply assignment; adds repository methods to query/delete QuestionAnalysis by analysisId; adds clearAnalysis() helper to MockApply; introduces ANALYSIS_NOT_FOUND error code; configures JWT secret and Spring profiles from environment variables with dev defaults.
Service Test Suite
src/test/java/com/jobdri/jobdri_api/domain/analysis/service/AnalysisServiceTest.java
Transactional tests validating successful analysis runs with persisted results, rejection of empty answers and unauthorized requests, sentence-level filtering when LLM output does not match answers, analysis replacement on re-runs, and retrieval of saved analyses; includes test fixture helpers for domain objects.

Sequence Diagram

sequenceDiagram
  participant User
  participant AnalysisController
  participant AnalysisService
  participant AnalysisAiClient
  participant OpenAIClient
  participant Database
  User->>AnalysisController: POST /api/mock-applies/{id}/analysis
  AnalysisController->>AnalysisService: analyze(user, mockApplyId)
  AnalysisService->>AnalysisService: Load & authorize MockApply
  AnalysisService->>AnalysisService: Gather questions & validate answers
  AnalysisService->>AnalysisAiClient: analyze(jobPosting, questions)
  AnalysisAiClient->>OpenAIClient: responses().create(prompt, expectedType)
  OpenAIClient-->>AnalysisAiClient: AnalysisLlmResponse
  AnalysisAiClient-->>AnalysisService: AnalysisLlmResponse
  AnalysisService->>Database: Delete prior QuestionAnalysis
  AnalysisService->>Database: Delete prior Analysis
  AnalysisService->>Database: Save new Analysis & QuestionAnalysis
  AnalysisService->>Database: Update MockApply status to COMPLETED
  AnalysisService-->>AnalysisController: AnalysisResponse
  AnalysisController-->>User: ApiResponse.onSuccess(AnalysisResponse)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A rabbit hops through OpenAI's domain,
To analyze each question, each answer, each name,
Smart scores and feedback now swiftly appear,
MockApply meets AI—the future is here! 🚀

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#24-analysis

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant