# @openhi/constructs

AWS CDK constructs for deploying OpenHI infrastructure. The library provides reusable constructs for applications, shared infrastructure (auth and core resources), data services, and common components used across OpenHI stacks.

## Source Boundaries

- `src/components`: reusable infrastructure building blocks and thin service integrations around AWS primitives.
- `src/data`: persistence models, data access operations, API routes, and storage-specific handlers.
- `src/workflows`: deployed async business processes, their EventBridge event contracts, workflow Lambda constructs, handlers, and tests.

Workflow Lambdas should live under a plane namespace such as `src/workflows/control-plane` or `src/workflows/data-plane`. Trigger-specific handlers in `components` or API routes should stay thin and publish workflow events when the business process can run asynchronously.

Use `events.ts` for EventBridge contracts, `<workflow>.handler.ts` for runtime handlers, `<workflow>-lambda.ts` for Lambda constructs, `<workflow>.handler.test.ts` for handler tests, and a `<domain>-workflow.ts` construct when EventBridge rules or multiple workflow Lambdas are deployed together.

## Strategy

Workflow placement (bus selection, Lambda vs. Step Functions, standard event envelope, idempotency contract, cross-boundary rules) is governed by [ADR-016 — Workflow Boundary Strategy](https://github.com/codedrifters/openhi-planning/blob/main/docs/src/content/docs/requirements/architectural-decisions/ADR-016-workflow-boundary-strategy.md) in the planning repo.
