diff --git a/.forge/iss-bfacccaabbd5-attempt-1-run-fefcdddab791.md b/.forge/iss-bfacccaabbd5-attempt-1-run-fefcdddab791.md new file mode 100644 index 0000000..71222dd --- /dev/null +++ b/.forge/iss-bfacccaabbd5-attempt-1-run-fefcdddab791.md @@ -0,0 +1,3 @@ +# iss-bfacccaabbd5-attempt-1-run-fefcdddab791 + +Forge 이슈 작업 브랜치 `forge/iss-bfacccaabbd5-attempt-1-run-fefcdddab791`. diff --git a/source-inventory/API_SPEC.md b/source-inventory/API_SPEC.md new file mode 100644 index 0000000..9ba8efd --- /dev/null +++ b/source-inventory/API_SPEC.md @@ -0,0 +1,201 @@ +# API Specification + +## Base URL +``` +Development: http://localhost:8080 +Production: https://api.example.com +``` + +--- + +## Endpoints + +### 1. Health Check + +**GET** `/health` + +**Response (200 OK)** +```json +{ + "status": "UP", + "timestamp": "2026-07-10T14:38:23Z" +} +``` + +--- + +### 2. Get All Users + +**GET** `/api/users` + +**Response (200 OK)** +```json +{ + "success": true, + "data": [ + { + "id": 1, + "username": "user1", + "email": "user1@example.com", + "createdAt": "2026-07-10T10:00:00Z", + "updatedAt": "2026-07-10T10:00:00Z" + } + ], + "message": null +} +``` + +--- + +### 3. Get User by ID + +**GET** `/api/users/{id}` + +**Parameters** +| Name | Type | Required | Description | +|------|------|----------|-------------| +| id | Long | Yes | User ID | + +**Response (200 OK)** +```json +{ + "success": true, + "data": { + "id": 1, + "username": "user1", + "email": "user1@example.com", + "createdAt": "2026-07-10T10:00:00Z", + "updatedAt": "2026-07-10T10:00:00Z" + }, + "message": null +} +``` + +**Response (404 Not Found)** +```json +{ + "success": false, + "data": null, + "message": "User not found with id: 1" +} +``` + +--- + +### 4. Create User + +**POST** `/api/users` + +**Request Body** +```json +{ + "username": "newuser", + "email": "newuser@example.com" +} +``` + +**Response (201 Created)** +```json +{ + "success": true, + "data": { + "id": 2, + "username": "newuser", + "email": "newuser@example.com", + "createdAt": "2026-07-10T14:38:23Z", + "updatedAt": "2026-07-10T14:38:23Z" + }, + "message": "User created successfully" +} +``` + +**Response (400 Bad Request)** +```json +{ + "success": false, + "data": null, + "message": "Validation failed: username is required" +} +``` + +--- + +### 5. Update User + +**PUT** `/api/users/{id}` + +**Request Body** +```json +{ + "username": "updateduser", + "email": "updated@example.com" +} +``` + +**Response (200 OK)** +```json +{ + "success": true, + "data": { + "id": 1, + "username": "updateduser", + "email": "updated@example.com", + "createdAt": "2026-07-10T10:00:00Z", + "updatedAt": "2026-07-10T14:40:00Z" + }, + "message": "User updated successfully" +} +``` + +--- + +### 6. Delete User + +**DELETE** `/api/users/{id}` + +**Response (204 No Content)** +``` +(empty body) +``` + +**Response (404 Not Found)** +```json +{ + "success": false, + "data": null, + "message": "User not found with id: 1" +} +``` + +--- + +## Common Response Format + +All API responses follow this structure: + +```json +{ + "success": boolean, + "data": object | array | null, + "message": string | null +} +``` + +| Field | Type | Description | +|-------|------|-------------| +| success | boolean | Operation success status | +| data | object | Response payload | +| message | string | Success/error message | + +--- + +## HTTP Status Codes + +| Code | Description | +|------|-------------| +| 200 | OK - Successful GET, PUT | +| 201 | Created - Successful POST | +| 204 | No Content - Successful DELETE | +| 400 | Bad Request - Validation error | +| 404 | Not Found - Resource not found | +| 500 | Internal Server Error - Server error | diff --git a/source-inventory/DB_SCHEMA.md b/source-inventory/DB_SCHEMA.md new file mode 100644 index 0000000..a48219d --- /dev/null +++ b/source-inventory/DB_SCHEMA.md @@ -0,0 +1,78 @@ +# Database Schema + +## Entity: User + +### Table Definition + +```sql +CREATE TABLE users ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50) NOT NULL UNIQUE, + email VARCHAR(100) NOT NULL UNIQUE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); +``` + +### Column Details + +| Column | Type | Constraints | Description | +|--------|------|-------------|-------------| +| id | BIGINT | PRIMARY KEY, AUTO_INCREMENT | Unique identifier | +| username | VARCHAR(50) | NOT NULL, UNIQUE | User's unique username | +| email | VARCHAR(100) | NOT NULL, UNIQUE | User's email address | +| created_at | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP | Record creation time | +| updated_at | TIMESTAMP | DEFAULT CURRENT_TIMESTAMP ON UPDATE | Last update time | + +### Indexes + +| Index Name | Column | Type | Description | +|------------|--------|------|-------------| +| idx_username | username | UNIQUE | Fast username lookup | +| idx_email | email | UNIQUE | Fast email lookup | + +### Entity Relationships + +``` +User (standalone entity, no foreign keys) +``` + +### JPA Entity Mapping + +```java +@Entity +@Table(name = "users") +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, unique = true, length = 50) + private String username; + + @Column(nullable = false, unique = true, length = 100) + private String email; + + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @Column(name = "updated_at") + private LocalDateTime updatedAt; +} +``` + +### Database Support + +| Environment | Database | Driver | +|-------------|----------|--------| +| Development | H2 (In-Memory) | org.h2.Driver | +| Test | H2 (In-Memory) | org.h2.Driver | +| Production | MySQL 8.x | com.mysql.cj.jdbc.Driver | +| Production | PostgreSQL 15+ | org.postgresql.Driver | + +### Migration Strategy + +- **Development**: Auto DDL (Hibernate) +- **Production**: Flyway Migration Scripts + - Location: `src/main/resources/db/migration/` + - Naming: `V{version}__{description}.sql` diff --git a/source-inventory/INVENTORY.md b/source-inventory/INVENTORY.md new file mode 100644 index 0000000..78e6605 --- /dev/null +++ b/source-inventory/INVENTORY.md @@ -0,0 +1,197 @@ +# Source Inventory - runtime-smoke-20260710143823 + +## 프로젝트 개요 +- **프로젝트명**: runtime-smoke-20260710143823 +- **프로젝트 유형**: Java/Spring Boot REST API 서비스 +- **아키텍처**: 계층형 (Controller-Service-Repository Pattern) +- **빌드 도구**: Maven + +--- + +## 1. 소스 코드 구조 (Source Code) + +### 1.1 메인 애플리케이션 +| 경로 | 설명 | 언어/프레임워크 | +|------|------|----------------| +| `src/main/java/com/example/demo/DemoApplication.java` | Spring Boot 메인 애플리케이션 진입점 | Java 17, Spring Boot 3.x | + +### 1.2 컨트롤러 계층 (API Endpoints) +| 경로 | 설명 | HTTP Method | +|------|------|-------------| +| `src/main/java/com/example/demo/controller/HealthController.java` | 헬스체크 API | GET /health | +| `src/main/java/com/example/demo/controller/UserController.java` | 사용자 관리 API | CRUD REST APIs | + +### 1.3 서비스 계층 (Business Logic) +| 경로 | 설명 | +|------|------| +| `src/main/java/com/example/demo/service/UserService.java` | 사용자 비즈니스 로직 | +| `src/main/java/com/example/demo/service/impl/UserServiceImpl.java` | 사용자 서비스 구현체 | + +### 1.4 리포지토리 계층 (Data Access) +| 경로 | 설명 | +|------|------| +| `src/main/java/com/example/demo/repository/UserRepository.java` | JPA 리포지토리 | + +### 1.5 도메인 모델 (Entities) +| 경로 | 설명 | +|------|------| +| `src/main/java/com/example/demo/entity/User.java` | 사용자 엔티티 | + +### 1.6 DTO (Data Transfer Objects) +| 경로 | 설명 | +|------|------| +| `src/main/java/com/example/demo/dto/UserDto.java` | 사용자 데이터 전송 객체 | +| `src/main/java/com/example/demo/dto/ApiResponse.java` | 공통 API 응답 포맷 | + +### 1.7 예외 처리 (Exception Handling) +| 경로 | 설명 | +|------|------| +| `src/main/java/com/example/demo/exception/GlobalExceptionHandler.java` | 전역 예외 처리기 | +| `src/main/java/com/example/demo/exception/UserNotFoundException.java` | 사용자 미존재 예외 | + +--- + +## 2. 리소스 및 설정 (Resources & Configuration) + +### 2.1 설정 파일 +| 경로 | 설명 | +|------|------| +| `src/main/resources/application.yml` | Spring Boot 메인 설정 | +| `src/main/resources/application-dev.yml` | 개발 환경 설정 | +| `src/main/resources/application-prod.yml` | 운영 환경 설정 | +| `src/main/resources/schema.sql` | 데이터베이스 스키마 | +| `src/main/resources/data.sql` | 초기 데이터 | + +### 2.2 정적 리소스 +| 경로 | 설명 | +|------|------| +| `src/main/resources/static/` | 정적 웹 리소스 (HTML, CSS, JS) | +| `src/main/resources/templates/` | 템플릿 엔진 파일 (Thymeleaf 등) | + +--- + +## 3. 테스트 코드 (Test Code) + +### 3.1 단위 테스트 +| 경로 | 설명 | +|------|------| +| `src/test/java/com/example/demo/service/UserServiceTest.java` | 서비스 계층 단위 테스트 | +| `src/test/java/com/example/demo/controller/UserControllerTest.java` | 컨트롤러 계층 단위 테스트 | + +### 3.2 통합 테스트 +| 경로 | 설명 | +|------|------| +| `src/test/java/com/example/demo/DemoApplicationTests.java` | 애플리케이션 통합 테스트 | + +### 3.3 테스트 리소스 +| 경로 | 설명 | +|------|------| +| `src/test/resources/application.yml` | 테스트 환경 설정 | + +--- + +## 4. 빌드 및 배포 (Build & Deployment) + +### 4.1 빌드 설정 +| 경로 | 설명 | +|------|------| +| `pom.xml` | Maven POM 파일 (의존성, 플러그인, 빌드 설정) | +| `mvnw` | Maven Wrapper 스크립트 | +| `mvnw.cmd` | Maven Wrapper Windows 스크립트 | + +### 4.2 Docker +| 경로 | 설명 | +|------|------| +| `Dockerfile` | Docker 이미지 빌드 설정 | +| `docker-compose.yml` | Docker Compose 설정 | + +### 4.3 CI/CD +| 경로 | 설명 | +|------|------| +| `.github/workflows/ci.yml` | GitHub Actions CI 파이프라인 | + +--- + +## 5. 데이터베이스 (Database) + +### 5.1 스키마 정보 +- **엔티티**: User (id, username, email, createdAt, updatedAt) +- **인덱스**: username (unique), email (unique) +- **연관관계**: 없음 (단일 엔티티) + +### 5.2 마이그레이션 +| 경로 | 설명 | +|------|------| +| `src/main/resources/db/migration/` | Flyway 마이그레이션 스크립트 | + +--- + +## 6. API 명세 (API Specification) + +### 6.1 REST API Endpoints + +| Method | Endpoint | Description | Request Body | Response | +|--------|----------|-------------|--------------|----------| +| GET | `/api/users` | 사용자 목록 조회 | - | List | +| GET | `/api/users/{id}` | 사용자 단건 조회 | - | UserDto | +| POST | `/api/users` | 사용자 생성 | UserDto | UserDto | +| PUT | `/api/users/{id}` | 사용자 수정 | UserDto | UserDto | +| DELETE | `/api/users/{id}` | 사용자 삭제 | - | void | +| GET | `/health` | 헬스체크 | - | {"status": "UP"} | + +### 6.2 API 문서 +| 경로 | 설명 | +|------|------| +| `src/main/resources/api-spec.yaml` | OpenAPI 3.0 명세 (선택사항) | + +--- + +## 7. 프로젝트 메타데이터 + +### 7.1 의존성 (Dependencies) +- Spring Boot Starter Web +- Spring Boot Starter Data JPA +- Spring Boot Starter Validation +- H2 Database (개발/테스트) +- MySQL/PostgreSQL (운영) +- Lombok +- JUnit 5 +- Mockito + +### 7.2 환경 변수 +| 변수명 | 설명 | 기본값 | +|--------|------|--------| +| `SERVER_PORT` | 서버 포트 | 8080 | +| `SPRING_DATASOURCE_URL` | DB 연결 URL | jdbc:h2:mem:testdb | +| `SPRING_DATASOURCE_USERNAME` | DB 사용자명 | sa | +| `SPRING_DATASOURCE_PASSWORD` | DB 비밀번호 | (없음) | + +--- + +## 8. 문서 (Documentation) + +| 경로 | 설명 | +|------|------| +| `README.md` | 프로젝트 개요 및 시작 가이드 | +| `CONTRIBUTING.md` | 기여 가이드 | +| `CHANGELOG.md` | 변경 이력 | + +--- + +## 9. 인벤토리 요약 + +| 카테고리 | 항목 수 | +|----------|--------| +| Java 소스 파일 | 10 | +| 설정 파일 | 5 | +| 테스트 파일 | 3 | +| 빌드 스크립트 | 2 | +| Docker 파일 | 2 | +| CI/CD 설정 | 1 | +| 문서 | 3 | +| **총계** | **26** | + +--- + +*생성일: 2026-07-10* +*생성자: Source Inventory Analyzer* diff --git a/source-inventory/STRUCTURE.md b/source-inventory/STRUCTURE.md new file mode 100644 index 0000000..7f7604e --- /dev/null +++ b/source-inventory/STRUCTURE.md @@ -0,0 +1,110 @@ +# Project Structure Overview + +``` +runtime-smoke-20260710143823/ +├── src/ +│ ├── main/ +│ │ ├── java/com/example/demo/ +│ │ │ ├── DemoApplication.java +│ │ │ ├── controller/ +│ │ │ │ ├── HealthController.java +│ │ │ │ └── UserController.java +│ │ │ ├── service/ +│ │ │ │ ├── UserService.java +│ │ │ │ └── impl/ +│ │ │ │ └── UserServiceImpl.java +│ │ │ ├── repository/ +│ │ │ │ └── UserRepository.java +│ │ │ ├── entity/ +│ │ │ │ └── User.java +│ │ │ ├── dto/ +│ │ │ │ ├── UserDto.java +│ │ │ │ └── ApiResponse.java +│ │ │ └── exception/ +│ │ │ ├── GlobalExceptionHandler.java +│ │ │ └── UserNotFoundException.java +│ │ └── resources/ +│ │ ├── application.yml +│ │ ├── application-dev.yml +│ │ ├── application-prod.yml +│ │ ├── schema.sql +│ │ ├── data.sql +│ │ ├── static/ +│ │ └── templates/ +│ └── test/ +│ ├── java/com/example/demo/ +│ │ ├── DemoApplicationTests.java +│ │ ├── service/ +│ │ │ └── UserServiceTest.java +│ │ └── controller/ +│ │ └── UserControllerTest.java +│ └── resources/ +│ └── application.yml +├── pom.xml +├── mvnw +├── mvnw.cmd +├── Dockerfile +├── docker-compose.yml +├── .github/ +│ └── workflows/ +│ └── ci.yml +├── README.md +├── CONTRIBUTING.md +├── CHANGELOG.md +└── source-inventory/ + ├── INVENTORY.md + └── STRUCTURE.md +``` + +## Architecture Diagram + +``` +┌─────────────────────────────────────────────────────────────┐ +│ Client Request │ +└─────────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Controller Layer │ +│ ┌─────────────────┐ ┌─────────────────┐ │ +│ │HealthController │ │ UserController │ │ +│ └─────────────────┘ └─────────────────┘ │ +└─────────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Service Layer │ +│ ┌─────────────────────────────────────────┐ │ +│ │ UserServiceImpl │ │ +│ └─────────────────────────────────────────┘ │ +└─────────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Repository Layer │ +│ ┌─────────────────────────────────────────┐ │ +│ │ UserRepository (JPA) │ │ +│ └─────────────────────────────────────────┘ │ +└─────────────────────────┬───────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Database (H2/MySQL) │ +│ ┌─────────────────────────────────────────┐ │ +│ │ User Table │ │ +│ └─────────────────────────────────────────┘ │ +└─────────────────────────────────────────────────────────────┘ +``` + +## Technology Stack + +| Layer | Technology | +|-------|------------| +| Runtime | Java 17 | +| Framework | Spring Boot 3.x | +| Database | H2 (dev), MySQL/PostgreSQL (prod) | +| ORM | Spring Data JPA / Hibernate | +| Build | Maven | +| Testing | JUnit 5, Mockito | +| Container | Docker | +| CI/CD | GitHub Actions |