|
| 1 | +# Guidance for Coding Agents |
| 2 | + |
| 3 | +This repository is a pnpm monorepo managed with Turbo. It contains multiple apps and packages that make up the Trigger.dev platform and SDK. |
| 4 | + |
| 5 | +## Repository layout |
| 6 | +- `apps/webapp` – Remix application that serves as the main API and dashboard. |
| 7 | +- `apps/supervisor` – Node application for executing built tasks. |
| 8 | +- `packages/*` – Published packages such as `@trigger.dev/sdk`, the CLI (`trigger.dev`), and shared libraries. |
| 9 | +- `internal-packages/*` – Internal-only packages used by the webapp and other apps. |
| 10 | +- `references/*` – Example projects for manual testing and development of new features. |
| 11 | +- `ai/references` – Contains additional documentation including an overview (`repo.md`) and testing guidelines (`tests.md`). |
| 12 | + |
| 13 | +See `ai/references/repo.md` for a more complete explanation of the workspaces. |
| 14 | + |
| 15 | +## Development setup |
| 16 | +1. Install dependencies with `pnpm i` (pnpm `8.15.5` and Node.js `20.11.1` are required). |
| 17 | +2. Copy `.env.example` to `.env` and generate a random 16 byte hex string for `ENCRYPTION_KEY` (`openssl rand -hex 16`). Update other secrets if needed. |
| 18 | +3. Start the local services with Docker: |
| 19 | + ```bash |
| 20 | + pnpm run docker |
| 21 | + ``` |
| 22 | +4. Run database migrations: |
| 23 | + ```bash |
| 24 | + pnpm run db:migrate |
| 25 | + ``` |
| 26 | +5. Build the webapp, CLI and SDK packages: |
| 27 | + ```bash |
| 28 | + pnpm run build --filter webapp && pnpm run build --filter trigger.dev && pnpm run build --filter @trigger.dev/sdk |
| 29 | + ``` |
| 30 | +6. Launch the development server: |
| 31 | + ```bash |
| 32 | + pnpm run dev --filter webapp |
| 33 | + ``` |
| 34 | + The webapp runs on <http://localhost:3030>. |
| 35 | + |
| 36 | +For full setup instructions see `CONTRIBUTING.md`. |
| 37 | + |
| 38 | +## Running tests |
| 39 | +- Unit tests use **vitest**. Run all tests: |
| 40 | + ```bash |
| 41 | + pnpm run test |
| 42 | + ``` |
| 43 | +- Run tests for a specific workspace (example for `webapp`): |
| 44 | + ```bash |
| 45 | + pnpm run test --filter webapp |
| 46 | + ``` |
| 47 | +- Prefer running a single test file from within its directory: |
| 48 | + ```bash |
| 49 | + cd apps/webapp |
| 50 | + pnpm run test ./src/components/Button.test.ts |
| 51 | + ``` |
| 52 | + If packages in that workspace need to be built first, run `pnpm run build --filter webapp`. |
| 53 | + |
| 54 | +Refer to `ai/references/tests.md` for details on writing tests. Tests should avoid mocks or stubs and use the helpers from `@internal/testcontainers` when Redis or Postgres are needed. |
| 55 | + |
| 56 | +## Coding style |
| 57 | +- Formatting is enforced using Prettier. Run `pnpm run format` before committing. |
| 58 | +- Follow the existing project conventions. Test files live beside the files under test and use descriptive `describe` and `it` blocks. |
| 59 | +- Do not commit directly to the `main` branch. All changes should be made in a separate branch and go through a pull request. |
| 60 | + |
| 61 | +## Additional docs |
| 62 | +- The root `README.md` describes Trigger.dev and links to documentation. |
| 63 | +- The `docs` workspace contains our documentation site, which can be run locally with: |
| 64 | + ```bash |
| 65 | + pnpm run dev --filter docs |
| 66 | + ``` |
| 67 | +- `references/README.md` explains how to create new reference projects for manual testing. |
| 68 | + |
0 commit comments