LeadFlow CRM

Software Engineer · 2023 · 3 Months · 2 people · 3 min read

A custom-engineered internal CRM commissioned by the CEO to centralize lead acquisition, automate distribution logic, and eliminate the manual overhead of spreadsheet-based sales tracking.

Overview

Tasked by executive leadership to solve a critical 'lead leakage' problem, I architected a Django-based CRM that serves as the company's single source of truth for sales data. The system automates the ingestion of leads from various marketing channels and implements a proprietary assignment engine to ensure rapid follow-up.

Problem

The sales department relied on fragmented spreadsheets, leading to a 15% lead loss rate due to manual entry errors and slow response times. The CEO required a centralized platform to gain real-time visibility into the sales pipeline and scale operations without the recurring costs of enterprise SaaS licenses.

Constraints

  • Must provide real-time executive reporting for the CEO
  • Requires an automated 'Round-Robin' lead distribution system
  • Deployment must be on-premise to comply with internal data privacy standards
  • Database must handle rapid spikes in lead volume during marketing campaigns

Approach

Developed a robust Django MVT architecture with a focus on data integrity. I implemented a 'Service Layer' pattern to handle the complex lead assignment logic, keeping it separate from the web views. To provide a modern user experience without a heavy frontend framework, I utilized HTMX for dynamic UI updates like lead status toggles and filtered searches.

Key Decisions

Weighted Round-Robin Assignment Logic

Reasoning:

To eliminate manual bottlenecks, I built a custom assignment engine that automatically routes leads to sales reps based on their current workload and availability. This removed the need for a manager to manually 'hand out' leads.

Alternatives considered:
  • Manual Assignment (The original bottleneck)
  • Random Assignment (Unfairly distributed workload among reps)

HTMX for Partial Page Updates

Reasoning:

The CEO requested a fast, reactive dashboard. HTMX allowed me to implement inline editing and real-time filtering with minimal JavaScript, keeping the codebase maintainable for a solo engineer while meeting the performance requirements.

Alternatives considered:
  • React/Vue (Would have exceeded the 3-month development window)
  • Standard Django Form Submissions (Too slow for high-volume sales tasks)

Tech Stack

  • Python (Django)
  • PostgreSQL
  • HTMX
  • Tailwind CSS
  • Redis & Celery
  • Docker

Result & Impact

  • 95% Improvement (< 5 mins vs hours)
    Response Time
  • 18% Increase in first-month ROI
    Lead Conversion
  • Zero SaaS licensing fees
    Cost Savings

The tool successfully transitioned the company from a reactive sales posture to a data-driven one. By automating the most tedious parts of the sales funnel, the team could focus entirely on closing deals, while the CEO gained an instant, accurate view of company revenue health.

Learnings

  • Building for internal stakeholders requires a deep understanding of the business workflow; an engineer must act as a product manager when reporting directly to a CEO.
  • Automated 'fail-safes'—like re-assigning a lead if it isn't claimed in 15 minutes—are more effective for productivity than manual oversight.
  • Relational database constraints are the most effective tool for preventing the 'data rot' common in spreadsheet-based systems.

Additional Context

The primary technical challenge was ensuring that the Lead Assignment Engine was thread-safe. In high-traffic periods where multiple leads arrived simultaneously via webhooks, the system had to ensure a lead was never assigned to two reps at once. I solved this by using PostgreSQL’s select_for_update() to lock the assignment records during the routing calculation.

By delivering this tool, I replaced a system that was fundamentally broken with a scalable asset. The final product didn’t just store data; it enforced a disciplined sales process that directly contributed to the company’s bottom line, proving the value of a custom-built internal solution over generic software.