Back to Work

Case Study

ClientGate v4

Full-feature agency & client management platform: multi-tenant agencies, invoicing, payments, domains, AI capabilities, and a dedicated client portal—all under one roof.

Multi-tenant Invoicing & Payments Client Portal AI & Automation

At a Glance

Type

SaaS Platform

Stack

PHP 8, MySQL, Tailwind

Full Feature Outline

Everything that ships in v4.
Auth, agencies, invoicing, payments, domains, AI, and more.

Authentication & Access

01
  • Login / Logout – Session-based auth
  • Password reset – Forgot password, reset via token
  • Invite-only registration – Request access → Admin approves → Payment token → Set password → Activate
  • Payment token activation (pay_token.php) – View plan, pay externally, admin verifies
  • Role-based access (RBAC) – Senior Admin, Agency Admin, Agency Staff, Client

Multi-Tenant / Agencies

02
  • Agencies – Name, slug, plan (Free / Pro / Enterprise), billing status
  • Tenant isolation – Clients, invoices, domains, payment refs scoped by agency
  • Senior Admin – Platform owner, sees all agencies, approves registration requests
  • Agency Admin / Staff – See only their agency’s data
  • Registration requests – Approve, reject, generate payment tokens

Client Management

03
  • Clients – Add, edit, view
  • Client-scoped data – Invoices, domains, payment refs, receipts
  • Preferred currency – Per-client display currency
  • Client portal – Separate dashboard for clients

Invoicing

04
  • Create / Edit / View invoices – With line items
  • Invoice numbering – e.g. INV-YYYY-NNN
  • Statuses – Draft, Sent, Overdue, Partial, Paid
  • Mark as paid – Manual approval
  • Send invoice – Email (via includes/mail.php)
  • Print invoice – PDF export
  • Multi-currency – Base (USD) + display currency, exchange rates

Tax & Compliance

05
  • TIN / VRN – Agency tax identity
  • VAT – Percentage and selective application
  • Tax receipts – Auto-generated on payment
  • Receipt tax migration – Dedicated migration for receipt tax fields

Payment References

06
  • Generate references – Unique control numbers per invoice/domain
  • Status workflow – Pending → Submitted → Approved / Rejected
  • Payment proof upload – Client submits proof for admin review
  • Document AI – Parse payment proofs (amount, reference, date, payer)

Payments & Gateways

07
  • Manual payment flow – Proof upload → Admin approve
  • Flutterwave integration – Tanzania mobile money (M-Pesa, Tigo, Airtel, Halopesa)
  • “Pay with Mobile Money” – Button on invoice for instant payment
  • Webhook – flutterwave_webhook.php for auto confirmation
  • USD→TZS conversion – When invoice is in USD

Receipts

08
  • Auto receipt generation – On invoice payment
  • PDF download – Professional receipt export
  • Tax breakdown – VAT on receipts

Domain Management

09
  • Add / Edit / View domains – Per client
  • Expiry tracking – Expiry date, annual cost
  • Renewal workflow – Domain renewal, renewal invoices
  • Status lifecycle – Active → Expired → Suspended (cron-driven)
  • Reminders – Send expiry reminders
  • Nameserver tracking – Current and pending nameservers
  • Transfer lock/unlock – Fields and workflow for transfers
  • File manager link – Per-domain file manager URL for clients

Reports

10
  • Revenue report – By client, date range, monthly aggregation
  • Invoice aging – 0–30, 31–60, 61–90, 90+ days overdue
  • Domain expiry pipeline – 7, 30, 60 days to expiry
  • Export – PDF, CSV, Excel (role- and agency-scoped)

Multi-Currency

11
  • Base currency – USD
  • Display currency – Per client / invoice
  • Exchange rates – currency_rates table
  • Cron – cron_refresh_currency_rates.php (e.g. every 12h)
  • Optional ExchangeRate API – Via EXCHANGERATE_API_KEY

Client Portal

12
  • Dashboard – Overview for clients
  • My Invoices – View, pay, print
  • My Receipts – Download
  • My Domains – View domains and status
  • Pay Now – submit_payment.php with reference lookup and proof upload
  • Invoice pay page – Pay invoice, including mobile money
  • Profile – Update account details

Support & Tickets

13
  • Support tickets – Subject, message, priority
  • NLP analysis – Sentiment, topics, auto-priority suggestion
  • Email logging – Tickets logged to email_logs
  • Activity logs – Ticket creation recorded

File Vault

14
  • Shared files – Admin shares with clients
  • File types – Invoice, contract, image, zip, PDF
  • Domain portals – Links to hosting file managers per domain
  • Visibility – Client-visible files

AI Capabilities

15
  • Predictive, Anomaly, Recommendation, NLP, Document, Conversational, Workflow
  • OpenAI chat integration

Activity & Audit

16
  • Activity logs – User actions, IP, user agent
  • Audit log – Structured old/new JSON for important changes
  • CSRF – Forms protected with CSRF tokens

Settings

17
  • Agency settings – Name, tax, currency
  • Payment config – Flutterwave keys, auto payments toggle
  • OpenAI API key – .env or settings table

Cron Jobs

18
  • cron_ai_compute_scores.php – AI scores, anomaly detection, workflow automation
  • cron_refresh_currency_rates.php – FX rates
  • cron_suspend_domains.php – Domain status transitions (expired, suspended)

Notifications

19
  • In-app notifications – notifications table
  • Email – Account approved, payment verified, etc.
  • PHPMailer – Used for email sending

UI & UX

20
  • Tailwind CSS – UI styling
  • Alpine.js – Client-side interactivity
  • Responsive layout – Mobile-friendly
  • Left nav drawer – Hamburger menu
  • Activity drawer – Right-side activity feed
  • Search bar – Global search
  • Landing page – Marketing/home page with feature overview