Guard
Lead and referral management platform for multi-organization sales networks, with QR-code capture and automated payouts
// At a glance
Problem
Multi-organization sales networks had no shared system to capture, assign, and track leads across roles, or to automate referral payouts tied to lead outcomes.
Solution
Built a decoupled Laravel + React platform with a repository/interface pattern decoupling controllers from Eloquent, an event-driven notification architecture triggering queued mail jobs on domain events, Policy plus Spatie-permission authorization, and public QR-code/form lead capture feeding the pipeline via n8n automation.
// Key highlights
- →Repository/interface abstraction layer keeping business logic testable and decoupled from the ORM
- →Event-driven notification architecture (7+ domain events, queued mail jobs) instead of coupling email into controllers
- →Configurable, per-organization payout/commission engine tied to lead status transitions
- →Large-scale, feature-sliced React dashboard supporting five distinct role-based views
- →Public, unauthenticated lead-capture surfaces (QR + form) integrated with n8n-based email-to-lead automation
Guard is a full-stack lead and referral management platform for multi-organization sales networks. It gives Admins, Group/Partner Directors, Sales Managers, and Sales Agents role-specific dashboards to track leads through their lifecycle, schedule and manage appointments, manage teams and organizations, and automate referral payouts — with QR-code and public-form lead capture feeding directly into the pipeline.
Tech Stack
- Backend: PHP 8.2, Laravel 12, Laravel Sanctum (token auth), Spatie Laravel Permission (roles/permissions)
- Backend libraries: Endroid QR Code generator, Laravel Mail/Queue (email notifications), Pint, Pest/PHPUnit
- Database: MySQL (via Laravel migrations/Eloquent)
- Frontend: React 18, Vite 7, Tailwind CSS 3 (
tailwind-variants,tailwind-merge) - State/data: TanStack React Query, Axios
- UI/UX: MUI (date pickers), Recharts, TipTap rich text editor, React Joyride/Driver.js (onboarding tours), react-beautiful-dnd, Sonner (toasts), Tippy.js
- Other: i18next (localization), Luxon (dates), qrcode/jsPDF (QR & PDF generation), DOMPurify
- DevOps: Netlify deployment config, ESLint/Prettier, n8n workflow integration (email-to-lead automation)
Key Features
- Role-based dashboards (Admin, Group Director, Partner Director, Sales Manager, Sales Agent) with tailored analytics and stat cards
- Lead lifecycle management: creation, assignment, status tracking, notes, and conversion
- Public lead capture via QR code registration and public web forms, feeding automated intake pipelines
- Appointment scheduling with confirmation, rescheduling, cancellation, and completion follow-up emails
- Organization, team, and user management with granular role/permission control (Spatie ACL)
- Referral and payout system with configurable per-organization payout rules and transaction tracking
- Registration approval workflow for new organizations/users
- Automated transactional email system (10+ mail templates) driven by domain events and queued jobs
- Guided in-app onboarding tours, dark/light theming, and multi-language support
Architecture
Guard is a decoupled system: a Laravel 12 REST API backend and a separate React SPA frontend (feature-sliced under src/features, consumed via src/pages). The backend follows a repository-interface pattern (app/Interfaces + implementations wired through a dedicated RepositoryServiceProvider) to decouple controllers from Eloquent persistence, and uses Laravel's event/listener system extensively (LeadCreated, LeadStatusChanged, AppointmentScheduled, etc.) to trigger notification mail jobs asynchronously via queues — keeping request/response cycles fast. Authorization is centralized through Policies per resource (Lead, Appointment, Organization, Team, Transaction, User, Payout) combined with Spatie roles/permissions for fine-grained, role-aware access control. The frontend consumes the API through an Axios service layer and TanStack Query for caching/synchronization, with public-facing routes (QR registration, public lead form) separated from the authenticated dashboard shell.
My Role
- Designed a clean repository/interface abstraction layer in Laravel to keep business logic testable and decoupled from the ORM
- Built an event-driven notification architecture (7+ domain events, dedicated listeners, queued mail jobs) instead of coupling email logic into controllers
- Implemented a configurable, per-organization payout/commission engine tied to lead status transitions
- Built a large-scale, feature-sliced React dashboard supporting five distinct role-based views with shared, reusable UI primitives
- Integrated public, unauthenticated lead-capture surfaces (QR + form) with backend validation and n8n-based email-to-lead automation