DEV Community

Cover image for Modeling ADU Lot Setbacks, Lot Coverage, and Buildable Envelopes in TypeScript
Clara Sutton
Clara Sutton

Posted on Originally published at plancaliber.hashnode.dev

Modeling ADU Lot Setbacks, Lot Coverage, and Buildable Envelopes in TypeScript

When a homeowner decides to build a backyard Accessory Dwelling Unit (ADU), casita, or in-law suite, the design almost never fails inside the kitchen or bathroom. It fails at the property line.

A buyer falls in love with a 30' x 36' (1,080 sq ft) floor plan, spends a weekend picking cabinets, and then discovers that after subtracting the existing main house, the front street setback, the 4'-0" side and rear ADU setbacks, and a 10'-0" fire-separation buffer between detached structures, their backyard can only fit a 20' x 36' (720 sq ft) rectangle.

When we built the interactive US ADU Size & Setback Calculator inside PlanCaliber, we needed a pure TypeScript parcel-geometry model that checks setbacks, detached separation, lot coverage ratio, and state-level minimum-size protections in under a millisecond and hands the resulting exact footprint straight into our 2D/3D CAD studio.


1. The Four Geometric Constraints on Every Backyard ADU

Most US municipal ADU ordinances evaluate a proposed backyard unit against four interacting rules:

  1. Parcel Setbacks (front, side, rear): States like California (Gov. Code 66314) and Oregon cap detached ADU side and rear setbacks at 4'-0", while many suburban zoning districts use 5'-0" to 10'-0" unless a state ADU preemption applies.
  2. Detached Structure Separation (buildingGapFt): Standard residential fire separation under IRC Table R302.1(1) typically requires 6'-0" to 10'-0" between an unprotected detached ADU exterior wall and the primary dwelling (or 1-hour fire-rated wall construction when placed closer).
  3. Maximum Lot Coverage (maxCoveragePct): The sum of the primary house footprint, existing garage/sheds, and the new ADU divided by total parcel square footage must stay under the zone limit (often 40% to 50%), except where state law guarantees an 800 sq ft minimum detached ADU regardless of lot coverage.
  4. Absolute Area Cap (maxAduSqFt): Commonly 800 sq ft (studio/1-bed), 1,000 sq ft (2-bed), or 1,200 sq ft maximum detached floor area, or 50% of the primary dwelling area where local percentage caps apply.

2. Deterministic TypeScript Buildable-Envelope Engine

Instead of returning a vague "maybe" to a homeowner, we compute the exact remaining rear-yard bounding box, compare the proposed ADU width and depth against both the buildable rectangle and the lot-coverage budget, and emit actionable sizing diagnostics.

export interface ParcelAduInput {
  lotWidthFt: number;
  lotDepthFt: number;
  mainHouseWidthFt: number;
  mainHouseDepthFt: number;
  mainHouseFrontSetbackFt: number;
  existingAccessorySqFt: number;
  aduSideSetbackFt: number;
  aduRearSetbackFt: number;
  detachedSeparationFt: number;
  maxLotCoveragePct: number;
  maxAduSqFt: number;
  stateGuarantees800SqFt: boolean;
  proposedAduWidthFt: number;
  proposedAduDepthFt: number;
}

export interface AduEnvelopeResult {
  lotAreaSqFt: number;
  maxBuildableWidthFt: number;
  maxBuildableDepthFt: number;
  maxRearEnvelopeSqFt: number;
  existingFootprintSqFt: number;
  proposedAduSqFt: number;
  projectedCoveragePct: number;
  remainingCoverageBudgetSqFt: number;
  effectiveMaxAduSqFt: number;
  fitsRearEnvelope: boolean;
  passesCoverageRule: boolean;
  recommendedWidthFt: number;
  recommendedDepthFt: number;
  warnings: string[];
}

const round1 = (n: number): number => Math.round(n * 10) / 10;

export function evaluateAduEnvelope(input: ParcelAduInput): AduEnvelopeResult {
  const lotAreaSqFt = round1(input.lotWidthFt * input.lotDepthFt);
  const mainHouseSqFt = round1(input.mainHouseWidthFt * input.mainHouseDepthFt);
  const existingFootprintSqFt = round1(mainHouseSqFt + input.existingAccessorySqFt);

  const maxBuildableWidthFt = Math.max(
    0,
    round1(input.lotWidthFt - 2 * input.aduSideSetbackFt)
  );
  const mainHouseRearEdgeFt = input.mainHouseFrontSetbackFt + input.mainHouseDepthFt;
  const maxBuildableDepthFt = Math.max(
    0,
    round1(
      input.lotDepthFt -
        mainHouseRearEdgeFt -
        input.detachedSeparationFt -
        input.aduRearSetbackFt
    )
  );

  const maxRearEnvelopeSqFt = round1(maxBuildableWidthFt * maxBuildableDepthFt);
  const proposedAduSqFt = round1(input.proposedAduWidthFt * input.proposedAduDepthFt);

  const maxAllowedTotalFootprint = (lotAreaSqFt * input.maxLotCoveragePct) / 100;
  const rawCoverageBudget = Math.max(0, round1(maxAllowedTotalFootprint - existingFootprintSqFt));

  // State-level 800 sq ft minimum ADU floor where applicable
  const coverageAllowanceSqFt = input.stateGuarantees800SqFt
    ? Math.max(rawCoverageBudget, 800)
    : rawCoverageBudget;

  const effectiveMaxAduSqFt = round1(
    Math.min(input.maxAduSqFt, maxRearEnvelopeSqFt, coverageAllowanceSqFt)
  );

  const projectedCoveragePct =
    lotAreaSqFt > 0
      ? round1(((existingFootprintSqFt + proposedAduSqFt) / lotAreaSqFt) * 100)
      : 0;

  const fitsRearEnvelope =
    input.proposedAduWidthFt <= maxBuildableWidthFt &&
    input.proposedAduDepthFt <= maxBuildableDepthFt;

  const passesCoverageRule =
    proposedAduSqFt <= coverageAllowanceSqFt && proposedAduSqFt <= input.maxAduSqFt;

  const warnings: string[] = [];
  if (!fitsRearEnvelope) {
    warnings.push(
      `Proposed ${input.proposedAduWidthFt}'x${input.proposedAduDepthFt}' footprint exceeds the ${maxBuildableWidthFt}'x${maxBuildableDepthFt}' rear buildable envelope.`
    );
  }
  if (proposedAduSqFt > input.maxAduSqFt) {
    warnings.push(
      `Proposed ${proposedAduSqFt} sq ft exceeds the ${input.maxAduSqFt} sq ft detached ADU cap.`
    );
  }
  if (proposedAduSqFt > rawCoverageBudget) {
    warnings.push(
      input.stateGuarantees800SqFt && proposedAduSqFt <= 800
        ? `Exceeds ${input.maxLotCoveragePct}% lot coverage (${projectedCoveragePct}%), relying on the 800 sq ft state ADU floor.`
        : `Projected ${projectedCoveragePct}% lot coverage exceeds the ${input.maxLotCoveragePct}% cap.`
    );
  }

  // Clamp proposed aspect ratio into the legal envelope for instant CAD launch
  let recommendedWidthFt = Math.min(input.proposedAduWidthFt, maxBuildableWidthFt);
  let recommendedDepthFt = Math.min(input.proposedAduDepthFt, maxBuildableDepthFt);
  if (recommendedWidthFt * recommendedDepthFt > effectiveMaxAduSqFt && recommendedWidthFt > 0) {
    recommendedDepthFt = Math.floor((effectiveMaxAduSqFt / recommendedWidthFt) * 2) / 2;
  }

  return {
    lotAreaSqFt,
    maxBuildableWidthFt,
    maxBuildableDepthFt,
    maxRearEnvelopeSqFt,
    existingFootprintSqFt,
    proposedAduSqFt,
    projectedCoveragePct,
    remainingCoverageBudgetSqFt: rawCoverageBudget,
    effectiveMaxAduSqFt,
    fitsRearEnvelope,
    passesCoverageRule,
    recommendedWidthFt: round1(recommendedWidthFt),
    recommendedDepthFt: round1(recommendedDepthFt),
    warnings
  };
}
Enter fullscreen mode Exit fullscreen mode

3. Four Real-World US Residential Lot Benchmarks

Running evaluateAduEnvelope() across four typical suburban and urban US single-family lots shows why checking geometry before drafting saves weeks of rework:

Lot Profile Lot Size Rear Envelope (4' Setbacks, 10' Gap) Proposed ADU Projected Coverage Status
Narrow Urban Lot (40'x100') 4,000 sq ft 32' x 26' (832 sq ft) 20' x 24' (480 sq ft) 45.0% Fits envelope; check 45% vs 40% zone cap
Classic Suburban (50'x120') 6,000 sq ft 42' x 46' (1,932 sq ft) 20' x 40' (800 sq ft) 40.0% Passes setbacks & 40% coverage cleanly
Deep Ranch Lot (60'x140') 8,400 sq ft 52' x 60' (3,120 sq ft) 28' x 36' (1,008 sq ft) 35.8% Room for 2-bed ADU + patio buffer
Shallow Corner (65'x85') 5,525 sq ft 57' x 17' (969 sq ft) 20' x 32' (640 sq ft) 40.5% Fails depth (20' > 17'); rotate to 32' x 16'

That fourth row is one of the most frequent real-world catches: a 20' x 32' unit fails a shallow backyard by 3 feet, whereas rotating and reshaping into a 16' x 32' (512 sq ft) linear layout slides right inside the 17'-0" rear buildable depth without touching a variance board.


4. Generating an Interactive Site Envelope SVG and Launching Directly into 2D/3D CAD

Once the envelope clears, the calculator renders a live scaled site-diagram SVG showing the parcel lines, dashed setback inset, main house footprint, fire-separation corridor, and proposed ADU placement, then passes recommendedWidthFt and recommendedDepthFt straight into our browser floor plan studio via query parameters:

export function buildAduStudioUrl(res: AduEnvelopeResult): string {
  const params = new URLSearchParams({
    intent: 'adu',
    w: String(res.recommendedWidthFt),
    d: String(res.recommendedDepthFt),
    source: 'calc_adu'
  });
  return `/app?${params.toString()}`;
}
Enter fullscreen mode Exit fullscreen mode

That single URL handoff drops the homeowner directly onto a pre-sized imperial wall shell where they can partition bedrooms, verify 36" kitchen aisles and bathroom clearances, inspect the space in 3D, export a free watermarked proof PNG, or unlock unwatermarked vector PDF sheets (from $9 one-time) and layered AutoCAD .DXF files ($19 one-time).


Try It Live

Preliminary space-planning and zoning-envelope reference only. Always verify recorded parcel surveys, utility easements, fire-rated wall separation, height limits, and local city/county ADU ordinances on site before construction.

Top comments (0)