# ADR-011: Independent Enterprise Loyalty Platform Service

| Field | Value |
| --- | --- |
| Status | Accepted |
| Date | 2026-07-24 |
| Deciders | Platform Architecture |
| Supersedes | — |
| Superseded by | — |

## Context

Multiple business modules (Restaurant, Marketplace, Ecommerce, Academy, Booking, Healthcare, Salon, Gym, and future modules) need loyalty, points, rewards, campaigns, referrals, wallets, and gift cards. Embedding loyalty inside CRM or any single business module would couple unrelated domains and prevent reuse.

## Decision

Loyalty is an **independent shared platform service** (`loyalty-service`) with:

1. Dedicated database `loyalty_db` (ADR-001)
2. Permission prefix `loyalty.*`
3. Publish-only domain events `loyalty.*`
4. Row-level multi-tenancy via `tenant_id` (ADR-003)
5. Immutable point ledger as the sole source of balances (Phase 7.2+) — direct balance mutation is forbidden
6. Consumption by business modules via REST API + Events only — never via shared tables or CRM ownership

Loyalty must **not** belong to CRM, Restaurant, or Ecommerce.

## Consequences

### Positive

- Reusable loyalty across all business modules
- Clear ownership and independent schema evolution
- Enforceable ledger / audit invariants

### Negative

- Modules must integrate asynchronously for eventual consistency of customer 360 views
- Cross-module references use external IDs / refs only

### Neutral

- Phase 7.0 ships foundation aggregates; engines (membership, points, rewards, campaigns, referral, wallet, gift card, analytics, public APIs) land in Phases 7.1–7.9

## Alternatives Considered

1. Loyalty subsystem inside CRM — rejected (CRM is Sales-only; Loyalty is cross-module)
2. Per-module loyalty tables — rejected (duplication, inconsistent rules)
3. Shared monolith database schema — rejected (ADR-001)

## Related Documents

- [Module Boundaries](../module-boundaries.md)
- [Database Architecture](../database-architecture.md)
- [ADR-001](ADR-001.md) · [ADR-003](ADR-003.md) · [ADR-006](ADR-006.md)
- [Loyalty Phase 7.0](../../loyalty-phase-7-0.md)
- [Module Registry — loyalty](../../module-registry.md#loyalty)
