# Domain Map

## Domain ownership

| Domain | Owns | May depend on |
|---|---|---|
| Foundation | clocks, IDs, request context, shared contracts | Laravel only |
| Identity | credentials, verification, 2FA, auth events | Foundation, Audit port |
| Access Control | users' roles, permissions, policies | Identity, Foundation |
| Company | company profile, teams, public contact details | Media, Settings |
| Content | home sections and reusable page content | Media, SEO |
| Catalog | categories, services, industries, templates, features, technologies | Media, SEO |
| Pricing | currencies, price lists, entries, rules, packages | Catalog, Audit |
| Quotations | quote requests, snapshots, workflow | Catalog, Pricing, CRM |
| Scheduling | types, assignees, availability, meetings, history | Identity, AI, CRM |
| CRM | contacts, leads, clients, lead transitions | Scheduling, Quotations |
| Portfolio | projects, client/service/technology links | CRM, Catalog, Media, SEO |
| Publishing | blog posts, assets, review/publication | Media, SEO, Identity |
| Recruitment | jobs and applications | Media, SEO, Notifications |
| AI | agent registry, provider configs, grounded sessions | Catalog, Pricing, Scheduling |
| Analytics | events, aggregates, metric definitions | read-only projections/events |
| Media | objects, variants, attachments, downloads | Identity/Access for policies |
| Notifications | templates, deliveries, preferences | queued domain events |
| Audit | append-only audit records | actor identity/request context |
| SEO | metadata, redirects, sitemap state | publishable resources |
| Integrations | provider connections and delivery attempts | Settings, Audit |
| Settings | typed scoped settings | Audit, encryption service |

## Communication rules

1. A module owns all writes to its tables.
2. Cross-domain reads use an exported query/service contract or an explicit read
   model; Eloquent relationships across boundaries are read conveniences only.
3. Domain events are past tense and contain IDs/minimal immutable facts, not
   serialized Eloquent models.
4. Queued listeners are idempotent and cannot be part of an invariant-preserving
   transaction.
5. Circular dependencies are resolved through ports/events or by moving a real
   shared concept to Foundation—not by service-locator calls.
6. Presentation code never invokes another module's controller.

## High-level flow

```mermaid
flowchart LR
  I["Identity & Access"] --> A["Admin / Public Delivery"]
  C["Catalog"] --> P["Pricing Engine"]
  C --> Q["Quotations"]
  P --> Q
  C --> AI["Grounded AI"]
  P --> AI
  AI --> Q
  AI --> S["Scheduling"]
  S --> CRM["CRM / Leads / Clients"]
  Q --> CRM
  E["Domain Events"] --> N["Notifications"]
  E --> AN["Analytics"]
  E --> AU["Audit"]
```

