Delivered remotely for a business based in Boston, United States. Names withheld by agreement.
Project Overview
Complex B2B sales cycles depend on clean institutional memory across marketing handoffs, multi-threaded stakeholder conversations, and renewal milestones. Working with commercial operations teams in Boston, we engineered a custom CRM platform powered by Python, Django, React, PostgreSQL, and Celery. The system centralizes account hierarchies, customizable deal pipelines, bi-directional email thread logging, and territory-scoped forecasting inside a fast web interface built for daily high-volume use.
Business Bottleneck
Off-the-shelf CRM suites had become brittle under custom territory rules and multi-entity B2B account structures. Reps spent hours manually copying email threads into activity logs, duplicate company profiles polluted pipeline reports whenever inbound leads arrived from multiple channels, and revenue operations analysts had to export raw CSVs every Friday because native reports could not reconstruct what the pipeline looked like at the start of the quarter. Performance degraded noticeably whenever account executives filtered thousands of open opportunities across regional views.
Architectural Strategy
We structured the backend as a strongly modular Django application backed by PostgreSQL and Celery, paired with a React and TypeScript frontend optimized for rapid keyboard navigation and dense data tables. All synchronous web requests stay focused on authenticated reads, permission-checked mutations, and instant inline edits.
External integrations—including mailbox delta polling, webhook ingestion, bulk spreadsheet imports, and territory reassignment cascades—run asynchronously through Celery workers coordinated via Redis. By recording every deal mutation in an append-only timeline table alongside normalized current-state tables, the platform supports both crisp transactional updates and auditable point-in-time pipeline analysis.
Core Capabilities
- Multi-Pipeline Deal Management: Configurable deal stages with required exit criteria, probability weights, and virtualized Kanban and table views.
- Automated Account & Contact Deduplication: Domain-based matching and fuzzy trigram candidate detection that merge inbound duplicates without losing historical activity.
- Incremental Mailbox Synchronization: OAuth-authenticated Gmail and Microsoft 365 sync capturing relevant client threads automatically onto account timelines.
- Territory & Hierarchy Access Control: Regional visibility boundaries supporting parent-child corporate accounts, split deal ownership, and sensitive field masking.
- Point-in-Time Forecast Snapshots: Historical pipeline comparisons tracking slippage, stage velocity, and newly created pipeline across fiscal quarters.
- Bulk Import & Enrichment Workflows: Validated background CSV ingestion with dry-run error previews, rollback protection, and rate-limited enrichment hooks.
Technical Architecture
Flow: React SPA (TypeScript) -> Django REST Framework (Gunicorn) -> PostgreSQL (Account/Deal Graph + Ledger) & Redis / Celery Workers (Email Delta Sync & Imports)
Authenticated sessions enter Django REST Framework endpoints where custom permission classes translate user roles and territory trees into SQL-level query predicates. React renders large opportunity tables using window virtualization and splits detail views into parallel cached queries so opening a deal drawer displays notes, stakeholders, and synced email threads without blocking the pipeline board.
On the ingestion path, Celery beat schedules incremental mailbox pulls using provider delta tokens stored encrypted in PostgreSQL. Before executing a mailbox job, a worker obtains a per-account Redis mutex to prevent overlapping polls. Matched emails are parsed into normalized activity records linked via RFC Message-ID uniqueness constraints, while deal stage updates simultaneously commit an immutable audit entry used by forecasting queries.
Technology Stack
| Category | Technology detail |
|---|---|
| Backend Framework | Python and Django with Django REST Framework for typed resource endpoints |
| Frontend Workspace | React and TypeScript with virtualized pipeline boards and inline record drawers |
| Transactional Store | PostgreSQL storing accounts, contacts, deal stages, and immutable activity ledgers |
| Async Processing | Celery workers orchestrating email sync, lead enrichment, and CSV bulk imports |
| Broker & Cache | Redis serving as Celery task broker, distributed lock store, and permission cache |
| Email Integration | OAuth2 incremental sync adapters for Microsoft Graph and Gmail history cursors |
| Search & Filtering | PostgreSQL trigram and GIN indexes powering fuzzy account and contact matching |
| Infrastructure | Containerized Gunicorn and Celery worker pools deployed with health-checked zero-downtime releases |
Engineering Trade-offs & Solutions
| Challenge | Architectural Solution |
|---|---|
| Preventing concurrent mailbox sync workers from duplicating emails | Per-mailbox Redis distributed locks combined with unique (tenant_id, rfc_message_id) database constraints |
| Rendering thousands of deals without sluggish browser scrolling | Windowed table virtualization in React paired with keyset-paginated DRF endpoints and slim list serializers |
| Avoiding slow recursive permission checks across account hierarchies | Materialized territory path arrays indexed with PostgreSQL GIN operators for single-query visibility filtering |
| Supporting reliable quarter-over-quarter pipeline history | Append-only deal state ledger written inside the same ACID transaction as stage and value updates |
| Keeping bulk CSV imports from starving live user API requests | Dedicated Celery import queue with chunked batch upserts and isolated worker concurrency limits |
Security & Reliability
Mailbox OAuth refresh tokens are encrypted at rest using envelope encryption keys before persistence, and users can revoke mailbox scopes individually without disrupting shared account records. Domain-level exclusion rules ensure internal colleague emails and personal domains never sync onto commercial customer timelines.
All webhook and form-capture endpoints validate HMAC signatures or scoped API tokens and enforce idempotency keys to absorb upstream retries cleanly. Sensitive administrative actions—such as mass territory transfers, record merges, and CSV exports—write structured audit logs capturing actor identity, timestamp, and affected primary keys.
Performance & Scale
Query optimization relies on selective Django select_related and prefetch_related loading paired with composite indexes aligned to the most frequent filter combinations (owner_id, territory_id, stage_id, expected_close_date). Full-text and fuzzy contact searches leverage PostgreSQL pg_trgm indexes rather than introducing an external search cluster prematurely, keeping operational overhead low while preserving sub-second lookup responsiveness.
Heavy forecast aggregations read from indexed summary views refreshed when deals close or cross stage gates, ensuring executive dashboards remain snappy during end-of-quarter review meetings.
Operational Outcomes
Commercial teams gained a reliable single record of customer interactions without manual copy-pasting or fragile spreadsheet exports. Account executives spend less time cleaning duplicate entries and chasing missing email context, while revenue operations leaders inspect clean stage-by-stage pipeline movement grounded in verifiable historical snapshots.