Skip to content

[Refactor/#190] WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합합니다.#191

Merged
wjdrjs00 merged 1 commit intodevelopfrom
refactor/#190-routine-integration
Mar 7, 2026
Merged

[Refactor/#190] WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합합니다.#191
wjdrjs00 merged 1 commit intodevelopfrom
refactor/#190-routine-integration

Conversation

@wjdrjs00
Copy link
Member

@wjdrjs00 wjdrjs00 commented Mar 5, 2026

[ PR Content ]

WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합했습니다.

Related issue

Screenshot 📸

  • N/A

Work Description

  • WriteRoutine 관련 DataSource, Service, Repository를 Routine 으로 통합 및 이전
  • RepeatDayDayOfWeek로 대체하고 관련 모델(RoutineRegisterInfo, RoutineEditInfo 등) 재정의

To Reviewers 📢

  • 궁금, 특이사항이 있다면 리뷰 남겨주십쇼!

Summary by CodeRabbit

릴리스 노트

  • Refactor
    • 루틴 작성 기능을 기존 루틴 모듈로 통합하여 코드 구조를 개선했습니다. 내부 아키텍처 개선으로 유지보수성을 강화했으며, 기존 기능에는 영향이 없습니다.

@wjdrjs00 wjdrjs00 requested a review from l5x5l March 5, 2026 09:36
@wjdrjs00 wjdrjs00 self-assigned this Mar 5, 2026
@wjdrjs00 wjdrjs00 added 🔨 Refactor 기존 기능 개선 🧤 대현 labels Mar 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Walkthrough

이 PR은 writeRoutine 패키지의 기능을 routine 패키지로 통합하는 대규모 리팩토링입니다. WriteRoutine 관련 클래스들을 제거하고, 해당 기능을 RoutineRepository와 RoutineService로 이동했으며, DI 바인딩을 정리하고 타입을 DayOfWeek으로 통합했습니다.

Changes

Cohort / File(s) Summary
DI 바인딩 제거
app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt, RepositoryModule.kt, ServiceModule.kt
WriteRoutineDataSource, WriteRoutineRepository, WriteRoutineService의 Dagger/Hilt 바인딩 제거로 DI 컨테이너에서 이들 의존성 등록 해제.
WriteRoutine 데이터 계층 제거
data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasource/*, datasourceImpl/*, service/WriteRoutineService.kt, repositoryImpl/WriteRoutineRepositoryImpl.kt
WriteRoutineDataSource, WriteRoutineDataSourceImpl, WriteRoutineService, WriteRoutineRepositoryImpl 클래스 및 해당 요청 모델(RegisterRoutineRequest, EditRoutineRequest) 완전 제거.
Routine 데이터 계층 확장
data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt, datasourceImpl/RoutineRemoteDataSourceImpl.kt, service/RoutineService.kt, repositoryImpl/RoutineRepositoryImpl.kt
registerRoutine, editRoutine 메서드 추가 및 새로운 요청 모델(RoutineRegisterRequest, RoutineEditRequest) 정의로 등록/수정 기능 통합.
새로운 요청 모델
data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineRegisterRequest.kt, RoutineEditRequest.kt
직렬화 가능한 새 DTO 정의 및 도메인 정보(RoutineRegisterInfo, RoutineEditInfo)를 요청 모델로 변환하는 확장 함수 추가.
도메인 계층 구조 조정
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineUpdateType.kt, WriteRoutineEvent.kt, RoutineRegisterInfo.kt, RoutineEditInfo.kt
RoutineUpdateType, WriteRoutineEvent를 writeroutine 패키지에서 routine 패키지로 이동 및 새로운 정보 모델(RoutineRegisterInfo, RoutineEditInfo) 추가.
도메인 계층 저장소 통합
domain/src/main/java/com/threegap/bitnagil/domain/routine/repository/RoutineRepository.kt
registerRoutine, editRoutine, getWriteRoutineEventFlow 메서드를 RoutineRepository에 추가하여 WriteRoutineRepository 기능 통합.
WriteRoutine 도메인 제거
domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/RepeatDay.kt, repository/WriteRoutineRepository.kt, usecase/EditRoutineUseCase.kt, GetWriteRoutineEventFlowUseCase.kt, RegisterRoutineUseCase.kt
WriteRoutineRepository, RepeatDay enum, 관련 use case 클래스들 완전 제거.
새로운 도메인 Use Case
domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/RegisterRoutineUseCase.kt, EditRoutineUseCase.kt, GetWriteRoutineEventFlowUseCase.kt
새로운 패키지 위치에서 routine 저장소에 위임하는 use case 추가로 기능 재구성.
프레젠테이션 계층 마이그레이션
presentation/src/main/java/com/threegap/bitnagil/presentation/screen/home/HomeViewModel.kt, routinelist/RoutineListViewModel.kt, routinewrite/RoutineWriteViewModel.kt, routinewrite/model/Day.kt
Import 경로 업데이트 (writeroutine → routine) 및 RepeatDay를 DayOfWeek으로 변경하여 타입 통합.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • l5x5l

Poem

🐰 양쪽 모듈이 하나로 뭉쳐,
WriteRoutine의 짐을 내려놓고,
Routine이 모든 걸 거머쥐네!
DayOfWeek로 요일도 통일하며,
더 깔끔한 코드의 정원이 피어났네! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 사항의 주요 내용을 명확하게 반영하고 있습니다. WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합한다는 핵심 변경사항을 간결하게 요약했습니다.
Description check ✅ Passed PR 설명이 관련 이슈, 작업 설명, 그리고 리뷰어 주의사항을 포함하여 템플릿 구조를 충분히 따르고 있습니다. 통합 작업의 주요 내용과 변경 범위가 명확하게 설명되어 있습니다.
Linked Issues check ✅ Passed PR의 모든 변경사항이 연결된 이슈 #190의 목표와 완벽하게 일치합니다. WriteRoutine을 Routine으로 통합하기 위해 필요한 모든 도메인, 데이터 레이어, 모델 변경이 포함되어 있습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 WriteRoutine을 Routine으로 통합하고 RepeatDay를 DayOfWeek로 대체하는 명시된 목표 범위 내에 있습니다. 범위를 벗어난 변경사항은 없습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#190-routine-integration

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt (1)

29-40: 등록/수정 매핑 로직 공통화를 권장합니다.

Line 29-40 매핑 패턴이 등록 요청 매퍼와 거의 동일해 추후 포맷/필드 변경 시 드리프트가 발생하기 쉽습니다. 공통 변환 유틸(특히 날짜/시간 포맷)을 분리해 두면 유지보수가 쉬워집니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt`
around lines 29 - 40, The RoutineEditInfo.toDto mapping duplicates the
registration mapper; extract shared mapping logic (especially date/time
formatting) into a common utility or mapper function and use it from
RoutineEditInfo.toDto and the registration mapper to avoid drift—e.g.,
centralize conversion of startDate/endDate/startTime to string and common field
mappings used to build RoutineEditRequest so both the RoutineEditInfo.toDto
function and the corresponding registration mapper call that shared
routine-to-request converter.
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt (1)

6-15: 등록 모델과 동일한 불변식 검증을 맞춰 주세요.

Line 6-15도 id/name 공백, 날짜 역전 상태를 허용합니다. RoutineRegisterInfo와 동일한 기준으로 init 검증을 두면 일관성이 좋아집니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt`
around lines 6 - 15, RoutineEditInfo currently allows blank id/name and inverted
dates; add the same invariant checks used in RoutineRegisterInfo by adding an
init block in RoutineEditInfo that validates non-blank id and name and enforces
startDate <= endDate (and any other checks present in RoutineRegisterInfo such
as non-empty repeatDay or valid startTime bounds if applicable). Implement the
checks using require(...) (or equivalent) with clear messages so the invariants
match RoutineRegisterInfo exactly and maintain consistency across the models.
presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt (1)

15-15: 메서드명과 반환 타입 의미를 맞춰 주세요.

Line 15의 toRepeatDay()는 이제 DayOfWeek를 반환하므로, toDayOfWeek()처럼 이름을 맞추면 호출부 혼동을 줄일 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt`
at line 15, The method toRepeatDay() in Day.kt returns a DayOfWeek but its name
is misleading; rename the function to toDayOfWeek() (signature returning
DayOfWeek) and update all callers to use the new name; if you need a
non-breaking change, add a deprecated wrapper fun toRepeatDay() = toDayOfWeek()
with `@Deprecated` annotation forwarding to the new toDayOfWeek() to give callers
time to migrate.
domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt (1)

7-15: 도메인 불변식 검증을 추가하는 것을 권장합니다.

Line 7-15는 외부 입력을 그대로 담아 name 공백, startDate > endDate 같은 비정상 상태를 허용합니다. init { require(...) }로 최소 검증을 두면 하위 레이어 오류를 줄일 수 있습니다.

예시 수정안
 data class RoutineRegisterInfo(
     val name: String,
     val repeatDay: List<DayOfWeek>,
     val startTime: LocalTime,
     val startDate: LocalDate,
     val endDate: LocalDate,
     val subRoutines: List<String>,
     val recommendedRoutineType: RecommendCategory?,
-)
+) {
+    init {
+        require(name.isNotBlank()) { "name must not be blank" }
+        require(!startDate.isAfter(endDate)) { "startDate must be on or before endDate" }
+    }
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt`
around lines 7 - 15, RoutineRegisterInfo currently accepts invalid input (blank
name, empty repeatDay, startDate after endDate, etc.); add an init {
require(...) } block inside the RoutineRegisterInfo data class to validate
fields: require(name.isNotBlank()), require(repeatDay.isNotEmpty()),
require(!startDate.isAfter(endDate)), and any other invariants you want (e.g.,
subRoutines non-null/unique) referencing the properties name, repeatDay,
startTime, startDate, endDate, and subRoutines so invalid instances are rejected
at construction time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineRegisterRequest.kt`:
- Line 33: The request uses LocalDate.toString() and LocalTime.toString() which
yield variable formats; fix the serialization in RoutineRegisterRequest.kt
(fields routineStartDate, routineEndDate, executionTime) and the toDto() in
RoutineEditRequest.kt by formatting dates/times with
DateTimeFormatter.ofPattern(...) (e.g., ISO_LOCAL_DATE and ISO_LOCAL_TIME or
your server-expected pattern) and pass the formatted strings instead of raw
toString() values; update the methods that set executionTime, routineStartDate,
and routineEndDate (and the toDto() implementation) to call format(formatter) so
the server receives a stable, explicit format.

In
`@data/src/main/java/com/threegap/bitnagil/data/routine/repositoryImpl/RoutineRepositoryImpl.kt`:
- Around line 55-56: The MutableSharedFlow _writeRoutineEventFlow currently uses
the default replay=0 which can drop events emitted before the ViewModel starts
collecting (registerRoutine()/editRoutine() emit synchronously while
observeRoutineChanges()/observeWriteRoutineEvent() start collection
asynchronously via viewModelScope.launch). Initialize _writeRoutineEventFlow
with a non-zero replay (e.g., MutableSharedFlow<WriteRoutineEvent>(replay = 1))
so the last emitted event is retained for late subscribers; update the
declaration of _writeRoutineEventFlow and keep getWriteRoutineEventFlow()
returning _writeRoutineEventFlow.asSharedFlow().

In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/repository/RoutineRepository.kt`:
- Line 19: The current WriteRoutine event flow can drop emits before subscribers
attach; update the implementation so late subscribers receive the last success
event by using a replaying SharedFlow instead of the default
MutableSharedFlow(). In RoutineRepositoryImpl, change the backing flow (the
MutableSharedFlow used for getWriteRoutineEventFlow) to include replay = 1
(e.g., MutableSharedFlow<WriteRoutineEvent>(replay = 1)) so the most recent
success event is retained for new subscribers; keep existing emit calls
(emit/tryEmit) as-is so producers still publish to the same flow.

---

Nitpick comments:
In
`@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt`:
- Around line 29-40: The RoutineEditInfo.toDto mapping duplicates the
registration mapper; extract shared mapping logic (especially date/time
formatting) into a common utility or mapper function and use it from
RoutineEditInfo.toDto and the registration mapper to avoid drift—e.g.,
centralize conversion of startDate/endDate/startTime to string and common field
mappings used to build RoutineEditRequest so both the RoutineEditInfo.toDto
function and the corresponding registration mapper call that shared
routine-to-request converter.

In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt`:
- Around line 6-15: RoutineEditInfo currently allows blank id/name and inverted
dates; add the same invariant checks used in RoutineRegisterInfo by adding an
init block in RoutineEditInfo that validates non-blank id and name and enforces
startDate <= endDate (and any other checks present in RoutineRegisterInfo such
as non-empty repeatDay or valid startTime bounds if applicable). Implement the
checks using require(...) (or equivalent) with clear messages so the invariants
match RoutineRegisterInfo exactly and maintain consistency across the models.

In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt`:
- Around line 7-15: RoutineRegisterInfo currently accepts invalid input (blank
name, empty repeatDay, startDate after endDate, etc.); add an init {
require(...) } block inside the RoutineRegisterInfo data class to validate
fields: require(name.isNotBlank()), require(repeatDay.isNotEmpty()),
require(!startDate.isAfter(endDate)), and any other invariants you want (e.g.,
subRoutines non-null/unique) referencing the properties name, repeatDay,
startTime, startDate, endDate, and subRoutines so invalid instances are rejected
at construction time.

In
`@presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt`:
- Line 15: The method toRepeatDay() in Day.kt returns a DayOfWeek but its name
is misleading; rename the function to toDayOfWeek() (signature returning
DayOfWeek) and update all callers to use the new name; if you need a
non-breaking change, add a deprecated wrapper fun toRepeatDay() = toDayOfWeek()
with `@Deprecated` annotation forwarding to the new toDayOfWeek() to give callers
time to migrate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a748ea8-8a92-4db8-abf0-5d4fb16fa5c4

📥 Commits

Reviewing files that changed from the base of the PR and between 77d64c0 and 4eaa9c0.

📒 Files selected for processing (34)
  • app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt
  • app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt
  • app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineRegisterRequest.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/repositoryImpl/RoutineRepositoryImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasource/WriteRoutineDataSource.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasourceImpl/WriteRoutineDataSourceImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/EditRoutineRequest.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/service/WriteRoutineService.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineUpdateType.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/SubRoutineDeletionInfo.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/WriteRoutineEvent.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/repository/RoutineRepository.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/EditRoutineUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/GetWriteRoutineEventFlowUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/RegisterRoutineUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/RepeatDay.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/EditRoutineUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt
  • presentation/src/main/java/com/threegap/bitnagil/presentation/screen/home/HomeViewModel.kt
  • presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinelist/RoutineListViewModel.kt
  • presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/RoutineWriteScreen.kt
  • presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/RoutineWriteViewModel.kt
  • presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt
💤 Files with no reviewable changes (15)
  • app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasourceImpl/WriteRoutineDataSourceImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt
  • app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt
  • app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/EditRoutineRequest.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasource/WriteRoutineDataSource.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/RepeatDay.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/service/WriteRoutineService.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/routine/model/SubRoutineDeletionInfo.kt
  • data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/EditRoutineUseCase.kt
  • domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt

Copy link
Contributor

@l5x5l l5x5l left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

@wjdrjs00 wjdrjs00 merged commit 55c8f13 into develop Mar 7, 2026
2 checks passed
@wjdrjs00 wjdrjs00 deleted the refactor/#190-routine-integration branch March 7, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 기존 기능 개선 🧤 대현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] routine, writeRoutine 통합 작업

2 participants