# CRM Platform — Phased Module Roadmap

> v1 ships a working CRM. v1.5 adds communication + billing. v2 adds domain-specific apps + AI.
> Each row maps a module/feature to a version. Scope is fixed; timing is driven by deployment signals.

---

## v1 — Current Plan + Support + Document

**Demo-ready end-to-end across 5 product profiles.** Specced in `phases/phase0.md`, `phase1.md`, `phase2.md`.

### Universal modules (every profile)

| Module | Path | Status |
|---|---|---|
| Lead | `CrmApp/Lead/` | ✅ specced — `modules/lead.md` |
| Deal | `CrmApp/Deal/` | ✅ specced — `modules/deal.md` |
| Contact (CRM view) | `CrmApp/Contact/` | ✅ specced — `modules/contact.md` |
| Activity | `CrmApp/Activity/` | ✅ specced — `modules/activity.md` |
| **Support** | `CrmApp/Support/` | ⏳ **new — needs `modules/support.md` spec.** Same skeleton as Lead/Deal: migration with `HasPipeline + HasCustomFields + HasActivityTimeline + FiresWorkflowEvents`, filter, service, policy, controller, pages, routes. Adds a 17th tenant table. Adds `pipeline_type='support'` to PipelineEngine. Slots into Phase 2 as **2.6**. |
| **Document** | `CrmApp/Document/` | ⏳ **new — thin wrapper.** Reuses existing Spatie MediaLibrary integration. One `documents` table with `entity_type`/`entity_id` polymorphic FK + `category` + `verified_at`. No new engine work. Slots into Phase 2 as **2.7**. |

### Engines (CoreApp — all 6 + scaffolds)

`FieldEngine`, `PipelineEngine`, `ActivityEngine`, `WorkflowEngine`, `EntityEngine`, `LabelEngine`, `Proposal scaffold` — all spec'd in `engines/` and locked into Phase 1.

### Profiles shipped

`taskco-crm-{general, education, realstate, pharma, garments}` — all 5 with full pack JSONs (`packs/*.md`).

### v1 trigger to start v1.5

v1 deployed to ≥1 paying tenant in each of the 5 profiles, no P1 bugs open for 30 days.

---

## v1.5 — Communication + Invoice Integration

**Ships only after v1 is stable in production.** Adds the two pieces every domain in your spec asked for but that need real external integration.

| Module / feature | What it adds |
|---|---|
| **Communication** | New `CrmApp/Communication/` module. Email (SMTP/IMAP polling), WhatsApp Business API, message log table (`communication_logs`). Adds two new WorkflowEngine actions: `SendEmail`, `SendWhatsApp` — wired into existing dispatcher, no engine change. |
| **Invoice integration** | New WorkflowEngine action: `CreateInvoice`. Calls SalesApp's existing invoice-create entry point on `deal.stage_changed → Won`. Tied to existing `SalesApp/Invoice` module — verify entry point exists before committing. |

**v1.5 trigger to start v2:** at least one domain (likely Education or Real Estate) signals demand for vertical depth — typically a paying customer asking for "the property/university list" inside the CRM.

---

## v2 — Domain Apps + AI

**Vertical depth. Each piece ships only when its target profile has paying customers asking for it.**

| Item | Profiles needing it | Notes |
|---|---|---|
| **AcademicApp** (Universities, Courses) | Education only | New nwidart app. Pack JSON declares `requires_modules: ['AcademicApp']` to opt-in. |
| **Property** module | Real Estate only | Same opt-in pattern. |
| **AI features** | All — vertical-tuned | Swap `NullAiHook` for real implementation per domain. University recommendation (education), price prediction (real estate), buyer intent scoring (garments), visa success prediction (education), document validation (education). |
| **WorkflowEngine admin UI** | All | Phase 3.1 of current plan. |
| **EntityEngine admin UI** | All | Phase 3.2. |
| **ActivityEngine UI polish** | All | Phase 3.3. |
| **Proposal UI** | All | Phase 3.4. |
| **Pipeline management UI** | All | Phase 3.7. |
| **Pack import/export panel** | All | Phase 3.9. |

These align with the existing Phase 3 items already in `phases/phase3.md`, plus the two domain apps.

---

## Architectural addition: "Domain Modules" tier

The architecture diagram gets one new tier:

```
Tier 0 — Product Profiles (5 PHP files)
Tier 1 — CoreApp engines (headless, all profiles)
Tier 2 — CrmApp universal modules
            v1:   Lead, Deal, Contact, Activity, Support, Document
            v1.5: + Communication
Tier 2.5 — Domain modules (only on specific profiles)              ← v2
            v2:   AcademicApp (education), Property (real estate)
Tier 3 — Admin UIs                                                  ← v2
```

A pack JSON can declare `"requires_modules": ["AcademicApp"]`. The `setup:crm` command enables those modules per tenant via the existing `modules_statuses.json` + AppRegistry — no new mechanism.

---

## What does NOT change between versions

- The 6 CoreApp engines (one ServiceProvider, one migrations folder)
- The pack-JSON-driven configuration model
- The label-rebrand mechanism
- `EntityRegistry::convertsTo()` indirection (wired in v1)
- Seed-driven workflow rules + `workflow:tick` scheduled triggers
- Additive-only seeders (R4)

Any new module added in v1.5 or v2 plugs into the existing engines. **No engine refactor between versions.**
