mcpField
P
project-structure

project-structure

github.com/elie222開発12.9k37 回インストール今日更新
リポジトリ

project-structure について

Turborepo と pnpm workspaces を使う Next.js アプリの開発者向け構成ガイドです。ディレクトリ配置、命名規則、ページやコンポーネント、ユーティリティの整理方法を説明します。

主な機能

  1. 01アプリとパッケージの構成案内
  2. 02ページとコンポーネントの配置説明
  3. 03ファイル命名規則の提示
  4. 04ユーティリティの整理とインポート方法

活用シーン

  1. 01メインアプリや共有パッケージのコード検索
  2. 02規約に沿ったページの新規作成
  3. 03再利用可能なユーティリティの整理

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/elie222/inbox-zero --skill project-structure

インストール後、Claude Code で/project-structureを入力して読み込まれたか確認します。

詳細

プロジェクト構成

主な構成

  • Turborepo と pnpm ワークスペースを使用しています
  • メインアプリは apps/web にあります
  • パッケージは packages フォルダーにあります
  • サーバーアクションは apps/web/utils/actions フォルダーにあります
.
├── apps
│   ├── web/             # Main Next.js application
│   │   ├── app/         # Next.js App Router
│   │   │   ├── (app)/   # Main application pages
│   │   │   │   ├── assistant/     # AI assistant feature
│   │   │   │   ├── reply-zero/     # Reply Zero feature
│   │   │   │   ├── settings/       # User settings
│   │   │   │   ├── setup/          # Main onboarding
│   │   │   │   ├── clean/          # Bulk email cleanup
│   │   │   │   ├── smart-categories/ # Smart sender categorization
│   │   │   │   ├── bulk-unsubscribe/ # Bulk unsubscribe
│   │   │   │   ├── stats/          # Email analytics
│   │   │   │   ├── mail/           # Email client (in beta)
│   │   │   │   └── ... (other app routes)
│   │   │   ├── api/    # API Routes
│   │   │   │   ├── knowledge/      # Knowledge base API
│   │   │   │   ├── reply-tracker/  # Reply tracking
│   │   │   │   ├── clean/          # Cleanup API
│   │   │   │   ├── ai/            # AI features API
│   │   │   │   ├── user/          # User management
│   │   │   │   ├── google/        # Google integration
│   │   │   │   ├── auth/          # Authentication
│   │   │   │   └── ... (other APIs)
│   │   │   ├── (landing)/  # Marketing/landing pages
│   │   │   ├── blog/       # Blog pages
│   │   │   ├── layout.tsx  # Root layout
│   │   │   └── ... (other app files)
│   │   ├── utils/       # Utility functions and helpers
│   │   │   ├── actions/    # Server actions
│   │   │   ├── ai/         # AI-related utilities
│   │   │   ├── llms/       # Language model utilities
│   │   │   ├── gmail/      # Gmail integration utilities
│   │   │   ├── redis/      # Redis utilities
│   │   │   ├── user/       # User-related utilities
│   │   │   ├── parse/      # Parsing utilities
│   │   │   ├── queue/      # Queue management
│   │   │   ├── error-messages/  # Error handling
│   │   │   └── *.ts        # Other utility files (auth, email, etc.)
│   │   ├── public/      # Static assets (images, fonts)
│   │   ├── prisma/      # Prisma schema and client
│   │   ├── styles/      # Global CSS styles
│   │   ├── providers/   # React Context providers
│   │   ├── hooks/       # Custom React hooks
│   │   ├── sanity/      # Sanity CMS integration
│   │   ├── __tests__/   # AI test files (Vitest)
│   │   ├── scripts/     # Utility scripts
│   │   ├── store/       # State management
│   │   ├── types/       # TypeScript type definitions
│   │   ├── next.config.mjs
│   │   ├── package.json
│   │   └── ... (config files)
├── packages
    ├── tinybird/
    ├── loops/
    ├── resend/
    ├── tinybird-ai-analytics/
    └── tsconfig/

ファイルの命名と整理

  • ルートディレクトリにはケバブケースを使用します(例:api/hello-world/route)
  • コンポーネントにはパスカルケースを使用します(例:components/Button.tsx)
  • Shadcn コンポーネントは components/ui にあります
  • その他すべてのコンポーネントは components/ にあります
  • アプリ全体で使用できる場合を除き、ファイルは使用するフォルダー内にまとめます
  • コンポーネントを多くの場所で使用できる場合は、components フォルダーに配置します

新しいページ

  • 新しいページは apps/web/app/(app)/PAGE_NAME/page.tsx に作成します
  • ページ用のコンポーネントは、page.tsx または apps/web/app/(app)/PAGE_NAME フォルダーに配置します
  • ページは、データを直接読み込むためのサーバーコンポーネントです
  • 深くネストされたコンポーネントでのデータ取得には swr を使用します
  • onClick を持つコンポーネントは、use client ディレクティブを指定したクライアントコンポーネントにする必要があります
  • サーバーアクションのファイルは use server で始める必要があります

ユーティリティ関数

  • 再利用可能なロジック用のユーティリティ関数は utils/ フォルダーに作成します
  • 一般的な操作(配列、オブジェクト、文字列)には lodash のユーティリティを使用します
  • バンドルサイズを最小限に抑えるため、lodash の関数を個別にインポートします:
    import groupBy from "lodash/groupBy";
    

コメント