# Phase 6: Admin Analytics Dashboard

## Technology Stack
- We integrated **Chart.js** via a highly available CDN directly into `layouts/admin.blade.php`. This allows global availability across any future admin analytical tools without adding bundling weight natively.

## Data Aggregation Engine
`AdminController@dashboard` acts as the computational entry point:
- **Stat Cards**: Leverages quick scalar counts via direct queries (e.g., `User::role('student')->count()`).
- **Time Series Parsing**: We dynamically map a 30-day lookback `Carbon` array.
- **Grouping**: To prevent the N+1 problem and heavy iterative overhead, we retrieve a singular payload of `payments` and `enrollments` bridging the last 30 days, parsing them once via `groupBy()` mapping directly to Carbon date-strings. The arrays are injected cleanly into Blade using `{!! json_encode(...) !!}`.

## Visual Implementation
`resources/views/admin/dashboard.blade.php` has been rebuilt.
- Implements 4 highly visual **Tailwind Stat Cards** with colored accent borders.
- Mounts two distinct HTML5 canvases.
- Dispatches a smooth **Revenue Line Chart** plotting PKR revenue against date axis with gradient fills.
- Dispatches a comparative **Enrollments Bar Chart** graphing daily registrations.

## Next Steps
Administrative insights are active. For **Phase 7: Bunny.net Video Integration**, we leave visual UI briefly to configure abstracted backend wrappers focusing strictly on secure API calls to Bunny CDN ensuring that video courses are thoroughly protected and tokenized.
