stella.choi be 과제 제출#12
Open
choiyoorim wants to merge 16 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🏷 Stock 주식 정보 제공 API
🚀 Spring Boot 기반의 주식 종가 조회 API
✅ RESTful API 설계 | ✅ MySQL 연동 | ✅ JPA 및 Query 최적화 | ✅ Swagger API 문서화
📌 프로젝트 개요
Stock 주식 정보 제공 API는 특정 기업의 주식 종가 데이터를 조회하는 기능을 제공합니다.
JPA와 MySQL을 활용하여 데이터를 관리하며, API Key 기반의 인증을 적용하였습니다.
또한, Swagger를 사용하여 API 문서를 자동 생성하여 편리한 테스트 환경을 제공합니다.
📌 기술 스택
Backend
Dependencies
** 현재 테스트 코드는 시간상 도입 못해서 나중에 수정 예정
📌 API 명세서 (Swagger UI)
API 명세는 Swagger OpenAPI를 통해 제공되며, 실행 후 다음 URL에서 확인 가능합니다.
🔗 Swagger UI
📌 특별히 신경 쓴 부분
📍 1. RESTful API 설계
✅ URI를 리소스 중심으로 설계 (/api/v1/stock/history) -> 이후 stock 관련 기능 추가를 고려해 history로 한번 더 분리
✅ HTTP 메서드를 의미에 맞게 사용 (GET은 조회, POST는 생성)
📍 2. API Key 보안 강화
✅ 하드코딩된 API Key 제거 → application.yml에서 환경 변수로 관리
✅ @value("${api.key}")를 사용하여 API Key를 동적으로 주입
✅ 인증 실패 시 403 Forbidden 응답 반환
📍 3. 예외 처리 (GlobalExceptionHandler 적용)
✅ @RestControllerAdvice를 활용하여 예외를 중앙에서 관리
✅ API 요청 검증 (필수 파라미터 누락, 날짜 형식 오류 등)을 ErrorCode Enum과 함께 구조화
✅ 일관된 에러 응답 포맷 유지
📍 4. 계층형 아키텍처 구현 (Layered Architecture 적용)
✅ Controller - Service - Repository 계층 분리하여 역할별 책임을 명확히 구분
✅ Controller: 클라이언트 요청을 처리하고 응답을 반환
✅ Service: 비즈니스 로직을 수행하고, 데이터 검증 및 변환 처리
✅ Repository: 데이터베이스와의 직접적인 연결 및 CRUD 수행 (JPA 활용)
✅ DTO (Data Transfer Object) 도입
📌 트러블슈팅 (문제 해결 과정)