Subscription Management System — PHP & MySQL
Track every subscription, renewal, payment, and client — with AI analytics, multi-currency, customer portal, and automated email alerts. Built on PHP 8 & MySQL.
🎬 Tutorial
[!IMPORTANT]
📥 Source Code — Download link is in the YouTube video description above.
What is this?
A full Subscription Management System you can host yourself. Built for businesses that sell software licenses, SaaS subscriptions, annual maintenance contracts, or any recurring service — and need to track every client, every renewal date, every payment, and every document in one place.
The system has four user roles — admin, user, salesperson, and customer — each with their own dashboard and access scope. Admins get full control including an AI chat assistant (powered by Google Gemini) that can analyze revenue data, forecast renewals, detect at-risk clients, and project salesperson commissions. Customers get their own portal to log in and see their subscriptions and invoices.
No frameworks. No Composer. PHP 8 + MySQL, React 18 on the frontend via CDN, and a service worker for PWA support. Drop it in your web root, run setup.php, and it's live.
Roles & Access
| Role |
What they can do |
admin |
Full access — all modules, settings, reports, AI chat, backup |
user |
Manage their own added subscriptions only |
salesperson |
View and manage subscriptions assigned to them, their commission data |
customer |
Customer portal — view their own subscriptions, invoices, and pricing |
How it Works
1. Admin does the initial setup (wizard guides you through it)
On first run, a setup wizard takes the admin through company branding (name, logo, email), currency selection, tax rate, notification preferences, and SMTP configuration. Once done, the wizard is dismissed and won't appear again.
From Settings, the admin can configure: company info, default currency, tax %, notification schedule, auto-email on/off, date format, timezone, maintenance mode, Google OAuth, SMTP credentials, and the Gemini API key for AI chat.
2. Load the catalog and team
Before adding subscriptions, the admin sets up:
- Products — the software/services you sell (name, selling price, purchase price, color tag, display order)
- Salespersons — your sales team with commission rates
- Customers — client companies with contact details, linked to their subscriptions
- Tax Rates — configurable named rates (e.g. GST 18%, VAT 5%) with a default
- Currencies — multi-currency with exchange rates, one marked as default
3. Add subscriptions
Each subscription record holds everything about a client's contract:
- Which customer, which product, which salesperson
- Invoice number (auto or manual), invoice date, start date, expiry date
- Selling price, purchase price, tax amount, total — profit is auto-calculated
- Payment status (Paid / Unpaid / Partial), payment method, payment date
- Product key, user count, license duration (1 Year, 6 Months, etc.)
- Auto-renew flag, priority (High / Medium / Low)
- Supplier details (who you bought it from)
- Contract reference number, remarks, document attachments
- Per-subscription currency override (different from system default)
You can also bulk-import subscriptions via CSV using the provided template.
4. Track renewals — the core workflow
The dashboard shows you exactly where everything stands:
- Expired — these needed attention yesterday
- Expiring Today — contact these clients today
- Expiring Soon — within 30 days, start the renewal conversation
- Active — more than 30 days left
The Kanban board visualizes all subscriptions across 6 status columns — Active, Expiring Soon, Expiring Today, Expired, Paused, Cancelled. When a subscription renews, a new record is created with a renewal invoice number linked to the original.
The Calendar shows every expiry date on a monthly grid — click any date to see which subscriptions are due.
The automated cron email system sends expiry alert emails to clients on a configurable schedule (e.g. 30, 15, 7, 3, 1 days before, and on expiry day). Emails use a branded HTML template with the company logo and subscription details.
5. Payments and invoices
Payments are tracked as separate records per subscription — supports partial payments, multiple installments, different payment methods (Cash, Bank Transfer, Online, Cheque). Each payment has a reference number and date.
From any subscription, you can generate a PDF-ready invoice showing company branding, customer details, product details, tax breakdown, total, and payment history. Salesperson commission is shown based on their rate.
6. Customer portal
Customers get their own login and see only their subscriptions — payment status, expiry dates, documents, and a pricing page showing available products. Nothing else in the system is visible to them.
7. AI Chat (Gemini)
Admin-only. The AI chat loads a snapshot of your entire database — subscription stats, revenue totals, monthly trends, upcoming expiries, customer breakdown, salesperson performance, unpaid amounts — and lets you ask questions in plain English.
It's set up to handle forecasting: "which subscriptions expire next month?", "what's our renewal rate?", "who are the at-risk clients?", "project next quarter revenue". The system prompt enforces a chain-of-thought process (Understand → Gather → Analyze → Challenge → Verify → Answer) so it cross-checks its numbers instead of just guessing.
8. Everything is logged
Every action across the system writes to activity_logs with the user, IP, module, action type, and before/after values. Session management shows active sessions per user. Notification logs track every email sent.
Features
📊 Dashboard
- KPI cards — Total Subscriptions, Active, Expiring Soon, Expiring Today, Expired, Total Revenue, Unpaid Amount
- Subscription status distribution chart (Chart.js)
- Monthly revenue and profit trend (12 months)
- Product breakdown chart
- Role-aware: admins see everything, salespersons see their pipeline, users see their own
🗂️ Subscriptions (Core Module)
- Full CRUD with all fields (see "How it Works" above)
- Subscription lifecycle — Active / Paused / Cancelled with timestamps and cancel reason
- Days-left counter with color-coded urgency
- Profit per subscription (selling price − tax − purchase price)
- Per-subscription currency override
- Renewal invoice number linked to original
- Document attachments per subscription (PDF, DOC, DOCX, images — up to 15MB)
- CSV bulk import with downloadable template
- CSV export via DataTables
- Auto-renew flag
🟦 Kanban Board
- 6 automatic columns: Active, Expiring Soon, Expiring Today, Expired, Paused, Cancelled
- Cards sorted by expiry date
- Each card shows customer, invoice, product, payment status, salesperson
- Role-filtered — salespersons and users see only their own
💰 Payments
- Separate payment records per subscription
- Supports partial payments and multiple installments
- Payment method, reference number, notes per record
- Payment history shown on invoice
- CSV bulk import
- Admin/salesperson/user filtered views
🧾 Invoice Generator
- Printable invoice per subscription
- Shows: company branding, customer details (from linked customer record or subscription fields), product, dates, selling price, tax breakdown, total
- Payment history section
- Salesperson name and commission rate
- Clean print-ready layout
👥 Customers
- Company name, contact person, email, phone, address, city, country
- Notes field
- Custom fields (configured per entity type in Custom Fields manager)
- CSV import with downloadable template
- Linked to subscriptions — customer phone shows on subscription cards
📦 Products
- Catalog of software/services you sell
- Selling price, purchase price, color tag, description, display order
- Active/inactive toggle
- Used in subscription forms and customer-facing pricing page
🧑💼 Salespersons
- Name, email, phone, department, commission rate
- Linked to subscriptions
- Salesperson role in the system gets a scoped dashboard showing their own pipeline
📈 Reports
- Revenue Report — 12-month bar/line chart of revenue, profit, and unpaid amounts
- Product Report — revenue and count per product
- Customer Report — top customers by revenue
- Salesperson Report — commission and revenue per salesperson
- Payment Analysis — collection patterns, outstanding amounts
- All charts rendered via Chart.js, all data respects role-based filtering
🤖 AI Chat — Gemini (Admin Only)
Ask your subscription data anything in plain English.
- Powered by Google Gemini API (you provide the key in Settings)
- Full database context injected per conversation — subscription stats, monthly revenue, upcoming expiries, payment breakdown, customer and salesperson lists
- Multi-turn conversation history preserved in the session
- Handles: revenue analysis, renewal forecasting, at-risk client detection, unpaid collection priorities, salesperson performance, "what if" projections
- Enforced chain-of-thought: AI must verify calculations against raw data before answering
- Read-only — cannot modify any data
🌐 Customer Portal
- Separate role (
customer) for your clients
- Customers log in and see only their own subscriptions — status, dates, payment, documents
- Pricing page shows available products with prices
- No access to any internal data, other clients, financials, or settings
📅 Calendar
- Monthly grid view of all subscription expiry dates
- Dates with expiries highlighted — click to see which subscriptions are due
- Role-filtered as usual
🔔 Notifications
- In-app notification bell with unread count badge
- Mark individual or all notifications as read
- Notification Logs — full history of all alerts sent
- Cron email system — automated expiry alerts with configurable schedule (e.g. 30, 15, 7, 3, 1, 0 days before expiry)
- Branded HTML email template with company logo, subscription details, expiry urgency color
- Cron can be triggered via CLI (
php cron_email.php) or browser with a secret token
💱 Multi-Currency
- Add any currency with code, symbol, and exchange rate
- Set one as the system default
- Per-subscription currency override for international clients
- Revenue displayed in the system currency
🧮 Tax Rates
- Named tax rates (e.g. GST 18%, VAT 5%, No Tax)
- Set a default rate
- Active/inactive per rate
🧩 Custom Fields
- Add dynamic fields to Subscriptions or Customers
- Field types: text, number, date, dropdown, textarea, checkbox
- Mark fields as required
- Set display order
- Values stored in
custom_field_values table, linked per entity
⚙️ Settings (Admin)
| Setting |
Description |
| Company Info |
Name, email, logo, copyright text |
| Currency |
Default system currency |
| Tax |
Default tax percentage |
| Notifications |
Days before expiry to alert (e.g. 30,15,7,3,1,0) |
| Auto Email |
Toggle automated expiry emails on/off |
| Email Frequency |
Daily or weekly batch |
| Date Format |
MM/DD/YYYY, DD/MM/YYYY, YYYY-MM-DD |
| Timezone |
Any PHP-supported timezone |
| Maintenance Mode |
Block all non-admin access with a maintenance page |
| Gemini API Key |
Key for the AI chat module |
| Forgot Password |
Show/hide password recovery on login page |
| User Uploads |
Toggle profile avatar uploads system-wide |
📧 SMTP Setup
- Full SMTP configuration: host, port, username, password, encryption (TLS/SSL)
- Test email button
- Used for: expiry alerts, OTP, password reset
🔐 OAuth (Google)
- Google OAuth integration for login
- Configure Client ID, Client Secret, and redirect URI from the OAuth Setup page
👤 User Management
- Full CRUD for system users
- Roles: admin, user, salesperson, customer
- Link salesperson account to a salesperson record (for scoped dashboard)
- Link customer account to a customer record (for portal access)
- Avatar upload per user
- Last login tracking
- Active/inactive toggle
💾 Backup
- One-click database backup — exports all tables to a
.sql file
- Shows table-by-table row count and size before backup
- Download the backup file directly from the browser
📱 PWA (Progressive Web App)
- Dynamic
manifest.php uses your company name and logo from Settings