CRM pipeline: opportunities and configurable stages, attached to identity-parties (leads live on Person)
| Tier | domain |
| Role | unclassified (baselined) |
| Path | crates/domain/crm |
| Edition | 2021 |
| Targets | domain_crm |
| Public items | 0 across 0 modules |
| Tests | 29 |
What it is for
domain-crm: Opportunity + Stage pipeline library crates
Overview
Post-lead CRM pipeline: tenant-configurable Stages and Opportunity records attached to a identity_parties::Person or Organization. Leads are not modeled here -- identity_parties::Person already carries lead_status/lead_source/lead_owner_id; this crate starts after a lead has qualified into a pipeline opportunity (survey gap #3, docs/userstories/sprint-3.50-crm-pipeline.md, Gate 1.5 AC-scope).
Layer
Domain - depends on: foundation-basemodels, foundation-money
Key Types
Stage- a tenant-configurable pipeline stageOpportunity- a pipeline opportunity attached to a Person/OrganizationOpportunityPartyKind- Person|Organization discriminator (local, not
a reuse of domain_contact::PartyType -- Gate 1.5 Round 2, OQ3)
CrmService- high-level business operations
Example
use domain_crm::{CrmService, CreateOpportunityRequest, OpportunityPartyKind};
let service = CrmService::new(pool);
service.ensure_default_pipeline(tenant_id).await?;
let (opp, event) = service.create_opportunity(CreateOpportunityRequest {
tenant_id,
party_id: person_id,
party_kind: OpportunityPartyKind::Person,
stage_id: new_stage_id,
name: "Managed services -- initial engagement".to_string(),
owner_id: staff_user_id,
value_amount: None,
value_currency: None,
source: Some("Referral".to_string()),
}).await?;
Capabilities
No public items.
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into foundation.
Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (41 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | domain |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/domain/crm |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_domain["domain"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
| `foundation-money` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
rust_decimal | ^1 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json, rust_decimal | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
rust_decimal_macros | ^1 | — | no | always |
tokio | ^1 | full, test-util | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_crm["application-crm"] -->|uses| SELF SELF["domain-crm"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] SELF -->|runtime| n_foundation_money["foundation-money"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | domain_crm | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-crm.
Verification
| Kind | Count |
|---|---|
| Unit tests | 29 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
test_already_closed—src/errors.rstest_lost_reason_required—src/errors.rstest_opportunity_not_found—src/errors.rstest_stage_not_found—src/errors.rstest_validation_error—src/errors.rstest_event_serialization—src/events.rstest_opportunity_created_event—src/events.rstest_stage_changed_event—src/events.rstest_won_lost_events—src/events.rstest_crm_events_end_to_end—src/lib.rstest_lost_pipeline_requires_reason_end_to_end—src/lib.rstest_pipeline_workflow—src/lib.rstest_default_pipeline_has_one_won_one_lost—src/models.rstest_intern_currency_known_and_unknown—src/models.rstest_move_already_closed_opportunity_errors—src/models.rstest_move_to_lost_stage_rejects_blank_reason—src/models.rstest_move_to_lost_stage_requires_reason—src/models.rstest_move_to_lost_stage_with_reason_closes_opportunity—src/models.rstest_move_to_stage_open_uses_stage_default_probability—src/models.rstest_move_to_stage_probability_override_wins—src/models.rstest_move_to_won_stage_closes_opportunity—src/models.rstest_opportunity_new_defaults_open—src/models.rstest_opportunity_soft_delete—src/models.rstest_opportunity_with_value—src/models.rstest_party_kind_roundtrip—src/models.rstest_stage_as_lost—src/models.rstest_stage_as_won—src/models.rstest_stage_new_is_open_non_terminal—src/models.rstest_status_is_closed—src/models.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 6 |
| Source lines | 1469 |
| Code lines | 1100 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 29 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 9 |
| Workspace reverse dependencies | 1 |
pie showData
title Rust source composition
"Code" : 1100
"Blank or comment" : 369
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.