libra/docs/epics/epic-6-admin-dashboard.md

8.4 KiB

Epic 6: Admin Dashboard

Epic Goal

Create a comprehensive admin dashboard providing centralized control, statistics, analytics, data exports, and system configuration for the law firm's operations.

Epic Description

Business Context

The lawyer needs a central control panel to manage all aspects of the platform efficiently. This includes real-time metrics, quick actions, data visualization, export capabilities, and system settings.

Technical Context

  • Charts: Chart.js for visualizations
  • Exports: CSV and PDF formats
  • Real-time: Live metrics updates
  • PDF: barryvdh/laravel-dompdf
  • CSV: league/csv

Success Criteria

  • Overview dashboard with key metrics
  • Charts for trends and analytics
  • Quick access to pending actions
  • Data export (CSV, PDF)
  • System settings management
  • Legal pages editor (Terms, Privacy)
  • Audit log visibility
  • Responsive design for tablet use

Stories

Story 6.1: Dashboard Overview & Statistics

Description: Main dashboard page with real-time metrics and key performance indicators.

Acceptance Criteria:

  • User Metrics Card:
    • Total active clients
    • Individual vs company breakdown
    • Deactivated clients count
    • New clients this month
  • Booking Metrics Card:
    • Pending requests count (highlighted)
    • Today's consultations
    • This week's consultations
    • This month's consultations
    • Total consultations (all time)
    • Free vs paid breakdown
    • No-show rate percentage
  • Timeline Metrics Card:
    • Active case timelines
    • Archived timelines
    • Updates added this week
  • Posts Metrics Card:
    • Total published posts
    • Posts published this month
  • Clean card-based layout
  • Color-coded status indicators
  • Quick stats at a glance

Technical Notes:

  • Use Livewire for real-time updates
  • Cache expensive queries with short TTL
  • Responsive grid layout

Story 6.2: Analytics Charts

Description: Visual charts showing trends and historical data.

Acceptance Criteria:

  • Monthly Trends Chart (Line):
    • New clients per month
    • Consultations per month
  • Consultation Breakdown (Pie/Donut):
    • Free vs paid ratio
  • No-show Rate (Line):
    • Monthly no-show trend
  • Date range selector:
    • Last 6 months
    • Last 12 months
    • Custom range
  • Chart tooltips with exact values
  • Responsive charts (resize with viewport)
  • Bilingual labels

Technical Notes:

  • Use Chart.js
  • Data aggregated server-side
  • Lazy load chart data

Story 6.3: Quick Actions Panel

Description: Quick access to pending items requiring admin attention.

Acceptance Criteria:

  • Pending Bookings:
    • Count badge with urgent indicator
    • Link to booking management
    • Mini list of recent pending
  • Today's Schedule:
    • List of today's consultations
    • Time and client name
    • Quick status update buttons
  • Recent Timeline Updates:
    • Last 5 updates made
    • Quick link to timeline
  • Notification bell with pending count
  • One-click access to common tasks:
    • Create user
    • Create post
    • Block time slot

Technical Notes:

  • Dashboard widgets pattern
  • Real-time updates via Livewire polling

Story 6.4: Data Export - User Lists

Description: Export user data in CSV and PDF formats.

Acceptance Criteria:

  • Export all users
  • Export individual clients only
  • Export company clients only
  • Filter options:
    • Date range (created)
    • Status (active/deactivated)
  • CSV export includes:
    • Name, email, phone
    • User type
    • National ID / Company reg
    • Status
    • Created date
  • PDF export includes:
    • Same data with professional formatting
    • Libra branding header
    • Generation timestamp
  • Download directly to device
  • Bilingual column headers (based on admin language)

Technical Notes:

  • Use league/csv for CSV
  • Use barryvdh/laravel-dompdf for PDF
  • Chunked processing for large datasets

Story 6.5: Data Export - Consultation Records

Description: Export consultation/booking data.

Acceptance Criteria:

  • Export all consultations
  • Filter options:
    • Date range
    • Consultation type (free/paid)
    • Status (approved/completed/no-show/cancelled)
    • Payment status
  • Export includes:
    • Client name
    • Date and time
    • Consultation type
    • Status
    • Payment status
    • Problem summary
  • CSV and PDF formats
  • Professional PDF layout with branding

Technical Notes:

  • Similar pattern to user exports
  • Handle large problem summaries in PDF

Story 6.6: Data Export - Timeline Reports

Description: Export timeline and case data.

Acceptance Criteria:

  • Export all timelines (across all clients)
  • Export timelines for specific client
  • Filter options:
    • Status (active/archived)
    • Date range
  • Export includes:
    • Case name and reference
    • Client name
    • Status
    • Created date
    • Number of updates
    • Last update date
  • CSV and PDF formats

Technical Notes:

  • Option to include update content or summary only

Story 6.7: Monthly Statistics Report

Description: Generate comprehensive monthly PDF report.

Acceptance Criteria:

  • "Generate Monthly Report" button
  • Select month/year
  • PDF report includes:
    • Overview of key metrics
    • Charts (rendered as images)
    • User statistics
    • Consultation statistics
    • Timeline statistics
    • Post statistics
  • Professional layout with branding
  • Table of contents
  • Printable format
  • Bilingual based on admin preference

Technical Notes:

  • Complex PDF generation
  • Pre-render charts as base64 images
  • Longer generation time (loading indicator)

Story 6.8: System Settings

Description: Configure system-wide settings.

Acceptance Criteria:

  • Profile Settings:
    • Admin name
    • Email
    • Password change
    • Preferred language
  • Email Settings:
    • View current sender email
    • Test email functionality
  • Notification Preferences:
    • Toggle admin notifications
    • Summary email frequency
  • Settings saved and applied immediately
  • Validation for all inputs

Technical Notes:

  • Settings can be stored in config or database
  • Some settings may require .env changes (display only)

Story 6.9: Legal Pages Editor

Description: Admin-editable Terms of Service and Privacy Policy pages.

Acceptance Criteria:

  • Edit Terms of Service:
    • Rich text editor
    • Bilingual content (Arabic/English)
    • Save and publish
  • Edit Privacy Policy:
    • Rich text editor
    • Bilingual content
    • Save and publish
  • Pages accessible from footer (public)
  • Last updated timestamp displayed
  • Preview before publishing

Technical Notes:

  • Store in database (settings table or pages table)
  • Public routes for viewing
  • No versioning required (simple overwrite)

Story 6.10: Audit Log Viewer

Description: View admin action history for accountability.

Acceptance Criteria:

  • List admin actions from admin_logs table
  • Display:
    • Action type (create, update, delete)
    • Target (user, consultation, timeline, etc.)
    • Old and new values (for updates)
    • Timestamp
    • IP address
  • Filter by:
    • Action type
    • Target type
    • Date range
  • Search by target name/ID
  • Pagination
  • Export audit log (CSV)

Technical Notes:

  • admin_logs table from Epic 1
  • Read-only view
  • Consider retention policy (future)

Dependencies

Epic Dependency
Epic 1 Base UI, authentication, database
Epic 2 User data for metrics
Epic 3 Booking data for metrics
Epic 4 Timeline data for metrics
Epic 5 Posts data for metrics

Risks & Mitigations

Risk Impact Mitigation
Large export performance Medium Chunked processing, background jobs
PDF generation memory Medium Limit data per report, optimize
Real-time metric performance Low Cache with short TTL, efficient queries

Definition of Done

  • All stories completed with acceptance criteria met
  • Metrics display accurately
  • Charts render correctly
  • Exports generate valid files
  • PDF branding correct
  • Settings save and apply
  • Legal pages editable and public
  • Audit log queryable
  • Responsive on tablet
  • Code formatted with Pint