-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
π SaaS ISP Platform β Merged Architecture
π Core Architecture Rules
- Framework: Laravel (PHP)
- Authentication: FreeRADIUS for AAA (Authentication, Authorization, Accounting)
- Network Integration: MikroTik routers via RouterOS API
- Database: Dual MySQL databases (application + FreeRADIUS)
- Multi-tenancy: All queries scoped by
tenant_id - Business Logic: Resides in
app/Services/ - Controllers: Handle only request/response, never core logic
π₯ Role Hierarchy (Standardized)
- Developer (Platform Owner)
- Super Admin (Platform Reseller)
- Admin (ISP Owner)
- Operator (Reseller)
- Sub-Operator
- Manager
- Staff
- Accountant
- Customer (Subscriber)
π§ Core Entities
- Customer β single source of truth for RADIUS/MikroTik status
- Invoice β automated billing
- Payment β gateway + manual
- ServicePackage β bandwidth, quota, validity
- RechargeCard β prepaid top-ups
- Commission β reseller/agent earnings
π Naming Conventions
- Admin = ISP Owner
- Operator = Reseller
- Customer = Subscriber
- Consistent terminology across UI, docs, and code
π Refactor Guidelines
- REST API cleanup β consolidate into
app/Services/ - Role hierarchy standardization β purge unused roles
- MikroTik/NAS integration β merge into
MikrotikService - Gateway logic β standardize via reusable service methods
- Documentation β update Markdown checklists + ERD diagrams
ποΈ Deprecation Rules
- Replace
network_usersβCustomer - Drop
network_user_idβ usecustomer_id - Remove legacy REST API endpoints
- Delete obsolete roles + DB fields (
legacy_status,old_role_id) - Do not remove existing features
- Views must follow:
- β
resources/views/panels/* - β No legacy paths (
resources/views/developer, etc.)
- β
π¨ Panel View Management
- Adding Views:
- Blade templates under
resources/views/panels/ - RBAC middleware for tenant + role checks
- Dynamic navigation menus
- Blade templates under
- Removing Views:
- Identify unused templates
- Remove routes/controllers
- Clean up navigation links
- Document in changelog
π Duplicate Check Rules
- Customers β unique email, phone, username
- Invoices β unique invoice numbers per tenant
- Payments β prevent duplicate transaction IDs
- Sessions β disallow multiple active sessions per
customer_id - Recharge Cards β unique card codes, prevent reuse
- Panel Views β avoid duplicate menu entries
β Implementation Checklist
- Refactor legacy REST API endpoints
- Merge MikroTik/NAS infrastructure
- Add tenant scoping to all queries
- Unit tests for
MikrotikService+OltService - Update invoice generation logic
- Remove deprecated roles + DB fields
- Purge unused Blade templates
- Replace
network_userswithCustomer - Add/remove panel views with RBAC enforcement
- Implement duplicate checks
π B2B2B Multi-Tenancy Model
- Developer (Platform Owner): sells SaaS subscriptions to Super Admins
- Super Admin (Platform Reseller): buys slots, resells to Admins (local ISPs)
- Admin (ISP Owner): buys slots, manages customers + infrastructure
1. Three-Level Database Hierarchy
| users | tenantsplatform_resellers | ispsbranches |
2. Parent Relationship (Migration Example)
Schema::table('users', function (Blueprint $table) {
$table->unsignedBigInteger('parent_id')->nullable(); // Who created this user?
$table->unsignedBigInteger('subscription_plan_id')->nullable();
$table->timestamp('expires_at')->nullable(); // For Super Admin subscriptions
});3. Subscription Logic (Middleware)
public function handle($request, $next)
{
$user = $request->user();
$superAdmin = ($user->role === 'Admin') ? User::find($user->parent_id) : $user;
if ($superAdmin->role === 'Super Admin' && now()->gt($superAdmin->expires_at)) {
return response()->view('errors.subscription_expired', [], 403);
}
return $next($request);
}4. Billing Logic (Developer Revenue)
- Super Admins purchase slots via bKash/Nagad/Stripe/PayPal
- Payment updates
expires_at+isp_limit - Admins cannot operate if parent Super Admin subscription expired
π₯οΈ Panel Requirements
- Developer Panel: reseller lifecycle, slot management, impersonation, analytics, audit trail
- Super Admin Panel: ISP management, subscription enforcement, BI tools
- Customer Portal: real-time visibility, billing, bandwidth turbo, support
π Migration Notes
- Check
GEMINI.mdfor architecture references - Ensure all new panels follow
resources/views/panels/*convention - Document every refactor in Markdown checklists + changelog
- Update ERD diagrams to reflect new hierarchy + entity relationships
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels