leecycle·design doc

Leecyclelive

An AI-guided ERP for waste and sustainability operations — with access rules that hold across every business on it.

spec.yaml
type:
AI-powered waste & sustainability ERP
context:
Professional work · Tech Prastish
area:
Platform · Multi-tenant ERP
stack:
9 technologies
Node.jsExpressTypeScriptPostgreSQLNext.jsReactZodVitestTurbo

01Problem

Waste haulers, municipalities, recyclers and other waste operators run routes, dispatch, billing, compliance, fleet and customer service across disconnected tools — and on one shared platform, every company, branch, team and field has to stay behind access rules that can be audited.

02Approach

Leecycle is an AI-guided operating system for waste and sustainability: 27 solutions — route planning and dispatch, billing and payments, CRM, logistics and fleet, weighbridge, environmental compliance and ESG reporting, learning management, a driver app and a customer portal — with AI route optimisation and predictive insights. Every module stands on shared foundations: tenant registry, organisation hierarchy, roles, an ABAC policy engine, data scopes with row-level security, field-level security and audit logs.

03Architecture← the interesting bit

  1. pnpm + Turbo monorepo: a Node/Express API and multiple Next.js "zone" apps behind one shell
  2. PostgreSQL as the source of truth; row-level data scopes and field-level security
  3. ACM: permissions compiled per subject (role, team, department, service account…) instead of per user × resource
  4. Tiered permission resolution ending in default deny; pattern-based policies like module.finance.*
  5. Audit & access logs, approval matrix, document numbering, currencies & FX as platform services

04From the notebook

may this person do it? — Leecyclerequestuser, module, actiontenant registrywhich company?which branch / dept?access model (ACM)compiled per subject:role, team, dept,service account…module.finance.*patterns, not liststiered resolutionmost specific first …… ends in DEFAULT DENYnothing matched? → nodata scopesrow-level: which rowsfield-level: which fieldsaudit + access logrow per user× per resource✗ grows multiplicatively→ compile per subject27 solutions,one core underneath

05Trade-offs & hard parts

risk.01Per-user × per-resource permission rows grow multiplicatively; the access model had to compile permissions per subject to stay small and fast.
risk.02Keeping the core industry-agnostic while CRM, fleet and LMS each pull it toward their own shape.

06Ownership

owner: Worked on the shared multi-tenant foundations every module stands on: tenant registry, organisation hierarchy, the ABAC policy engine, row-level data scopes, field-level security and audit logs.

— Hankish

07Outcome

Live at leecycle.io: 27 solutions across 11 waste and recycling industries — haulers, municipalities, recyclers, commercial, roll-off, skip hire, construction & demolition, scrap metal, hazardous waste, portable sanitation and enterprise.

next: /services/roadpulseRoadPulse