File size: 5,650 Bytes
1dbc34b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Folder & Naming Pattern Guide

This document defines the folder structure and naming conventions used in this codebase.

## File Naming Convention

**All files use kebab-case** (lowercase with hyphens):

```
βœ… add-feature-dialog.tsx
βœ… use-board-actions.ts
βœ… board-view.tsx

❌ AddFeatureDialog.tsx
❌ useBoardActions.ts
❌ BoardView.tsx
```

## Export Naming Convention

While files use kebab-case, **exports use PascalCase for components and camelCase for hooks/functions**:

```tsx
// File: add-feature-dialog.tsx
export function AddFeatureDialog() { ... }

// File: use-board-actions.ts
export function useBoardActions() { ... }
```

## View Folder Structure

Each complex view should have its own folder with the following structure:

```
components/views/
β”œβ”€β”€ [view-name].tsx              # Entry point (exports the main view)
└── [view-name]/                 # Subfolder for complex views
    β”œβ”€β”€ components/              # View-specific reusable components
    β”‚   β”œβ”€β”€ index.ts             # Barrel export
    β”‚   └── [component].tsx      # Individual components
    β”œβ”€β”€ dialogs/                 # View-specific dialogs and modals
    β”‚   β”œβ”€β”€ index.ts             # Barrel export
    β”‚   └── [dialog-name].tsx    # Individual dialogs/modals
    β”œβ”€β”€ hooks/                   # View-specific hooks
    β”‚   β”œβ”€β”€ index.ts             # Barrel export
    β”‚   └── use-[name].ts        # Individual hooks
    β”œβ”€β”€ shared/                  # Shared utilities between components
    β”‚   β”œβ”€β”€ index.ts             # Barrel export
    β”‚   └── [name].ts            # Shared code
    β”œβ”€β”€ constants.ts             # View constants
    β”œβ”€β”€ types.ts                 # View-specific types (optional)
    β”œβ”€β”€ utils.ts                 # View utilities (optional)
    └── [main-component].tsx     # Main view components (e.g., kanban-board.tsx)
```

## Example: board-view

```
components/views/
β”œβ”€β”€ board-view.tsx                           # Entry point
└── board-view/
    β”œβ”€β”€ components/
    β”‚   β”œβ”€β”€ index.ts
    β”‚   β”œβ”€β”€ kanban-card.tsx
    β”‚   └── kanban-column.tsx
    β”œβ”€β”€ dialogs/
    β”‚   β”œβ”€β”€ index.ts
    β”‚   β”œβ”€β”€ add-feature-dialog.tsx
    β”‚   β”œβ”€β”€ edit-feature-dialog.tsx
    β”‚   β”œβ”€β”€ follow-up-dialog.tsx
    β”‚   β”œβ”€β”€ delete-all-verified-dialog.tsx
    β”‚   β”œβ”€β”€ delete-completed-feature-dialog.tsx
    β”‚   β”œβ”€β”€ completed-features-modal.tsx
    β”‚   β”œβ”€β”€ agent-output-modal.tsx
    β”‚   └── feature-suggestions-dialog.tsx
    β”œβ”€β”€ hooks/
    β”‚   β”œβ”€β”€ index.ts
    β”‚   β”œβ”€β”€ use-board-actions.ts
    β”‚   β”œβ”€β”€ use-board-features.ts
    β”‚   └── use-board-drag-drop.ts
    β”œβ”€β”€ shared/
    β”‚   β”œβ”€β”€ index.ts
    β”‚   β”œβ”€β”€ model-constants.ts
    β”‚   └── model-selector.tsx
    β”œβ”€β”€ constants.ts
    └── kanban-board.tsx
```

## Global vs View-Specific Code

### Global (`src/hooks/`, `src/lib/`, etc.)

Code that is used across **multiple views**:

- `src/hooks/use-auto-mode.ts` - Used by board-view, agent-view, etc.
- `src/hooks/use-keyboard-shortcuts.ts` - Used across the app
- `src/lib/utils.ts` - Global utilities

### View-Specific (`[view-name]/hooks/`, `[view-name]/components/`)

Code that is **only used within a single view**:

- `board-view/hooks/use-board-actions.ts` - Only used by board-view
- `board-view/components/kanban-card.tsx` - Only used by board-view

## Barrel Exports

Use `index.ts` files to create clean import paths:

```tsx
// board-view/hooks/index.ts
export { useBoardActions } from './use-board-actions';
export { useBoardFeatures } from './use-board-features';

// Usage in board-view.tsx
import { useBoardActions, useBoardFeatures } from './board-view/hooks';
```

## When to Create a Subfolder

Create a subfolder for a view when:

1. The view file exceeds ~500 lines
2. The view has 3+ related components
3. The view has 2+ custom hooks
4. Multiple dialogs/modals are specific to the view

## Dialogs Folder

The `dialogs/` folder contains all dialog and modal components specific to a view:

### What goes in `dialogs/`:

- Confirmation dialogs (e.g., `delete-all-verified-dialog.tsx`)
- Form dialogs (e.g., `add-feature-dialog.tsx`, `edit-feature-dialog.tsx`)
- Modal overlays (e.g., `agent-output-modal.tsx`, `completed-features-modal.tsx`)
- Any component that renders as an overlay/popup

### Naming convention:

- Use `-dialog.tsx` suffix for confirmation/form dialogs
- Use `-modal.tsx` suffix for content-heavy modals

### Barrel export pattern:

```tsx
// dialogs/index.ts
export { AddFeatureDialog } from './add-feature-dialog';
export { EditFeatureDialog } from './edit-feature-dialog';
export { AgentOutputModal } from './agent-output-modal';
// ... etc

// Usage in view entry point
import { AddFeatureDialog, EditFeatureDialog, AgentOutputModal } from './board-view/dialogs';
```

## Quick Reference

| Location   | File Naming                     | Export Naming          |
| ---------- | ------------------------------- | ---------------------- |
| Components | `kebab-case.tsx`                | `PascalCase`           |
| Dialogs    | `*-dialog.tsx` or `*-modal.tsx` | `PascalCase`           |
| Hooks      | `use-kebab-case.ts`             | `camelCase`            |
| Utils/Lib  | `kebab-case.ts`                 | `camelCase`            |
| Types      | `kebab-case.ts`                 | `PascalCase`           |
| Constants  | `constants.ts`                  | `SCREAMING_SNAKE_CASE` |