Forge CRM pipeline module (opportunities/stages). Sprint 3.50, survey gap #3.
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/crm |
| Edition | 2024 |
| Targets | application_crm |
| Public items | 22 across 4 modules |
| Tests | 4 |
What it is for
application-crm — Layer 3 module. Sprint 3.50 (CRM/pipeline, survey gap #3).
Capabilities
crate root
application-crm — Layer 3 module. Sprint 3.50 (CRM/pipeline, survey gap #3).
| Item |
|---|
fn assert_single_tenant_mount(is_multi_tenant_host : bool) -> Result <(), & 'static str> |
CrmModule
application-crm — Layer 3 module. Sprint 3.50 (CRM/pipeline, survey gap #3).
| Item |
|---|
pub struct CrmModule |
CrmModule :: fn new() -> Self |
CrmModule :: fn name(& self) -> & 'static str |
CrmModule :: fn version(& self) -> & 'static str |
CrmModule :: fn migrations(& self) -> Vec <MigrationSet> |
CrmModule :: async fn migrate_pending(& self, _pool : & PgPool) -> Result <u32, MigrationError> |
CrmModule :: fn permission_codes(& self) -> Vec <String> |
api (other)
application-crm HTTP API. Sprint 3.50.
| Item |
|---|
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
api::crm_admin (other)
CRM admin REST router.
| Item |
|---|
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
MoveStageBody
CRM admin REST router.
| Item |
|---|
pub struct MoveStageBody |
OpportunityListQuery
CRM admin REST router.
| Item |
|---|
pub struct OpportunityListQuery |
TenantQuery
CRM admin REST router.
| Item |
|---|
pub struct TenantQuery |
services::crm (other)
CRM service — thin wrapper around domain_crm::CrmService.
| Item |
|---|
async fn ensure_default_pipeline(pool : & PgPool, tenant_id : Uuid,) -> Result <Vec <Stage>, CrmError> |
async fn list_stages(pool : & PgPool, tenant_id : Uuid) -> Result <Vec <Stage>, CrmError> |
async fn create_stage(pool : & PgPool, req : CreateStageRequest) -> Result <Stage, CrmError> |
async fn create_opportunity(pool : & PgPool, req : CreateOpportunityRequest,) -> Result <(Opportunity, CrmEvent), CrmError> |
async fn get_opportunity(pool : & PgPool, id : Uuid) -> Result <Option <Opportunity>, CrmError> |
async fn opportunities_for_party(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <Vec <Opportunity>, CrmError> |
async fn open_pipeline(pool : & PgPool, tenant_id : Uuid, stage_id : Option <Uuid>, owner_id : Option <Uuid>,) -> Result <Vec <Opportunity>, CrmError> |
async fn move_opportunity_to_stage(pool : & PgPool, tenant_id : Uuid, opportunity_id : Uuid, target_stage_id : Uuid, probability_override : Option <i16>, lost_reason : Option <String>,) -> Result <(Opportunity, CrmEvent), CrmError> |
async fn delete_opportunity(pool : & PgPool, tenant_id : Uuid, id : Uuid) -> Result <(), CrmError> |
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
application_crm
apiapi::crm_adminservicesservices::crm
flowchart TD n_application_crm["application_crm"] n_application_crm --> n_api["api"] n_api --> n_api__crm_admin["crm_admin"] n_application_crm --> n_services["services"] n_services --> n_services__crm["crm"]
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct CrmModule | — |
CrmModule :: fn new() -> Self | — |
CrmModule :: fn name(& self) -> & 'static str | — |
CrmModule :: fn version(& self) -> & 'static str | — |
CrmModule :: fn migrations(& self) -> Vec <MigrationSet> | — |
CrmModule :: async fn migrate_pending(& self, _pool : & PgPool) -> Result <u32, MigrationError> | — |
CrmModule :: fn permission_codes(& self) -> Vec <String> | — |
fn assert_single_tenant_mount(is_multi_tenant_host : bool) -> Result <(), & 'static str> | Gate 1.5 OQ4 guard: crm_opportunities.party_id cannot be tenant-checked against persons/organizations (they carry no tenant_id column yet, issue #222) |
`api`
| Item | What it is |
|---|---|
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | Admin router for the CRM pipeline, generic over consumer state S |
`api::crm_admin`
| Item | What it is |
|---|---|
pub struct TenantQuery | — |
pub struct OpportunityListQuery | — |
pub struct MoveStageBody | — |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | — |
`services::crm`
| Item | What it is |
|---|---|
async fn ensure_default_pipeline(pool : & PgPool, tenant_id : Uuid,) -> Result <Vec <Stage>, CrmError> | — |
async fn list_stages(pool : & PgPool, tenant_id : Uuid) -> Result <Vec <Stage>, CrmError> | — |
async fn create_stage(pool : & PgPool, req : CreateStageRequest) -> Result <Stage, CrmError> | — |
async fn create_opportunity(pool : & PgPool, req : CreateOpportunityRequest,) -> Result <(Opportunity, CrmEvent), CrmError> | — |
async fn get_opportunity(pool : & PgPool, id : Uuid) -> Result <Option <Opportunity>, CrmError> | — |
async fn opportunities_for_party(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <Vec <Opportunity>, CrmError> | — |
async fn open_pipeline(pool : & PgPool, tenant_id : Uuid, stage_id : Option <Uuid>, owner_id : Option <Uuid>,) -> Result <Vec <Opportunity>, CrmError> | — |
async fn move_opportunity_to_stage(pool : & PgPool, tenant_id : Uuid, opportunity_id : Uuid, target_stage_id : Uuid, probability_override : Option <i16>, lost_reason : Option <String>,) -> Result <(Opportunity, CrmEvent), CrmError> | — |
async fn delete_opportunity(pool : & PgPool, tenant_id : Uuid, id : Uuid) -> Result <(), CrmError> | — |
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into domain, foundation, platform.
Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 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) | application |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/application/crm |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_application["application"] --> n_domain["domain"] n_application["application"] --> n_foundation["foundation"] n_application["application"] --> n_platform["platform"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-core` | application | no | always |
| `domain-crm` | domain | no | always |
| `foundation-money` | foundation | no | always |
| `platform-dto` | platform | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
axum | ^0.7 | multipart | no | always |
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 | no | always |
thiserror | ^2 | — | no | always |
tracing | ^0.1 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development. None.
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["application-crm"] SELF -->|runtime| n_application_core["application-core"] SELF -->|runtime| n_domain_crm["domain-crm"] SELF -->|runtime| n_foundation_money["foundation-money"] SELF -->|runtime| n_platform_dto["platform-dto"] 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 | application_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 | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | yes |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CARGO_PKG_VERSION | src/lib.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 4 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 2 | 0 | 0 |
api | 1 | 0 | 0 |
api::crm_admin | 4 | 0 | 0 |
services::crm | 9 | 0 | 0 |
What the tests establish, by name:
test_module_migrations_empty—src/lib.rstest_permission_codes—src/lib.rstest_single_tenant_guard_allows_single_tenant_host—src/lib.rstest_single_tenant_guard_refuses_multi_tenant_host—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 2 | 22 |
Public modules with a //! block | 3 | 4 |
pie showData
title Public items with rustdoc
"Documented" : 2
"No rustdoc detected" : 20
Metrics
| Metric | Value |
|---|---|
| Rust source files | 5 |
| Source lines | 417 |
| Code lines | 338 |
| Public API items | 22 |
| Public modules | 4 |
| Tests | 4 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 14 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"function" : 12
"method" : 6
"struct" : 4
pie showData
title Rust source composition
"Code" : 338
"Blank or comment" : 79
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.