Admin & Control Panel
Relevant source files
The following files were used as context for generating this wiki page:
- app/Providers/Filament/AdminPanelProvider.php
- app/Filament/Pages/Dashboard.php
- app/Filament/Resources/UserResource.php
- app/Filament/Resources/TagResource.php
- tests/Feature/Admin/FilamentDashboardTest.php
- tests/Feature/Filament/ModerationDashboardTest.php
- app/Filament/Pages/ProjectSettingsPage.php
- resources/views/filament/pages/dashboard.blade.php
- resources/views/filament/pages/project-settings.blade.php
The Admin & Control Panel in RateGuru is built using the Filament PHP framework, providing a centralized interface for moderators and administrators to manage content, users, and platform-wide configurations. It operates as a separate panel from the main application shell, utilizing its own CSS bundle and distinct design considerations to accommodate complex administrative workflows.
Sources: app/Providers/Filament/AdminPanelProvider.php, resources/views/filament/pages/dashboard.blade.php:3-6
Access Control and Authentication
Access to the admin panel is restricted to users with elevated roles, specifically admin and moderator. Normal users are explicitly denied access via a 403 Forbidden response. Authentication is handled through a standard login flow, and unauthorized guests are redirected to the Filament login route.
User Authorization Flow
The following diagram illustrates the permission check conducted when a user attempts to access the /admin path.
Moderation Dashboard
The primary landing page for administrative users is the Moderation Dashboard. This dashboard is designed to provide high-level metrics on content status and user behavior that require attention.
Dashboard Widgets
The dashboard uses a four-column horizontal layout for header widgets to provide an immediate summary of moderation needs.
| Widget | Purpose | Metrics Displayed |
|---|---|---|
PendingPostsWidget | Tracks content awaiting initial approval. | Count of posts with pending status. |
ReportedPostsWidget | Monitors community-reported content. | Count of published posts with reports_count > 0. |
ReportedCommentsWidget | Monitors community-reported comments. | Count of comments with reports. |
SuspiciousUsersWidget | Highlights potentially problematic accounts. | Combined count of shadowbanned users and authors of reported content. |
Sources: tests/Feature/Admin/FilamentDashboardTest.php:48-55, tests/Feature/Filament/ModerationDashboardTest.php:54-106
Resource Management
The panel organizes data management into specific Resources, each corresponding to an underlying Eloquent model.
User Management (UserResource)
Administrators (but not moderators) have full CRUD access to user accounts. This includes editing identity details, resetting passwords, and adjusting trust_level or status.
- Listing: Searchable and sortable table including columns for username, email, status badge, role badge, and post counts.
- Editing: Allows modification of email, name, role, and status (e.g., Active, Limited, Banned).
- Security: Username uniqueness is validated during edits.
Sources: app/Filament/Resources/UserResource.php, tests/Feature/Filament/UserResourceTest.php:23-53, 107-152
Tag Management (TagResource)
Both admins and moderators can manage platform tags used for content categorization.
- Fields: The resource manages Tag names and slugs.
- Metrics: Displays
posts_countderived from the tag's relationship to posts.
Sources: app/Filament/Resources/TagResource.php, tests/Feature/Filament/TagResourceTest.php:30-85
Project Settings
The ProjectSettingsPage allows administrators to configure global site variables without changing code. To ensure UI consistency, this page utilizes a custom "preset" system.
Configuration Presets
Administrators can apply predefined configurations to quickly toggle platform identities (e.g., "Food", "General"). Applying a preset updates multiple fields such as site_name, object_singular_name, and upload_cta_label.
// Example of preset options available in the UI
foreach(\App\Filament\Pages\ProjectSettingsPage::presetOptions() as $key => $label) {
// Renders as action buttons in project-settings.blade.php
}
Sources: resources/views/filament/pages/project-settings.blade.php:67-79, tests/Feature/Filament/ProjectSettingsValidationTest.php:7-25
Validation Rules
Configuration fields are strictly validated to prevent platform instability:
- Required: Site name, object singular name, and upload CTA label.
- Enums:
default_themeanddefault_sortmust match allowed application values.
Sources: tests/Feature/Filament/ProjectSettingsValidationTest.php:7-45
Technical Implementation Details
Design Token Deviation
A critical architectural decision in RateGuru is that the Filament admin panel does not load the main application's --rg-* design tokens. Filament uses its own pre-compiled CSS bundle. This prevents the admin panel from being affected by experimental UI changes in the main frontend.
Custom Styling in Admin
Because the admin panel is outside the main Vite/Tailwind build, custom views like ProjectSettingsPage use scoped <style> tags with literal hex values for both light and dark modes.
| Mode | Border Color | Background Color | Title Color |
|---|---|---|---|
| Light | #fde68a | #fffbeb | #92400e |
| Dark | #92400e | #451a03 | #fde68a |
Sources: resources/views/filament/pages/project-settings.blade.php:12-40, resources/views/filament/pages/dashboard.blade.php:3-5
Conclusion
The Admin & Control Panel serves as the operational backbone of RateGuru. By leveraging Filament, it provides a robust, type-safe environment for data management while maintaining a strict separation between the public-facing product design and the utility-focused administrative tools.