{"slug":"architecture/001-projection-engine-sole-composition-layer","title":"ADR-001: Projection Engine is the Sole Composition Layer","section":"architecture","sectionLabel":"Architecture","status":"unclassified","type":"document","path":"architecture/001-projection-engine-sole-composition-layer.mdx","bytes":1510,"description":null,"updated":null,"source":"integratewise/Integratewise-docs-wiki","content":"\n**Status:** Accepted  \n**Date:** 2026-07-21  \n**Deciders:** Nirmal (Founder)\n\n---\n\n## Context\n\nThe IntegrateWise platform has multiple services that read from the Adaptive Spine: gateway, twin-orchestrator, intelligence, workflow. Without a single composition point, each service would construct its own view of the workbench, leading to inconsistent projections and duplicated logic.\n\n## Decision\n\nThe `@integratewise/projection-engine` package is the **sole component** that produces a `SharedWorkbench`. No other package, service, or route handler may construct this shape.\n\nThe gateway (BFF) delegates all composition to `ProjectionEngine.compose()`. It handles auth, routing, and response formatting — but never assembles entities, relationships, or capabilities directly.\n\n## Consequences\n\n- **Positive:** Single source of truth for workbench composition. Consistent output shape across all consumers. Easier to test and reason about.\n- **Negative:** All composition logic lives in one package. Changes to composition affect all consumers simultaneously.\n- **Mitigation:** Versioned contract (`contracts/shared-workbench/v1.ts`). Breaking changes require version bump and ADR.\n\n## Evidence\n\n- `packages/projection-engine/src/projection-engine.ts` — `compose()`, `morningContext()`, `entity360()`, `inbox()`\n- `services/gateway/src/projections.ts` — delegates to `ProjectionEngine`\n- `contracts/shared-workbench/v1.ts` — frozen contract\n"}