Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"permissions": {
"allow": [
"Bash(./gradlew test:*)",
"Bash(./gradlew :apps:commerce-api:test:*)"
]
Comment on lines +3 to +6
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -type f -name "*.gradle*" -o -name "settings.gradle*" | head -20

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 451


🏁 Script executed:

cat -n ".claude/settings.local.json" 2>/dev/null || echo "File not found"

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 270


🏁 Script executed:

# 저장소 루트 구조 확인
ls -la | grep -E "^\." && echo "---" && ls -la | head -20

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 67


🏁 Script executed:

cat -n settings.gradle.kts

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 1230


🏁 Script executed:

head -50 build.gradle.kts

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 1361


🏁 Script executed:

head -50 ./apps/commerce-api/build.gradle.kts

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 1003


🏁 Script executed:

# Gradle에서 wildcard 패턴이 실제로 동작하는지 확인
# 프로젝트 구조와 가능한 태스크 확인
rg "test" --type gradle -A 2 | head -40

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 233


🌐 Web query:

Gradle wildcard task pattern syntax colon test:*

💡 Result:

In Gradle task paths, : is a separator, not a wildcard operator. So test:* (or :test:*) is not valid Gradle task-selection syntax—Gradle doesn’t support * wildcards for choosing tasks by name/path on the command line. Instead, Gradle supports task selectors (e.g., test runs the test task across subprojects) and name abbreviation (unique prefixes / camel-case abbreviations). [1]

What to use instead:

  • Run test for all subprojects (from the root):

    • ./gradlew test (task selector across the multi-project build) [1]
  • Run test in one subproject:

    • ./gradlew :subproject:test (or subproject:test) [1]
  • If you meant “wildcard” for tests inside the test task (not tasks):

    • ./gradlew test --tests '*SomePattern*' (test filtering supports *) [2]

Sources:
[1] Gradle User Manual – Command-Line Interface (multi-project task paths, task selectors, name abbreviation) (docs.gradle.org)
[2] Gradle User Manual – Testing in Java & JVM projects (test filtering, --tests, wildcard *) (docs.gradle.org)

Citations:


🌐 Web query:

Gradle task selector patterns documentation

💡 Result:

Gradle documents “task selector patterns” as task paths/selectors plus name abbreviation (pattern expansion) in the Gradle User Manual:

  • Task selectors / task paths (multi-project):

    • Run a task in a specific project with a path like :subproject:taskName (or subproject:taskName).
    • Run a task across subprojects by specifying only the task name from the root (e.g., gradle test runs test in all subprojects that have it).
      Source: Gradle Command-Line Interface → “Executing tasks in multi-project builds”. [1]
  • Name abbreviation / “patterns” (what most people mean by selector patterns):

    • You can type a unique prefix (e.g., gradle checheck).
    • You can use camel-case patterns that also match kebab-case (e.g., foBa or fB matches fooBar and foo-bar).
    • Also works for project names (e.g., gradle mAL:cT).
      Source: Gradle Command-Line Interface → “Name abbreviation”. [1]

If you want the shorter “basics” page for task paths (but it doesn’t cover the abbreviation patterns in as much detail), see: Command-Line Interface Basics → “Executing tasks”. [2]

Sources
[1] Gradle User Manual — Command-Line Interface: https://docs.gradle.org/current/userguide/command_line_interface.html
[2] Gradle User Manual — Command-Line Interface Basics: https://docs.gradle.org/current/userguide/command_line_interface_basics.html


🏁 Script executed:

# Gradle 공식 문서의 Task Selector 패턴 확인
# 실제 프로젝트에서 test로 시작하는 태스크들 확인
rg "test" -t kts build.gradle.kts | grep -E "(task|Test)" | head -20

Repository: Loopers-dev-lab/loop-pack-be-l2-vol3-java

Length of output: 112


Gradle 태스크 패턴 문법을 표준 형식으로 수정한다.

test:* 형식은 Gradle 공식 명령어가 아니다. Gradle은 태스크 경로에서 : 를 구분자로 사용하지만 * 와일드카드를 지원하지 않는다. 현재 패턴 ./gradlew test:*./gradlew :apps:commerce-api:test:* 는 표준 Gradle 문법이 아니므로 의도한 권한이 제대로 부여되지 않을 위험이 있다.

운영 관점에서 다음과 같이 수정한다:

  • ./gradlew test (모든 모듈의 테스트 태스크)
  • ./gradlew :apps:commerce-api:test (commerce-api 모듈만 테스트)

이렇게 수정하면 Claude가 정확한 Gradle 태스크를 실행할 수 있으며, 저장소 구조와의 명확한 대응이 보장된다. 추가로 권한 시스템이 실제로 이 패턴들을 인식하는지 테스트한다.

🤖 Prompt for AI Agents
In @.claude/settings.local.json around lines 3 - 6, Replace the non-standard
Gradle patterns "Bash(./gradlew test:*)" and "Bash(./gradlew
:apps:commerce-api:test:*)" in the "allow" array with the canonical task
invocations "Bash(./gradlew test)" and "Bash(./gradlew
:apps:commerce-api:test)"; update the entries in .claude/settings.local.json
where those strings appear (look for the allow array) and then verify the
authorization system recognizes and permits those exact commands by testing
execution.

}
}
45 changes: 0 additions & 45 deletions .codeguide/loopers-1-week.md

This file was deleted.

166 changes: 166 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Tech Stack & Versions

| Category | Technology | Version |
|----------|------------|---------|
| Language | Java | 21 |
| Framework | Spring Boot | 3.4.4 |
| Dependency Management | Spring Dependency Management | 1.1.7 |
| Cloud | Spring Cloud | 2024.0.1 |
| Build Tool | Gradle (Kotlin DSL) | 8.13+ |
| API Documentation | SpringDoc OpenAPI | 2.7.0 |
| ORM | Spring Data JPA + QueryDSL | (managed by Spring Boot) |
| Database | MySQL | 8.0 |
| Cache | Redis (Master-Replica) | - |
| Messaging | Kafka | 3.5.1 |
| Monitoring | Micrometer + Prometheus | (managed by Spring Boot) |
| Logging | Logback + Slack Appender | 1.6.1 |
| Testing | JUnit 5, Mockito 5.14.0, SpringMockk 4.0.2, Instancio 5.0.2 | - |
| Containers | TestContainers | (managed by Spring Boot) |

## Build & Run Commands

```bash
# Build all modules
./gradlew build

# Run tests (profile: test, timezone: Asia/Seoul)
./gradlew test

# Run specific app
./gradlew :apps:commerce-api:bootRun
./gradlew :apps:commerce-batch:bootRun --args='--job.name=jobName'
./gradlew :apps:commerce-streamer:bootRun

# Build specific module
./gradlew :apps:commerce-api:build

# Run single test class
./gradlew test --tests "com.loopers.ExampleServiceIntegrationTest"

# Run single test method
./gradlew test --tests "com.loopers.ExampleServiceIntegrationTest.testMethodName"

# Test with coverage report
./gradlew test jacocoTestReport
```

**Java version**: 21 (configured via Gradle toolchain)

## Local Infrastructure

```bash
# Start MySQL, Redis (master+replica), Kafka
docker-compose -f docker/infra-compose.yml up

# Start Prometheus + Grafana monitoring
docker-compose -f docker/monitoring-compose.yml up
```

- MySQL: localhost:3307 (root/root, application/application)
- Redis Master: localhost:6379, Replica: localhost:6380
- Kafka: localhost:19092, Kafka UI: localhost:9099
- Grafana: localhost:3000 (admin/admin)

## Architecture

### Multi-Module Structure

```
loopers-java-spring-template/
├── apps/ # Executable Spring Boot applications
│ ├── commerce-api # REST API (web, actuator, springdoc-openapi)
│ ├── commerce-batch # Batch jobs (spring-batch)
│ └── commerce-streamer # Event streaming (web, kafka)
├── modules/ # Reusable infrastructure configurations
│ ├── jpa # JPA, QueryDSL, MySQL connector
│ ├── redis # Spring Data Redis (master-replica)
│ └── kafka # Spring Kafka
└── supports/ # Cross-cutting add-on modules
├── jackson # Jackson serialization (Kotlin module, JSR310)
├── logging # Logback, Slack appender
└── monitoring # Micrometer, Prometheus registry
```

### Module Dependencies

| App | modules | supports |
|-----|---------|----------|
| commerce-api | jpa, redis | jackson, logging, monitoring |
| commerce-batch | jpa, redis | jackson, logging, monitoring |
| commerce-streamer | jpa, redis, kafka | jackson, logging, monitoring |

### Layer Architecture (commerce-api)
```
interfaces/api/ → Controllers, DTOs, OpenAPI specs
application/ → Facades (use case orchestration)
domain/ → Entities, Services, Repository interfaces
infrastructure/ → Repository implementations, adapters
```

### Key Patterns
- **Controllers**: Implement `*ApiSpec` interfaces for OpenAPI documentation
- **Facades**: Orchestrate domain services, convert domain models to DTOs
- **Services**: `@Component` with `@Transactional`, contain business logic
- **Repositories**: Interface in `domain/`, implementation in `infrastructure/`
- **Entities**: Extend `BaseEntity` (provides id, createdAt, updatedAt, deletedAt)
- **Response wrapper**: All APIs return `ApiResponse<T>`
- **Error handling**: `CoreException` with `ErrorType` enum, caught by `ApiControllerAdvice`

### Soft Delete
Entities use `deletedAt` field via `BaseEntity`:
```java
entity.delete(); // marks as deleted
entity.restore(); // restores
```

## Configuration

- Profile-based: local, test, dev, qa, prd
- Config imports in application.yml: jpa.yml, redis.yml, logging.yml, monitoring.yml
- Management endpoints on port 8081 (/health, /prometheus)

## Testing

- Framework: JUnit 5 + AssertJ + Mockito + SpringMockk + Instancio
- `DatabaseCleanUp` utility truncates tables between tests (from jpa test fixtures)
- `RedisCleanUp` available from redis test fixtures
- TestContainers support for MySQL, Redis, Kafka

## 개발 규칙

### 진행 Workflow - 증강 코딩
- **대원칙**: 방향성 및 주요 의사 결정은 개발자에게 제안만 할 수 있으며, 최종 승인된 사항을 기반으로 작업 수행
- **중간 결과 보고**: AI가 반복적인 동작을 하거나, 요청하지 않은 기능을 구현, 테스트 삭제를 임의로 진행할 경우 개발자가 개입
- **설계 주도권 유지**: AI가 임의판단을 하지 않고, 방향성에 대한 제안 등을 진행할 수 있으나 개발자의 승인을 받은 후 수행

### 개발 Workflow - TDD (Red → Green → Refactor)
- 모든 테스트는 3A 원칙으로 작성 (Arrange - Act - Assert)

| Phase | 설명 |
|-------|------|
| **Red** | 요구사항을 만족하는 실패하는 테스트 케이스 먼저 작성 |
| **Green** | Red Phase의 테스트가 모두 통과할 수 있는 최소한의 코드 작성 (오버엔지니어링 금지) |
| **Refactor** | 불필요한 private 함수 지양, 객체지향적 코드 작성, unused import 제거, 성능 최적화. 모든 테스트 통과 필수 |

### 주의사항

**Never Do:**
- 실제 동작하지 않는 코드, 불필요한 Mock 데이터를 이용한 구현 금지
- null-safety 하지 않은 코드 작성 금지 (Java의 경우 Optional 활용)
- println 코드 남기지 말 것

**Recommendation:**
- 실제 API를 호출해 확인하는 E2E 테스트 코드 작성
- 재사용 가능한 객체 설계
- 성능 최적화에 대한 대안 및 제안
- 개발 완료된 API는 `http/*.http` 파일에 분류해 작성

**Priority:**
1. 실제 동작하는 해결책만 고려
2. null-safety, thread-safety 고려
3. 테스트 가능한 구조로 설계
4. 기존 코드 패턴 분석 후 일관성 유지
167 changes: 167 additions & 0 deletions MERMAID.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Flow Diagrams

## 1. 회원가입 (POST /api/v1/members)

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service
participant DB

Client->>Controller: POST /api/v1/members (SignUpRequest)
Controller->>Facade: signupMember(request)
Facade->>Facade: Request to MemberModel 변환
Facade->>Service: saveMember(memberModel)
Service->>DB: findByLoginId (중복 체크)
DB-->>Service: Optional.empty()
Service->>Service: passwordEncoder.encode()
Service->>DB: save(memberModel)
DB-->>Service: savedMember
Service-->>Facade: MemberModel
Facade->>Facade: MemberModel to MemberInfo 변환
Facade-->>Controller: MemberInfo
Controller-->>Client: 201 Created (SignUpResponse)
```

### 예외 흐름

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service
participant DB

Client->>Controller: POST /api/v1/members (중복 ID)
Controller->>Facade: signupMember(request)
Facade->>Service: saveMember(memberModel)
Service->>DB: findByLoginId
DB-->>Service: Optional.of(existingMember)
Service-->>Controller: CoreException (CONFLICT)
Controller-->>Client: 409 Conflict
```

---

## 2. 내 정보 조회 (GET /api/v1/members/me)

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service
participant DB

Client->>Controller: GET /api/v1/members/me
Note over Client,Controller: Headers: X-Loopers-LoginId, X-Loopers-LoginPw
Controller->>Facade: getMyInfo(loginId, password)
Facade->>Service: authenticate(loginId, password)
Service->>DB: findByLoginId
DB-->>Service: MemberModel
Service->>Service: passwordEncoder.matches()
Service-->>Facade: MemberModel (인증 성공)
Facade->>Facade: MemberModel to MemberInfo 변환 (이름 마스킹)
Facade-->>Controller: MemberInfo
Controller-->>Client: 200 OK (MemberInfoResponse)
```

### 예외 흐름 - 인증 실패

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service
participant DB

Client->>Controller: GET /api/v1/members/me (틀린 비밀번호)
Controller->>Facade: getMyInfo(loginId, wrongPassword)
Facade->>Service: authenticate(loginId, wrongPassword)
Service->>DB: findByLoginId
DB-->>Service: MemberModel
Service->>Service: passwordEncoder.matches() = false
Service-->>Controller: CoreException (UNAUTHORIZED)
Controller-->>Client: 401 Unauthorized
```

---

## 3. 비밀번호 변경 (PATCH /api/v1/members/me/password)

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service
participant DB

Client->>Controller: PATCH /api/v1/members/me/password
Note over Client,Controller: Headers: X-Loopers-LoginId, X-Loopers-LoginPw
Note over Client,Controller: Body: oldPassword, newPassword
Controller->>Facade: changePassword(loginId, headerPw, oldPw, newPw)
Facade->>Service: authenticate(loginId, headerPw)
Service->>DB: findByLoginId
DB-->>Service: MemberModel
Service->>Service: passwordEncoder.matches(headerPw)
Service-->>Facade: 인증 성공
Facade->>Facade: new MemberModel(loginId, oldPw)
Facade->>Service: changePassword(memberModel, newPw)
Service->>Service: passwordEncoder.matches(oldPw) 검증
Service->>Service: newPw != oldPw 검증
Service->>Service: validatePassword(newPw) 규칙 검증
Service->>Service: passwordEncoder.encode(newPw)
Service->>DB: Dirty Checking (자동 저장)
Service-->>Facade: void
Facade-->>Controller: void
Controller-->>Client: 200 OK
```

### 예외 흐름 - Body의 기존 비밀번호 불일치

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service

Client->>Controller: PATCH (헤더 인증 OK, Body oldPw 틀림)
Controller->>Facade: changePassword(...)
Facade->>Service: authenticate() 성공
Facade->>Service: changePassword(wrongOldPw, newPw)
Service->>Service: passwordEncoder.matches(wrongOldPw) = false
Service-->>Controller: CoreException (UNAUTHORIZED)
Controller-->>Client: 401 Unauthorized
```

### 예외 흐름 - 새 비밀번호가 기존과 동일

```mermaid
sequenceDiagram
autonumber
participant Client
participant Controller
participant Facade
participant Service

Client->>Controller: PATCH (newPw == oldPw)
Controller->>Facade: changePassword(...)
Facade->>Service: authenticate() 성공
Facade->>Service: changePassword(oldPw, samePassword)
Service->>Service: oldPw 검증 성공
Service->>Service: newPw == oldPw 체크
Service-->>Controller: CoreException (BAD_REQUEST)
Controller-->>Client: 400 Bad Request
```
Loading