LionsHead Analytics GroupLionsHead Analytics Group

Work

Selected engagements, portable patterns.

6 systems LionsHead has architected and shipped. Each was built for a specific industry, the architecture itself is portable across every breakout principal practice. The doctor who left the hospital system, the lawyer who left the big firm, the advisor who left the fund, the dentist who hung her own shingle. Every one of them is solving the same operational problem on a different surface. The patterns below translate. Implementation details, credentials, and any client identifying surface are intentionally omitted. The patterns travel, the proprietary work doesn't.

Recovery

Producer Advance Verification

1 in 3 deals your producers were paid on didn't stick.

29,435 policies verified · 10,291 chargebacks identified · 2 books, 1 enrollment cycle

The problem

Producers get paid before the money is confirmed. The advance goes out that week, whether the policy survives is settled months later by a third party, and checking means opening records one at a time at a volume nobody has the hours for. So the advance stands. The policy dies. Nobody looks.

What we did

One complete enrollment cycle, 15 October 2025 to 10 July 2026. Every policy in both books verified against its actual status at the source, then matched back to the advance already paid.

  • 29,435 policies verified, 110 a day for 268 days
  • 10,291 chargebacks identified, about 35% of the book
  • $60 to $100 per advance, some higher, some as low as $20

At 1 minute a record that is 490 hours, which is why nobody was doing it.

Why the number is stated this way

We report exposure identified, not money saved. Some of those would have surfaced on their own eventually. The claim we can prove is 10,291 advances that should not have stood, found across 29,435 verified.

What transfers

Reconciling a machine readable counterparty record against your own ledger, one row at a time, at a volume that defeats manual review. Carrier statements. Remittance advice. Bank confirmations. Advertising spend against the calls it actually produced. Anywhere the answer sits in a system you can read but not the one you keep.

The Work

Every system we've shipped, one card at a time.

Flip through the deck and the full breakdown underneath follows the card in focus. The first 6 are the systems that fit almost any small, growing team, and each carries its whole case study, the problem, the architecture, the result, and the verticals it has been mapped to. Keep going for the specialist and health focused builds, like OCR policy verification for agencies buried in manual reconciliation.

TLDCRM repeats because these 10 shipped for agencies running it, not because the integration layer needs it. Interpreters exist for Salesforce and HubSpot too, so adding a platform is 1 file. Several shipped in Python and were rebuilt in .NET, which swapped the interpreters and left the interfaces above them alone.

Marketing Attribution · Web to Phone · Compliance as Code

Live

The Attribution Chain

  • Next.js
  • Node
  • SQL
  • PostgreSQL
  • Neon
  • Vercel
  • REST API
  • TLDCRM
  • Google Ads
  • Facebook Ads
  • Bing Ads
  • Google Analytics 4
  • Meta Pixel
  • Search Console

Paid Acquisition

A health agency was buying traffic it could not connect to a single sale. 1 phone number across 355 links meant the source of every call was gone the moment somebody picked up. Now a click resolves to a session, a session to a call, and a call to a policy.

lib/db/queries/reporting.jsSanitized
// Chosen from this map, never interpolated from a request.const DIMENSION_SQL = {  source:   SOURCE_LABEL,  campaign: `COALESCE(s.campaign, '(not set)')`,} // The report counts what it could NOT attribute, beside// what it could. A blind spot with a size gets fixed.SELECT count(*)                                AS total,       count(*) FILTER (WHERE lead_id IS NULL) AS unattributed  FROM calls WHERE started_at >= ?
Click to preview
01 / 09
The Attribution Chain

Full breakdown of The Attribution Chain below.Flip the deck to change what you are reading.

Arrow keys or buttons to move · click a card to open it

Now showing the breakdown for The Attribution Chain.

Marketing Attribution · Web to Phone · Compliance as Code

The Attribution Chain: From Ad Click to Enrolled Policy

Best Fit For:

  • AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
  • Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
  • Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
  • AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical
    Legal
    Advisory
    Insurance
    Securities
    Dental
    Mortgage
    Accounting
    Behavioral
    Veterinary
    Pharmacy
    Home Care
    Real Estate
    Property
    Recruiting
    Consulting
    Media
    AEC
    Medical

Principal Architect

  • Next.js App Router on Node
  • PostgreSQL, no ORM, raw SQL with quote aware parameter translation
  • 15 tables, 43 indexes, 4 migrations
  • Identity chain, visitor to session to call click to call to lead to policy
  • First touch and last touch attribution, both stored
  • Edge middleware auth, invite based admin, guarded again per page
  • Scheduled dialer mirror with shrink, overlap and invalidation guards
  • Server only import boundary on every data module
  • Consent capture verbatim, retention purge, automated accessibility audit
  • Error codes LH-4001 through LH-5031

Problem

The agency was paying for advertising with no instrument connecting any of it to a sale. 1 phone number served all 355 links on the site, so the source of every call was erased the moment somebody picked up. Underneath that sat the real constraint. The client held an editor login. Somebody else held the repository, the deployment, and the content dataset. They could reword a heading. They could not add a route, add a table, read a log, or export their own content in any structured form. The rebuild was forced by an access problem, not an engineering one.

Architectural Solution

Recover the content, then rebuild underneath it. 176 pages and 59 images were archived first, and 155 education articles were extracted into flat files the client now controls, where a git log shows every change to any of them. The build is Next.js App Router on Node with PostgreSQL, no ORM and no content management system (CMS). Content is code, so regulated copy carries a review diff on every change rather than being editable by anybody optimising a layout. Schema came before application code. Migration 001 builds visitors, sessions, call clicks, leads, consents, sync state and an audit log, with first touch on the visitor and last touch on the session, both stored. The cookie names, the reserved module paths and the timezone pin were all fixed before a single event was collected. Purchased leads land in the same table as website leads, authenticated per vendor with the source tag taken from the key rather than the payload, so cost per acquisition compares directly across both.

Tangible Result

The agency owns the repository, the database, the deployment, and the record. Every lead is written before it is forwarded and carries a tracking id minted in code rather than by the insert, so it survives a slow vendor and a failed write. Consent is stored verbatim as it was displayed. The published 24 month retention window has a purge script behind it, the published 30 day privacy deadline is written at insert rather than computed on read, and the accessibility statement is generated from an automated audit across 17 pages. The archive pass also surfaced a published relay number that reached nothing, on 528 pages, 1 wrong digit and the highest value fix in the engagement. The chain is instrumented from the lead forward. The call leg is what remains.

Same pattern, different surface

The same chain applies anywhere advertising is bought against a conversion that happens on a phone call rather than in a form, and the phone system is owned by somebody else.

  • Insurance agency, paid search into a call floor
  • Law firm, paid intake where the first call is the conversion
  • Mortgage, ad spend measured against funded loans rather than applications
  • Medical practice, paid acquisition measured to a booked appointment

Where it scales

The reporting layer was built and reviewed before a single event was collected. The admin reads through 1 dispatch that swaps between fabricated fixtures and the real queries, identical shapes either way, with a banner on every page while fixtures are on. Every timestamp is stored in coordinated universal time (UTC) with the session pinned to a business timezone, so a report grouped by day lands on the day the agents actually worked rather than splitting across 2 UTC dates. The dialer mirror pulls on a schedule behind 3 guards, a shrink guard that refuses any full pull returning under 90% of the rows already held, a 30 minute cursor rewind, and cron that calls the route rather than the script so cache invalidation runs inside the application runtime.

Where it mutates

The layer boundary is enforced rather than documented. Every data module carries an import guard, so a client component that reaches for one fails the build instead of shipping a database credential into a browser bundle. A startup check throws if any public environment variable name looks like a key or a token. Migration 001 uses foreign keys because it owns both sides of every relationship and controls write order. Migration 002, the dialer mirror, carries none, because a call can arrive referencing an agent hired an hour ago, and 1 foreign key failure would roll back the entire nightly sync over a label nobody has looked at. An unknown code should surface as an unknown row on a dashboard. It should never stop the sync.

lib/db/queries/reporting.js

/* The earliest surviving policy for a lead.
A lead can hold more than one over time, a rejected
application followed by a good one. The funnel counts
people rather than paperwork, so it takes the first and
nothing else. Counting policies would make 1 persistent
customer look like 2 conversions.
missing_since is excluded. A policy the dialer has
stopped returning is one it deleted, and counting it
would report business that no longer exists. */
 
const POLICY_JOIN = `
LEFT JOIN LATERAL (
SELECT policy_id, effective_date, policy_status
FROM policies
WHERE policies.lead_id = l.lead_id
AND policies.missing_since IS NULL
ORDER BY policies.submitted_at NULLS LAST
LIMIT 1
) p ON true`

Disclosure

What you're not seeing here.

A curated selection

The case studies above are a deliberate sample of recent work. Additional engagements, deeper architectures, and adjacent tooling exist in the private archive. Client names, system endpoints, credentials, schema level identifiers, and any logic that could be reverse engineered are intentionally omitted.

View the full project archive

Available under engagement

Live demos, full architecture briefs, and verifiable production metrics are available during a Discovery & Architecture Blueprint engagement. Request access via the contact form and we'll send the materials under NDA.

Request the dossier

Engage

Recognize your firm in one of these?

Most do. The patterns repeat across every breakout founder practice. Medical, legal, advisory, dental, and every other operation that has to build the infrastructure the institution used to provide. If your producers are paid before the revenue confirms, start with the audit. Fixed fee, scoped to the size of your book.