# Platform Admin Frontend Development Guide **Last Updated:** November 17, 2025 **Target Audience:** Frontend Developers **Backend Version:** SwiftOps v1.0 --- ## Table of Contents 1. [Overview](#overview) 2. [Authentication & Authorization](#authentication--authorization) 3. [Dashboard & Analytics](#dashboard--analytics) 4. [Organization Management](#organization-management) 5. [User Management](#user-management) 6. [System Monitoring](#system-monitoring) 7. [Audit Logs](#audit-logs) 8. [Complete API Reference](#complete-api-reference) 9. [UI/UX Recommendations](#uiux-recommendations) 10. [Error Handling](#error-handling) --- ## Overview ### What is a Platform Admin? **Platform Admin** is the highest-level administrative role with full system access. They manage: - **Organizations** (Clients & Contractors) - **Platform-wide settings** - **System health monitoring** - **Audit logs and compliance** - **Billing and usage metrics** (planned) **Key Responsibilities:** - Create and manage client organizations (telecom operators) - Create and manage contractor organizations (field service providers) - Monitor platform usage across all organizations - View comprehensive audit trails - Manage platform-wide configurations - Access all system data for oversight **Authorization Level:** ```javascript { role: "platform_admin", permissions: ["*"], // All permissions access_scope: "global" // Access to all organizations and projects } ``` --- ## Authentication & Authorization ### 1. Registration Flow Platform admins register through a secure 2-step OTP verification process. **Step 1: Request OTP** ```http POST /api/v1/auth/send-admin-otp Content-Type: application/json { "email": "admin@swiftops.com", "first_name": "John", "last_name": "Doe", "phone": "+254700123456" } ``` **Response:** ```json { "message": "✅ Registration request received! An OTP code has been sent to admin@swiftops.com..." } ``` **Step 2: Complete Registration** ```http POST /api/v1/auth/register Content-Type: application/json { "email": "admin@swiftops.com", "first_name": "John", "last_name": "Doe", "phone": "+254700123456", "password": "SecurePassword123!", "otp_code": "613281" } ``` **Response:** ```json { "message": "✅ Platform admin account created successfully!", "user_id": "uuid-here" } ``` ### 2. Login ```http POST /api/v1/auth/login Content-Type: application/json { "email": "admin@swiftops.com", "password": "SecurePassword123!" } ``` **Response:** ```json { "access_token": "eyJhbGciOiJIUzI1NiIs...", "token_type": "bearer", "user": { "id": "uuid", "email": "admin@swiftops.com", "first_name": "John", "last_name": "Doe", "role": "platform_admin", "is_active": true, "phone": "+254700123456" } } ``` ### 3. Authentication Headers All subsequent requests must include: ```http Authorization: Bearer eyJhbGciOiJIUzI1NiIs... ``` ### 4. Get Current User ```http GET /api/v1/auth/me Authorization: Bearer {token} ``` **Response:** ```json { "id": "uuid", "email": "admin@swiftops.com", "role": "platform_admin", "first_name": "John", "last_name": "Doe", "is_active": true, "created_at": "2025-11-17T10:00:00Z" } ``` --- ## Dashboard & Analytics ### Dashboard Overview Page The platform admin dashboard should display high-level metrics and system health. #### 1. System-Wide Statistics **Endpoint:** `GET /api/v1/tickets/stats` ```http GET /api/v1/tickets/stats Authorization: Bearer {token} ``` **Response:** ```json { "total_tickets": 1500, "by_status": { "open": 120, "assigned": 350, "in_progress": 280, "completed": 700, "cancelled": 50 }, "by_type": { "installation": 800, "support": 500, "infrastructure": 200 }, "by_priority": { "urgent": 45, "high": 200, "normal": 900, "low": 355 }, "overdue_tickets": 25, "sla_violations": 12, "avg_completion_time_hours": 18.5, "completion_rate": 0.87 } ``` **UI Component Suggestion:** ```jsx // Dashboard Overview Cards
``` #### 2. Organization Metrics **Clients Overview:** ```http GET /api/v1/clients?limit=100 Authorization: Bearer {token} ``` **Response:** ```json [ { "id": "uuid", "name": "Airtel Kenya", "industry": "Telecommunications", "is_active": true, "default_sla_days": 3, "created_at": "2025-01-01T00:00:00Z", "main_email": "contact@airtel.co.ke", "main_phone": "+254700000000" } ] ``` **Contractors Overview:** ```http GET /api/v1/contractors?limit=100 Authorization: Bearer {token} ``` **Response:** ```json [ { "id": "uuid", "name": "TechInstall Ltd", "competencies": ["FTTH", "Fixed Wireless", "Fiber Splicing"], "is_active": true, "onboarding_status": "completed", "created_at": "2025-01-15T00:00:00Z", "main_email": "info@techinstall.co.ke" } ] ``` **UI Component Suggestion:** ```jsx // Organizations Summary

Clients

{clients.length} Active
{clients.map(client => (

{client.name}

{client.industry}

))}

Contractors

{contractors.length} Active
{/* Similar list for contractors */}
``` #### 3. Active Projects ```http GET /api/v1/projects?is_active=true&limit=100 Authorization: Bearer {token} ``` **Response:** ```json [ { "id": "uuid", "title": "Nairobi FTTH Expansion", "client_id": "uuid", "contractor_id": "uuid", "client_name": "Airtel Kenya", "contractor_name": "TechInstall Ltd", "status": "active", "start_date": "2025-01-01", "end_date": "2025-12-31", "total_tickets": 500, "completed_tickets": 320 } ] ``` **UI Component Suggestion:** ```jsx // Active Projects Table ( )}, { key: "status", label: "Status" } ]} data={projects} /> ``` #### 4. Recent Activity Feed ```http GET /api/v1/audit-logs?limit=20 Authorization: Bearer {token} ``` **Response:** ```json [ { "id": "uuid", "action": "create", "entity_type": "client", "description": "Client organization created: Safaricom Ltd", "user_email": "admin@swiftops.com", "created_at": "2025-11-17T10:30:00Z", "ip_address": "192.168.1.1" } ] ``` --- ## Organization Management ### 1. Create Client Organization **Purpose:** Onboard new telecom operators or clients to the platform. **Endpoint:** ```http POST /api/v1/clients Authorization: Bearer {token} Content-Type: application/json { "name": "Safaricom Kenya", "description": "Leading telecommunications provider in Kenya", "industry": "Telecommunications", "main_email": "contact@safaricom.co.ke", "main_phone": "+254700000000", "website": "https://safaricom.co.ke", "default_sla_days": 3 } ``` **Response:** ```json { "id": "uuid", "name": "Safaricom Kenya", "description": "Leading telecommunications provider in Kenya", "industry": "Telecommunications", "main_email": "contact@safaricom.co.ke", "main_phone": "+254700000000", "website": "https://safaricom.co.ke", "is_active": true, "default_sla_days": 3, "created_at": "2025-11-17T10:00:00Z", "updated_at": "2025-11-17T10:00:00Z" } ``` **Validation Rules:** - `name`: Required, unique, 3-100 characters - `industry`: Optional, suggested values: "Telecommunications", "Utilities", "ISP", "Construction" - `main_email`: Required, unique, valid email format - `main_phone`: Optional, valid phone format - `default_sla_days`: Optional, integer 1-30, defaults to 3 **UI Form Fields:** ```jsx