Case Study
CLIENT CONTACT MANAGEMENT SYSTEM
Role
Backend Engineer
Platform
Enterprise B2B Sales & CRM Platform
Core capabilities
- Territory RBAC
- Approvals
- Cascade Targets
- Quote to PDF
.webp)
What is CCMS?
A production enterprise CRM for a hierarchical sales organization (Sales Rep → Manager → Director → VP → President → CFO → CEO), unifying client companies/accounts/contacts, territory-based data isolation, manager-approved sales pipelines, cascade revenue-target planning, and a quote-to-order document lifecycle with PDF generation and email — all synced with a company-wide SSO directory.
What I built
- Hierarchical RBAC & Set-Diff Territory Propagation. Engineered TerritoryPropagationService and TerritoryAccessService across a 7-tier sales hierarchy (Profile::getDescendantIds BFS traversal with cycle protection) — granting company, state, and city access down reporting subtrees and executing transactional set-diff cascade revocations when a manager's territory changes.
- Cascade Budget & Revenue Target Engine. Built CompanyTargetService and UserTargetService to allocate global and regional revenue buckets down the org chart without double-counting redistributions, enforcing consumed-budget deletion guards, bottom-up subtree cascade deletes, and TargetObserver audit trails.
- Race-Free Quote-to-Order & PDF Pipeline. Designed a two-stage manager approval workflow (PipelinePolicy, SalesQuotePolicy) that converts multi-line sales quotes into orders, acquires a Cache::lock atomic mutex for year-aware sequential quote numbering, renders Dompdf A4 documents, and emails ZIP-batched attachments (>5 PDFs) via DB-configured SMTP.
- 20K+ Row Bulk Import & Quarantine Pipeline. Built CompanyContactController::importRecords using FastExcel with 1,000-row chunked inserts and in-memory company/contact pre-fetch caches to eliminate per-row N+1 queries — normalizing US phones, inferring missing states from a 200+ area-code map, and quarantining incomplete rows behind a global Eloquent scope.
System scope
- Territory-Scoped AccessGranular company/state/city grants that aggregate up the reporting hierarchy and revoke from the entire subtree inside one transaction.
- Target Allocation EngineCascade revenue-target allocation (global → regions → users) with double-spend prevention, downline protection, and consumed-target deletion guards.
- Quote → PDF → EmailTwo-stage approval, race-free sequential quote numbering under a cache lock, branded Dompdf generation, and ZIP-batched emailing.
- Hierarchy-Driven AuthorizationCycle-safe, depth-capped recursive org tree powering query scopes, policies, and per-role pipeline visibility — reorganizations take effect instantly.
- SSO & User SynchronizationToken-exchange SSO plus bidirectional HMAC-SHA256 user provisioning with AuthCenter, retried via queued jobs with backoff.
- High-Volume Bulk ImportChunked bulk inserts with pre-fetch caches, phone normalization, US state inference, and a follow-up duplicate-resolution flow.
Inside the product
LET'S BUILD
YOUR NEXT SYSTEM
Whether you are hiring for a backend engineering role, architecting a multi-system SaaS platform, or automating complex operational workflows — let's connect.