Skip to content

Setting(project): router 초기 설정#46

Merged
constantly-dev merged 5 commits intodevelopfrom
setting/#44/router
Aug 27, 2025
Merged

Setting(project): router 초기 설정#46
constantly-dev merged 5 commits intodevelopfrom
setting/#44/router

Conversation

@constantly-dev
Copy link
Member

@constantly-dev constantly-dev commented Aug 27, 2025

📌 Related Issues

관련된 Issue를 태그해주세요. (e.g. - close #25)

📄 Tasks

  • react-router-dom 의존성 추가
  • Route config 상수 추가
  • Outlet 사용 Layout 컴포넌트 구현
  • routes 폴더 절대 경로 설정
  • 대시보드 기본 페이지 컴포넌트 추가

⭐ PR Point (To Reviewer)

라우터 기본 설정했습니다. path관련 config를 상수화해서 유지 보수가 편하게 설정했어요. 혹시나 추가로 건의해주시거나 의견이 있으시다면 편하게 코멘트 달아주세요 👍

Summary by CodeRabbit

  • New Features
    • 클라이언트 라우팅 도입으로 화면 간 이동 지원
    • 신규 페이지 추가: 리마인드, 나의 북마크, 카테고리(동적 ID), 레벨
    • 기본 레이아웃 추가 및 하위 라우트 구조화로 탐색 경험 개선
  • Refactor
    • 초기 화면 구성을 라우팅 기반 렌더링으로 전환하여 유지보수성 향상
  • Chores
    • 라우팅 지원을 위한 의존성 및 경로 별칭 구성 업데이트

@coderabbitai
Copy link

coderabbitai bot commented Aug 27, 2025

Walkthrough

라우팅 초기 설정을 추가했습니다. react-router-dom을 의존성에 등록하고, createBrowserRouter 기반의 router, routesConfig, Layout 및 기본 페이지 컴포넌트들을 생성했습니다. App은 RouterProvider를 렌더링하도록 변경되었고, tsconfig에 @routes 경로 별칭이 추가되었습니다.

Changes

Cohort / File(s) Summary
Dependency & Config
apps/client/package.json, apps/client/tsconfig.json
react-router-dom ^7.8.2 추가; TypeScript paths에 "@routes/*" 추가.
Routing Core
apps/client/src/routes/router.tsx, apps/client/src/routes/routesConfig.ts
createBrowserRouter 기반 라우터 및 ROUTES_CONFIG 추가; 루트에 Layout, 자식 경로(Remind, MyBookmark, Category(:id), Level) 정의.
App Bootstrap
apps/client/src/App.tsx
기존 상태 기반 UI 제거, RouterProvider로 교체.
Layout
apps/client/src/layout/Layout.tsx
Outlet을 포함한 기본 레이아웃 컴포넌트 추가.
Pages
apps/client/src/pages/.../Category.tsx, .../Level.tsx, .../MyBookmark.tsx, .../Remind.tsx
각 경로에 대응하는 단순 페이지 컴포넌트 추가.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Browser
    participant App
    participant RouterProvider as RouterProvider/router
    participant Layout
    participant Outlet
    participant Page as Page Component

    User->>Browser: URL 입력/네비게이션
    Browser->>App: 초기 렌더
    App->>RouterProvider: RouterProvider 마운트
    RouterProvider->>Layout: "/" 매칭 시 Layout 렌더
    Layout->>Outlet: Outlet 렌더
    RouterProvider-->>Outlet: 경로 매칭 (ROUTES_CONFIG)
    Outlet->>Page: Remind | MyBookmark | Category(:id) | Level 렌더
    note right of RouterProvider: 경로 정의는 ROUTES_CONFIG에서 로드
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
[#44] router 초기 설정
[#25] design-system: Progress Bar 구현 디자인 시스템/Progress 관련 파일, 컴포넌트, 스토리 추가 없음.

Assessment against linked issues: Out-of-scope changes

(없음)

Possibly related PRs

Suggested labels

⚙️ Setting

Suggested reviewers

  • jllee000
  • karnelll

Poem

깡충, 라우터 길을 폈다네 — /
홈에서 레벨, 북마크, 분류까지 고고! 🗺️
Outlet 문 너머 페이지들이 고개 들어,
경로 표지판 ROUTES_CONFIG가 반짝!
오늘도 토끼는 링크를 건너 뛰며,
싱그런 SPA 들판을 달린다. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch setting/#44/router

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the setting 세팅하라 세팅 label Aug 27, 2025
@github-actions
Copy link

✅ Storybook chromatic 배포 확인:
🐿️ storybook

Copy link
Collaborator

@jjangminii jjangminii left a comment

Choose a reason for hiding this comment

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

고생하셨습니다-!! 빠른 라우터 설정 좋네요 ㅎㅎ

Comment on lines +2 to +17
remind: {
title: '리마인드',
path: '/',
},
myBookmarks: {
title: '나의 북마크',
path: '/my-bookmarks',
},
category: {
title: '카테고리',
path: (id: string) => `/category/${id}`,
},
level: {
title: '레벨',
path: '/level',
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

path를 문자열로 그대로 쓰는 게 아니라 상수화 한 점 좋네요-!
이렇게 사용하면 사용하는 여러 곳에서 따로 수정할 필요 없이 config 하나만 수정해도 반영이 되니 좋은 반영 같습니다ㅏ

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: 1

🧹 Nitpick comments (9)
apps/client/src/pages/category/Category.tsx (1)

1-5: 동적 경로(':id')에 맞춰 useParams 사용 고려

라우트가 /category/:id라면 파라미터 사용까지 스텁으로 잡아두면 추후 누락을 방지할 수 있습니다.

다음과 같이 최소 추가를 제안합니다.

+import { useParams } from 'react-router-dom';

-const Category = () => {
-  return <div>Category</div>;
-};
+const Category = () => {
+  const { id } = useParams<{ id: string }>();
+  return <div>Category {id}</div>;
+};
apps/client/src/layout/Layout.tsx (2)

3-10: 레이아웃에 Suspense/ScrollRestoration 추가로 라우팅 UX 보완

지금 상태도 OK지만, 페이지를 lazy 로드할 때 대기 UI와 스크롤 복원을 바로 지원하면 기본 UX가 좋아집니다.

-import { Outlet } from 'react-router-dom';
+import { Outlet, ScrollRestoration } from 'react-router-dom';
+import { Suspense } from 'react';

 const Layout = () => {
   return (
     <>
       {/* TODO: 필요시 레이아웃 추가 */}
       {/* TODO: 사이드바 추가 */}
-      <Outlet />
+      <Suspense fallback={<div role="status" aria-busy="true">Loading...</div>}>
+        <Outlet />
+      </Suspense>
+      <ScrollRestoration />
     </>
   );
 };

3-3: 에러 핸들링 경로(404) 추가 검토 요청

현재 apps/client/src/routes/router.tsx를 확인한 결과, createBrowserRouter 배열 내부에 errorElement 속성이나 와일드카드(*) 404 경로 설정이 누락되어 있습니다. 초기에 에러 페이지를 잡아두면 디버깅이 훨씬 수월해집니다.

– 파일: apps/client/src/routes/router.tsx
– 확인 스크립트 결과: errorElementNotFound 미발견

추천 조치 사항:

  • 각 라우트 객체에 errorElement: <ErrorPage/>를 추가하거나
  • 배열 마지막에 { path: '*', element: <NotFoundPage/> } 형태의 404 라우트를 정의

추가로, 과거에 언급하신 대로 docs 디렉터리에 라우팅/경로 네이밍 규칙 초안을 간단히 정리해 두시면 팀 내 컨벤션 공유에 도움이 될 것입니다.

apps/client/src/routes/routesConfig.ts (2)

10-13: 동적 라우트용 매치 패턴을 명시적으로 추가해주세요

현재 category.path는 URL 빌더 함수로 쓰이고, 라우터에선 ':id'를 인자로 전달하고 있어 사용처가 혼동될 수 있습니다. 매칭용 패턴을 별도 필드로 분리하면 명확합니다.

다음 변경을 제안합니다:

   category: {
     title: '카테고리',
-    path: (id: string) => `/category/${id}`,
+    pattern: '/category/:id',
+    path: (id: string) => `/category/${id}`,
   },

18-18: 상수 단언으로 타입 안전성 향상

as const를 적용해 라우트 키와 값의 리터럴 타입을 고정하면 이후 사용 시 오타/변경으로 인한 리스크를 줄일 수 있습니다.

-};
+} as const;
apps/client/src/App.tsx (1)

5-8: 불필요한 Fragment 제거 (미세 최적화)

루트가 단일 노드이므로 Fragment 없이 바로 반환해도 됩니다.

-  return (
-    <>
-      <RouterProvider router={router} />
-    </>
-  );
+  return <RouterProvider router={router} />;
apps/client/src/routes/router.tsx (3)

15-17: 루트 기본 경로는 index 라우트로 선언하는 것이 명확합니다

'/' 자식 라우트를 명시하기보다 index: true를 사용하면 의도가 분명하고 중복 매칭을 피할 수 있습니다.

-      {
-        path: ROUTES_CONFIG.remind.path,
-        element: <Remind />,
-      },
+      {
+        index: true,
+        element: <Remind />,
+      },

23-24: 동적 라우트는 패턴 필드를 사용해 매칭하세요

앞선 제안대로 pattern을 추가했다면 라우터에서는 패턴을 직접 참조하는 편이 안전합니다.

-      {
-        path: ROUTES_CONFIG.category.path(':id'),
-        element: <Category />,
-      },
+      {
+        path: ROUTES_CONFIG.category.pattern,
+        element: <Category />,
+      },

26-30: 404 대응 라우트 추가 권장

정적/동적 경로 외 요청에 대한 폴백이 없습니다. 간단한 NotFound 라우트를 추가하세요.

       {
         path: ROUTES_CONFIG.level.path,
         element: <Level />,
       },
+      {
+        path: '*',
+        element: <div>Not Found</div>, // TODO: 별도 NotFound 컴포넌트로 교체
+      },
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9f36f04 and 45524d0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • apps/client/package.json (1 hunks)
  • apps/client/src/App.tsx (1 hunks)
  • apps/client/src/layout/Layout.tsx (1 hunks)
  • apps/client/src/pages/category/Category.tsx (1 hunks)
  • apps/client/src/pages/level/Level.tsx (1 hunks)
  • apps/client/src/pages/myBookmark/MyBookmark.tsx (1 hunks)
  • apps/client/src/pages/remind/Remind.tsx (1 hunks)
  • apps/client/src/routes/router.tsx (1 hunks)
  • apps/client/src/routes/routesConfig.ts (1 hunks)
  • apps/client/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: constantly-dev
PR: Pinback-Team/pinback-client#2
File: pnpm-workspace.yaml:3-3
Timestamp: 2025-08-18T13:48:59.065Z
Learning: constantly-dev는 docs 디렉터리를 컨벤션 문서 추가용으로 사용할 예정이라고 명시했습니다.
🧬 Code graph analysis (3)
apps/client/src/App.tsx (1)
apps/client/src/routes/router.tsx (1)
  • router (9-32)
apps/client/src/pages/remind/Remind.tsx (1)
packages/design-system/src/components/card/Card.stories.tsx (1)
  • Remind (42-53)
apps/client/src/routes/router.tsx (1)
apps/client/src/routes/routesConfig.ts (1)
  • ROUTES_CONFIG (1-18)
🔇 Additional comments (6)
apps/client/tsconfig.json (1)

8-9: Vite 플러그인 연결 확인 완료

apps/client 프로젝트의 vite.config.ts 파일에서 tsconfigPaths() 플러그인이 정상적으로 등록되어 있어, tsconfig.json에 추가된 경로 별칭이 올바르게 해석됩니다. 추가 확인은 필요 없으며, 해당 변경사항 승인합니다.

• apps/client/vite.config.ts
– 12행: tsconfigPaths(), 확인 완료

apps/client/package.json (1)

14-16: peerDependencies 호환성 검증 완료

react-router-dom@7.8.2의 peerDependencies(react >=18, react-dom >=18)를 확인한 결과, apps/client/package.json의 react·react-dom 버전(^19.1.1)이 모두 요구사항을 충족합니다. 추가 조치 불필요합니다.

apps/client/src/pages/myBookmark/MyBookmark.tsx (1)

1-5: LGTM

초기 페이지 스텁으로 충분합니다. 라우팅 연결만 확인되면 추후 내용 채워가면 되겠습니다.

apps/client/src/pages/remind/Remind.tsx (1)

1-5: 간단 페이지 컴포넌트 구현 적절합니다

불필요한 의존성/사이드이펙트 없고 기본 라우트에 연결하기에 충분합니다.

apps/client/src/pages/level/Level.tsx (1)

1-5: 구현 적절합니다

라우팅 연결을 위한 기본 스텁으로 충분합니다.

apps/client/src/routes/router.tsx (1)

1-6: tsconfig.json 경로 별칭(@routes, @pages) 정상 설정됨

apps/client/tsconfig.json의 compilerOptions.paths에 아래와 같이 필요한 별칭이 모두 매핑되어 있습니다.

  • @routes/*src/routes/*
  • @pages/*src/pages/*

@layout 별칭은 현재 코드에서 사용되지 않으므로 추가 설정이 불필요해 보입니다. 이로 인해 컴파일 에러가 발생할 우려는 없습니다.

import Remind from '@pages/remind/Remind';
import { ROUTES_CONFIG } from '@routes/routesConfig';
import { createBrowserRouter } from 'react-router-dom';
import Layout from 'src/layout/Layout';
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

레이아웃 import 경로가 빌드 실패를 유발할 가능성

'src/layout/Layout' 경로는 현재 워크스페이스 구조상 상대경로 또는 별칭 설정 없이는 해석되지 않을 확률이 높습니다. 상대경로로 변경하거나 TS paths 별칭을 추가해 주세요.

상대경로로 즉시 수정하려면:

-import Layout from 'src/layout/Layout';
+import Layout from '../layout/Layout';

별칭을 선호하시면 apps/client/tsconfig.json에 다음을 추가하고 기존 import를 @layout/Layout으로 사용하세요:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@routes/*": ["routes/*"],
      "@pages/*": ["pages/*"],
      "@layout/*": ["layout/*"]
    }
  }
}
🤖 Prompt for AI Agents
In apps/client/src/routes/router.tsx around line 7 the import
"src/layout/Layout" may not resolve in the workspace and will cause build
failures; either change the import to the correct relative path from this file
to the Layout component (e.g., adjust to the proper ../ or ../../ path that
points to layout/Layout), or add a TS path alias in apps/client/tsconfig.json
(set baseUrl to "src" and add a "@layout/*" mapping to "layout/*") and then
update the import to use that alias (e.g., "@layout/Layout"); after making the
change, reload/restart the TypeScript server and run a build to verify
resolution.

Copy link
Collaborator

@jllee000 jllee000 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 이제 client내에서도 단일 대시보드페이지가 아니라 여러 pages를 가지는 구조가 되었네용! 귯

Comment on lines +4 to +10
return (
<>
{/* TODO: 필요시 레이아웃 추가 */}
{/* TODO: 사이드바 추가 */}
<Outlet />
</>
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 레이아웃 파일은 사이드바 + page삽입] 구조 쓰는 곳으로 이해하는게 맞나요?

++ Outlet은 혹시 어떤 기능인건지?

Copy link
Member Author

Choose a reason for hiding this comment

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

페이지는 Outlet을 통해 router에 정의한 페이지가 들어가게 돼요! 사이드바/헤더와 같이 공통으로 적용되어야 하는 부분을 밖에 정의하고 Outlet을 통해 child요소 -> page 정의한 route들이 적용되게 됩니다~

@constantly-dev constantly-dev merged commit bb59c9d into develop Aug 27, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

setting 세팅하라 세팅

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Setting] router 초기 설정

3 participants