Construction · United States

Multi-tenant construction SaaS with geofenced time tracking that cut admin work by more than half

Schema-per-tenant Django architecture with PostGIS geofencing for automatic clock-ins, payroll and invoicing automation, a crew mobile app, and a Stripe webhook state machine for subscriptions and affiliate payouts.

Client
Construction management platform
Engagement
Ongoing partnership
Period
2022 to present
  • 60%+less admin overhead on payroll and invoicing
  • 40%+higher time-tracking accountability
  • 10+modules behind one API
The product

What it is

A management platform for construction companies: projects, tasks, crews, timesheets, leave, payroll, invoicing and inventory in one system, with a mobile app for workers in the field. Each company signs up as its own tenant, pays per staff member, and can be referred in by affiliates who earn a commission.

Where we came in

Construction firms were running crews from spreadsheets and paper timesheets. The product needed strict separation between companies (payroll data for one firm must never be visible to another), a time clock that didn't rely on workers remembering to punch in, and billing that scaled with headcount. We built the backend and the APIs that the web and mobile apps run on, and have maintained it since.

What we owned

  • Multi-tenant architecture and the tenant-aware authentication layer
  • REST APIs for 10+ modules: projects, tasks, timesheets, payroll, invoicing, leave, inventory, dashboards
  • Geofenced time-clock punches via PostGIS
  • Stripe subscription billing with affiliate commission payouts
  • Push notifications and the mobile dashboard and task-tracking APIs
  • PDF generation for payroll and invoices
Architecture

How the system is layered, from the people using it down to the data and the services it depends on.

  1. 01Clients
    • Web app
    • Crew mobile app
    • Affiliate portal
  2. 02API
    • Django REST Framework
    • Tenant-aware JWT
    • Role permissions
  3. 03Tenancy
    • django-tenants
    • Schema per company
    • Shared public schema for billing and affiliates
  4. 04Geospatial
    • PostGIS via custom tenant-aware backend
    • Site geofences
    • Radius matching in the database
  5. 05Billing and messaging
    • Stripe subscriptions
    • Webhook state machine
    • Affiliate payouts
    • Firebase Cloud Messaging
Engineering decisions

The choices that made the difference, and why we made them.

  1. 01

    Isolation the database enforces

    Each company lives in its own PostgreSQL schema. A query can't cross tenants because the connection's search path only contains one company's schema. JWTs are issued with the tenant baked in and verified against the resolved tenant on every request, so a token for one company can't be replayed against another.

  2. 02

    PostGIS inside a schema-per-tenant setup

    The tenants backend and the PostGIS backend both wrap Django's Postgres backend, and you can only pick one engine. We wrote a small custom backend that inherits from both, which lets spatial fields work inside every tenant schema. Geofence matching is then a single database query: the nearest site whose radius contains the worker's location.

  3. 03

    Time clock punches that happen on arrival

    The mobile app reports significant location changes; the backend matches them against site geofences and opens or closes a punch automatically. Manual entry dropped and accountability rose by more than 40 percent, because the record reflects where people were, not what they remembered.

  4. 04

    Subscription state that survives webhook chaos

    Stripe delivers events out of order, late and more than once. A webhook state machine reconciles six-plus event types into a single subscription state per tenant, with tiered per-staff pricing and automated affiliate commission payouts fired on activation.

Outcome
  • Automated payroll and invoicing, with PDF exports, cut administrative overhead by more than 60 percent.
  • Geofenced punches raised time-tracking accountability by more than 40 percent.
  • Per-staff billing and affiliate referrals support tenant onboarding without engineering involvement.

Technology

  • Python
  • Django
  • django-tenants
  • PostgreSQL
  • PostGIS
  • Stripe
  • Firebase
  • Docker
  • AWS

Building something similar?

Tell us what you're building. You'll get a straight answer on scope, timeline and cost, usually within one business day.