|
| 1 | +--- |
| 2 | +description: "Defines and enforces standardized directory structure and documentation requirements for Temporal-based workflows and workers" |
| 3 | +globs: ["workers/**/*", "docs/user-guide/temporal/**/*"] |
| 4 | +alwaysApply: false |
| 5 | +--- |
| 6 | +# Temporal Project Structure Rule |
| 7 | + |
| 8 | +## Purpose |
| 9 | +Defines the required directory and documentation structure for Temporal-based workflows and workers in this repository. |
| 10 | + |
| 11 | +## Project Structure |
| 12 | + |
| 13 | +The project follows a modular structure with workers as independent packages: |
| 14 | + |
| 15 | +``` |
| 16 | +. |
| 17 | +├── workers/ # Root directory for all Temporal workers |
| 18 | +│ ├── main/ # Main worker package |
| 19 | +│ │ ├── src/ # Source code |
| 20 | +│ │ │ ├── activities/ # Activity implementations |
| 21 | +│ │ │ ├── workflows/ # Workflow definitions |
| 22 | +│ │ │ ├── index.ts # Worker entry point |
| 23 | +│ │ │ └── types.ts # Worker-specific types |
| 24 | +│ │ ├── package.json # Worker dependencies |
| 25 | +│ │ ├── tsconfig.json # TypeScript configuration |
| 26 | +│ │ └── README.md # Worker documentation |
| 27 | +│ └── [other-workers]/ # Additional worker packages |
| 28 | +├── common/ # Shared utilities, types, and configuration for all workers |
| 29 | +├── docs/ # Project documentation |
| 30 | +│ └── user-guide/ # User guides and documentation |
| 31 | +├── docker-compose.yml # Docker compose configuration |
| 32 | +└── Dockerfile.temporal # Base Temporal worker Dockerfile |
| 33 | +``` |
| 34 | + |
| 35 | +All Temporal workers must be placed under `workers/<worker-name>/` and include: |
| 36 | + |
| 37 | +- `workflows/` — workflow definitions for this worker |
| 38 | +- `activities/` — activity implementations for this worker |
| 39 | +- `index.ts` — worker entry point (registers workflows/activities, sets task queue) |
| 40 | +- `types.ts` — (optional) worker-specific types |
| 41 | +- `README.md` — brief usage and development instructions |
| 42 | + |
| 43 | +### Shared Utilities |
| 44 | + |
| 45 | +Shared utilities, types, and configuration that are used by multiple workers should be placed in the `workers-shared/` directory at the project root. This directory is intended for code that is not specific to a single worker but is reused across multiple workers to avoid duplication and promote consistency. |
| 46 | + |
| 47 | +- `workers-shared/` — shared modules, types, and configuration for all workers |
| 48 | + - Utilities and helpers |
| 49 | + - Common type definitions |
| 50 | + - Shared configuration files |
| 51 | + |
| 52 | +## Documentation |
| 53 | + |
| 54 | +Each worker must have a dedicated documentation file at: |
| 55 | +`docs/user-guide/temporal/workers/<worker-name>.md` |
| 56 | + |
| 57 | +Documentation must include: |
| 58 | + |
| 59 | +- Purpose and responsibilities of the worker |
| 60 | +- List and description of workflows and activities |
| 61 | +- Required environment variables |
| 62 | +- Integration points (e.g., databases, APIs) |
| 63 | +- Best practices and troubleshooting |
| 64 | + |
| 65 | +## Best Practices |
| 66 | + |
| 67 | +- Keep workflow and activity logic modular and well-tested. |
| 68 | +- Use clear, descriptive names for workflows, activities, and task queues. |
| 69 | +- Update documentation with every significant change to workflows or activities. |
| 70 | +- New workers must not duplicate logic already present in shared modules. |
| 71 | +- Place all shared code in `workers-shared/` to maximize reuse and maintainability. |
| 72 | + |
| 73 | +## Enforcement |
| 74 | + |
| 75 | +- PRs introducing new Temporal workers or workflows **must** follow this structure and update documentation accordingly. |
0 commit comments