|
| 1 | +--- |
| 2 | +paths: |
| 3 | + - "apps/sim/**" |
| 4 | +--- |
| 5 | + |
| 6 | +# Sim App Architecture |
| 7 | + |
| 8 | +## Core Principles |
| 9 | +1. **Single Responsibility**: Each component, hook, store has one clear purpose |
| 10 | +2. **Composition Over Complexity**: Break down complex logic into smaller pieces |
| 11 | +3. **Type Safety First**: TypeScript interfaces for all props, state, return types |
| 12 | +4. **Predictable State**: Zustand for global state, useState for UI-only concerns |
| 13 | + |
| 14 | +## Root-Level Structure |
| 15 | + |
| 16 | +``` |
| 17 | +apps/sim/ |
| 18 | +├── app/ # Next.js app router (pages, API routes) |
| 19 | +├── blocks/ # Block definitions and registry |
| 20 | +├── components/ # Shared UI (emcn/, ui/) |
| 21 | +├── executor/ # Workflow execution engine |
| 22 | +├── hooks/ # Shared hooks (queries/, selectors/) |
| 23 | +├── lib/ # App-wide utilities |
| 24 | +├── providers/ # LLM provider integrations |
| 25 | +├── stores/ # Zustand stores |
| 26 | +├── tools/ # Tool definitions |
| 27 | +└── triggers/ # Trigger definitions |
| 28 | +``` |
| 29 | + |
| 30 | +## Feature Organization |
| 31 | + |
| 32 | +Features live under `app/workspace/[workspaceId]/`: |
| 33 | + |
| 34 | +``` |
| 35 | +feature/ |
| 36 | +├── components/ # Feature components |
| 37 | +├── hooks/ # Feature-scoped hooks |
| 38 | +├── utils/ # Feature-scoped utilities (2+ consumers) |
| 39 | +├── feature.tsx # Main component |
| 40 | +└── page.tsx # Next.js page entry |
| 41 | +``` |
| 42 | + |
| 43 | +## Naming Conventions |
| 44 | +- **Components**: PascalCase (`WorkflowList`) |
| 45 | +- **Hooks**: `use` prefix (`useWorkflowOperations`) |
| 46 | +- **Files**: kebab-case (`workflow-list.tsx`) |
| 47 | +- **Stores**: `stores/feature/store.ts` |
| 48 | +- **Constants**: SCREAMING_SNAKE_CASE |
| 49 | +- **Interfaces**: PascalCase with suffix (`WorkflowListProps`) |
| 50 | + |
| 51 | +## Utils Rules |
| 52 | + |
| 53 | +- **Never create `utils.ts` for single consumer** - inline it |
| 54 | +- **Create `utils.ts` when** 2+ files need the same helper |
| 55 | +- **Check existing sources** before duplicating (`lib/` has many utilities) |
| 56 | +- **Location**: `lib/` (app-wide) → `feature/utils/` (feature-scoped) → inline (single-use) |
0 commit comments