폴더 구조

<aside> 💡

아래 예시는 간단한 블로그를 생각하면서 만들었습니다.

폴더 및 파일이 도메인 별로 나뉘어 집니다.

블로그에는 간단하게 auth로 사용자의 권한을 관리하는 도메인과, post로 게시글을 관리하는 도메인으로 나누어집니다.

📦 project
├─ public
└─ src
   ├─ app
   │  ├─ auth
   │  │  ├─ sign-in/ page.tsx     # 로그인 페이지
   │  │  └─ sign-up/ page.tsx     # 회원가입 페이지
   │  │
   │  ├─ post
   │  │  ├─ read/ page.tsx      # 게시글 상세 페이지
   │  │  ├─ write/ page.tsx     # 게시글 작성 페이지
   │  │  └─ page.tsx            # 게시글 목록 페이지
   │  │ 
   │  ├─ global-style.css
   │  ├─ not-found.tsx
   │  ├─ error.tsx
   │  ├─ layout.tsx
   │  └─ page.tsx
   │ 
   ├─ components
   │  ├─ **_**post
   │  │   ├─ post-card.tsx
   │  │   ├─ post-like-button.tsx
   │  │   └─ post-markdown-editor.tsx
   │  ├─ **_**auth
   │  │   ├─ auth-sign-in-form.tsx
   │  │   ├─ auth-sign-up-form.tsx
   │  │   └─ auth-tabs.tsx
   │  ├─ ui
   │  │  ├─ button.tsx
   │  │  ├─ input.tsx
   │  │  ├─ modal.tsx
   │  │  └─ combobox.tsx
   │  ├─ commons  # shadcn 컴포넌트를 이용한 공통 컴포넌트 포함
   │  └─ layouts
   │     ├─ header.tsx
   │     └─ footer.tsx
   │ 
   ├─ lib
   │  ├─ queries
   │  │  ├─ use-get-all-post-query.ts
   │  │  └─ use-get-post-by-id-suspense-query.ts
   │  ├─ mutations
   │  │  ├─ use-create-post-mutation.ts
   │  │  ├─ use-delete-post-mutation.ts
   │  │  └─ use-update-post-mutation.ts
   │  ├─ api
   │  │  ├─ post.api.ts  # supabse를 호출하는 api 함수
   │  │  └─ auth.api.ts  # supabse를 호출하는 api 함수
   │  ├─ hooks
   │  │  ├─ use-media-query.ts  # 현재 screen width이 sm, md, lg 인지 반환하는 훅
   │  │  └─ use-debounce.ts     # debounce를 적용시킨 값을 반환하는 훅
   │  ├─ utils
   │  │  ├─ auth.util.ts   
   │  │  └─ post.util.ts   
   │  └─ utils.ts    # shadcn에서 자동으로 만든 것임...! 
   │                 # 해당 경로를 수정하면 앞으로 import 할 모든 shadcn 컴포넌트들에 대해 
   │                 # `import { cn } from "@/lib/utils"` 수정해줘야 함...
   │                 # 단, `utils/index.ts` 로 수정하면 import 구문 수정 안해도 됨.
   ├─ config
   ├─ constants
   └─ types
      │  ├─ post.dto.ts   
      │  └─ auth.dto.ts  
      └─ post-category.type.ts 

폴더 & 파일 네이밍

<aside> 💡

표기법의 종류

폴더파일 둘 다 케밥 케이스

특정 도메인에서 사용되는 폴더는 components 폴더 아래에 _(언더바) 접두사와 함께

컴포넌트 파일명 규칙

유틸 함수, api, 타입, 상수, store, dto 파일명 규칙