feat: Add tier-based vehicle limit enforcement (#23) #25
Reference in New Issue
Block a user
Delete Branch "issue-23-vehicle-limit-enforcement"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements tier-based vehicle limits to prevent users from exceeding their subscription allowance:
Fixes #23
Implementation Details
Backend Changes
VEHICLE_LIMITSconfiguration tofeature-tiers.tswith per-tier limitsgetVehicleLimit()andcanAddVehicle()helper functionsFOR UPDATElocking to prevent race conditionsVehicleLimitExceededErrorclass for limit violationscountByUserId()method to VehiclesRepositoryTIER_REQUIREDerror format (consistent with existing tier gating)Frontend Changes
useTierAccesshook withgetResourceLimit()andisAtResourceLimit()methodsVehicleLimitDialogcomponent with mobile/desktop responsive modesuseVehicleLimitCheckshared hook for managing limit stateRace Condition Prevention
The implementation uses PostgreSQL transactions with
FOR UPDATElocking:This ensures concurrent requests cannot bypass the limit.
Test Plan
Screenshots
Manual testing screenshots to be added
Notes
TIER_REQUIREDpattern for consistency🤖 Generated with Claude Code