# Clean Architecture Data Flow (Shared Contract)

This document defines the **shared** data-flow rules that apply across all delivery applications.

It does not contain app-specific rules.

App-specific contracts:

- Core: [`docs/architecture/core/CORE_DATA_FLOW.md`](docs/architecture/core/CORE_DATA_FLOW.md:1)
- API: [`docs/architecture/api/API_DATA_FLOW.md`](docs/architecture/api/API_DATA_FLOW.md:1)
- Website: [`docs/architecture/website/WEBSITE_DATA_FLOW.md`](docs/architecture/website/WEBSITE_DATA_FLOW.md:1)

## 1) Dependency rule (non-negotiable)

Dependencies point inward.

```text
Delivery apps → adapters → core
```

Core never depends on delivery apps.

## 2) Cross-boundary mapping rule

If data crosses a boundary, it is mapped.

Examples:

- HTTP Request DTO is mapped to Core input.
- Core result is mapped to HTTP Response DTO.

## 3) Ownership rule

Each layer owns its data shapes.

- Core owns domain and application models.
- API owns HTTP DTOs.
- Website owns ViewData and ViewModels.

No layer re-exports another layer’s models as-is across a boundary.

## 4) Non-negotiable rules

1. Core contains business truth.
2. Delivery apps translate and enforce.
3. Adapters implement ports.

