Skip to content

Commit 66aa81f

Browse files
committed
update rules for apps
1 parent 2882724 commit 66aa81f

7 files changed

Lines changed: 107 additions & 0 deletions

File tree

.trae/rules/apps/context-documents.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,22 @@ export interface ContextDocument {
2121
directoryId?: string | null;
2222
}
2323
```
24+
25+
## Logic & Rules
26+
27+
The core business logic is implemented in [src/services/contextDocumentService.ts](file:///home/pouria/projects/pyramid-solver/src/services/contextDocumentService.ts).
28+
29+
### Core Functions
30+
- **Document Management**:
31+
- `createContextDocument`: Initializes a document with empty content and type 'text'.
32+
- `getUserContextDocuments`: Fetches documents filtered by `userId` and optionally `workspaceId`.
33+
- `updateContextDocument`: Supports partial updates (patch) for title, content, type, etc.
34+
- **Directory Management**: (Implemented in [src/services/directoryService.ts](file:///home/pouria/projects/pyramid-solver/src/services/directoryService.ts))
35+
- `createDirectory`: Creates a new folder to organize documents.
36+
- `deleteDirectory`: Deletes a directory and moves all contained documents to the root (sets `directoryId` to null).
37+
- `getDirectoryDocuments`: Fetches documents within a specific directory (or root if `directoryId` is null).
38+
39+
### Invariants
40+
- Documents must always be associated with a `userId`.
41+
- The `type` field defaults to "text" but can support other formats.
42+
- When a directory is deleted, its documents are preserved but moved to the root level.

.trae/rules/apps/diagrams.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ export interface Diagram {
2525
edges: any[];
2626
}
2727
```
28+
29+
## Logic & Rules
30+
31+
The core business logic is implemented in [src/services/diagramService.ts](file:///home/pouria/projects/pyramid-solver/src/services/diagramService.ts).
32+
33+
### Core Functions
34+
- **CRUD**: Standard `createDiagram`, `getDiagram`, `updateDiagram`, `deleteDiagram` operations.
35+
- **Initialization**: New diagrams start with empty `nodes` and `edges` arrays.
36+
- **Timestamps**: `updateDiagram` automatically updates the `lastModified` timestamp.
37+
38+
### Invariants
39+
- `nodes` and `edges` default to empty arrays if undefined in storage.

.trae/rules/apps/product-definition.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ export interface ProductDefinition {
3030
data: Record<string, ProductDefinitionNode>;
3131
}
3232
```
33+
34+
## Logic & Rules
35+
36+
The core business logic is implemented in [src/services/productDefinitionService.ts](file:///home/pouria/projects/pyramid-solver/src/services/productDefinitionService.ts).
37+
38+
### Core Functions
39+
- **Template Initialization**: `createProductDefinition` creates a new definition with a pre-defined tree structure:
40+
1. **Problem & Goals**: (Problem Statement, Investment Limits, Baseline Comparison)
41+
2. **Solution Concepts**: (Key Flows, Rough Sketches, Scope Boundaries)
42+
3. **Risks & Unknowns**: (Technical Risks, Design Challenges, Risk Mitigation)
43+
4. **Implementation Strategy**: (Components, Complexity Analysis, Milestones)
44+
- **Data Normalization**: `mapDefinitionFromStorage` ensures that database snake_case fields are correctly mapped to TypeScript camelCase properties.
45+
46+
### Invariants
47+
- New definitions always start with the standard 4-section template.
48+
- The `root` node always has ID "root".

.trae/rules/apps/pyramid-solver.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ export interface Pyramid {
2222
contextSources?: ContextSource[];
2323
}
2424
```
25+
26+
## Logic & Rules
27+
28+
The core business logic is implemented in [src/services/pyramidService.ts](file:///home/pouria/projects/pyramid-solver/src/services/pyramidService.ts).
29+
30+
### Core Functions
31+
- **Initialization**: `createPyramid` initializes a new pyramid with a standard 8x8 grid (64 blocks) of type 'question'.
32+
- **Duplication**: `duplicatePyramid` creates a deep copy of a pyramid, appending "(Copy)" to the title, but resetting the ID and timestamps.
33+
- **Sorting**: `getUserPyramids` returns pyramids sorted by `lastModified` descending (newest first).
34+
- **Real-time Sync**: `subscribeToPyramid` provides real-time updates via the storage adapter's subscription mechanism.
35+
36+
### Invariants
37+
- Every pyramid MUST have exactly 64 blocks initialized upon creation.
38+
- Deleting a pyramid (`deletePyramid`) permanently removes it from storage.

.trae/rules/apps/technical-architecture.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,20 @@ export interface TechnicalArchitecture {
113113
};
114114
}
115115
```
116+
117+
## Logic & Rules
118+
119+
The core business logic is implemented in [src/services/technicalArchitectureService.ts](file:///home/pouria/projects/pyramid-solver/src/services/technicalArchitectureService.ts).
120+
121+
### Core Functions
122+
- **Template Initialization**: `createTechnicalArchitecture` initializes a comprehensive schema with empty placeholders for all major architectural sections:
123+
- System Architecture
124+
- Technology Stack
125+
- Code Organization
126+
- Design Patterns
127+
- API Standards
128+
- Security Standards
129+
- **Data Mapping**: `mapArchitectureFromStorage` handles the conversion from storage format to the TypeScript interface.
130+
131+
### Invariants
132+
- New architectures are always initialized with the full, deep structure to ensure UI components don't crash on missing nested fields.

.trae/rules/apps/technical-tasks.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,18 @@ export interface TechnicalTaskData {
3333
preservation_rules: Section<PreservationRulesMain, PreservationRulesAdvanced>;
3434
}
3535
```
36+
37+
## Logic & Rules
38+
39+
The core business logic is implemented in [src/services/technicalTaskService.ts](file:///home/pouria/projects/pyramid-solver/src/services/technicalTaskService.ts).
40+
41+
### Core Functions
42+
- **Pipeline Management**: `getPipelines` fetches task pipelines and automatically deduplicates "Backlog" pipelines if multiple are found (merging tasks into one).
43+
- **Batch Updates**:
44+
- `batchUpdatePipelines`: Updates the order of pipelines.
45+
- `batchUpdateTasks`: Updates the order and pipeline assignment of tasks (drag-and-drop).
46+
- **Dual Write**: `batchUpdateTasks` updates both `technicalTasks` (local/app context) and `globalTasks` (global context) to ensure visibility.
47+
48+
### Invariants
49+
- A "Backlog" pipeline is automatically created if no pipelines exist.
50+
- Tasks must always belong to a `pipelineId`.

.trae/rules/apps/ui-ux-architecture.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ export interface UiUxArchitecture {
2222
ux_patterns: UxPatterns;
2323
}
2424
```
25+
26+
## Logic & Rules
27+
28+
The core business logic is implemented in [src/services/uiUxArchitectureService.ts](file:///home/pouria/projects/pyramid-solver/src/services/uiUxArchitectureService.ts).
29+
30+
### Core Functions
31+
- **Template Initialization**: `createUiUxArchitecture` initializes a structure with:
32+
- **Theme Specification**: Colors, typography, spacing, border radius.
33+
- **UX Patterns**: Loading states, error states, empty states.
34+
- Empty lists for `base_components` and `pages`.
35+
- **Data Mapping**: `mapArchitectureFromStorage` converts storage timestamps (Firestore `Timestamp` or string) to ISO strings.
36+
37+
### Invariants
38+
- Timestamps (`createdAt`, `updatedAt`) are always returned as ISO strings.

0 commit comments

Comments
 (0)