Admin Control Panel - Design Document
Overview
This document describes the admin control panel implementation for FishingLog. The panel is designed with a user-centric approach, focusing on what admins need to accomplish rather than technical database operations.
Difficulty Assessment: MODERATE ✅
Why It's Moderate (Not Hard):
-
Existing Infrastructure Helps:
- ✅ Hybrid enum/lookup system already supports dynamic enum extensions
- ✅ Authorization helpers (
AuthorizationHelper.IsAdminAsync()) exist - ✅ Clean entity structure with well-defined relationships
- ✅ Existing controller patterns to follow
-
What Makes It Moderate:
- Need to create multiple controllers for different entity types
- Need to implement proper authorization checks
- Need to design user-friendly APIs (not just CRUD)
- Need to handle edge cases (e.g., preventing deletion of last admin)
-
What Makes It Easier:
- LookupTable system means enum management is already database-driven
- No need to modify enums in code - just add to lookup tables
- Existing patterns for pagination, filtering, etc.
Architecture
Authorization
AdminOnlyAttribute - Custom authorization attribute that:
- Checks if user has
UserRole.Admin - Returns
ForbidResultif not admin - Can be applied to controllers or individual endpoints
[AdminOnly]
public class AdminBrandController : ControllerBase
{
// All endpoints require admin role
}
Controllers Created
1. AdminLookupController (/api/admin/lookups)
Manages lookup table values (enum extensions).
User-Centric Features:
- Get all categories (e.g., "RodMaterial", "KnotCategory")
- Get/Add/Update/Delete lookup values
- Reorder lookup values (drag-and-drop support)
- Prevents deletion of system-defined values
Key Endpoints:
GET /api/admin/lookups/categories- List all lookup categoriesGET /api/admin/lookups/category/{category}- Get all values for a categoryPOST /api/admin/lookups- Add new lookup valuePUT /api/admin/lookups/{id}- Update lookup valueDELETE /api/admin/lookups/{id}- Delete lookup value (soft delete)POST /api/admin/lookups/reorder- Reorder values
2. AdminBrandController (/api/admin/brands)
Manages brands (gear manufacturers).
User-Centric Features:
- Full CRUD operations
- Record brand acquisitions (when one brand buys another)
- Soft delete (deactivate) instead of hard delete
- Prevents deletion of brands in use
Key Endpoints:
GET /api/admin/brands- List brands with pagination/filteringGET /api/admin/brands/{id}- Get specific brandPOST /api/admin/brands- Create brandPUT /api/admin/brands/{id}- Update brandPOST /api/admin/brands/{acquirerId}/acquire/{acquiredId}- Record acquisitionDELETE /api/admin/brands/{id}- Delete brand (soft delete)
3. AdminUserController (/api/admin/users)
Manages users and their roles.
User-Centric Features:
- View users with filtering (role, subscription tier, search)
- Update user roles (e.g., "Make this user an admin")
- Update subscription tiers
- View user activity statistics
- Deactivate users
- Prevents removing the last admin
Key Endpoints:
GET /api/admin/users- List users with pagination/filteringGET /api/admin/users/{id}- Get specific userPUT /api/admin/users/{id}/role- Update user rolePUT /api/admin/users/{id}/subscription- Update subscription tierGET /api/admin/users/{id}/activity- Get user activity statsPOST /api/admin/users/{id}/deactivate- Deactivate user
4. AdminFishSpeciesController (/api/admin/fish-species)
Manages fish species data.
User-Centric Features:
- Full CRUD operations
- Taxonomic classification support
- View usage statistics (how many catches reference this species)
- Get taxonomic ranks for dropdowns
Key Endpoints:
GET /api/admin/fish-species- List species with pagination/filteringGET /api/admin/fish-species/{id}- Get specific speciesPOST /api/admin/fish-species- Create speciesPUT /api/admin/fish-species/{id}- Update speciesGET /api/admin/fish-species/taxonomic-ranks- Get taxonomic ranksGET /api/admin/fish-species/{id}/usage- Get usage statistics
5. AdminDashboardController (/api/admin/dashboard)
Provides overview statistics and insights.
User-Centric Features:
- System health overview
- User growth metrics
- Content statistics
- Recent activity feed
Key Endpoints:
GET /api/admin/dashboard/overview- Get dashboard statisticsGET /api/admin/dashboard/recent-activity- Get recent activity
User-Centric Design Principles
1. Task-Oriented Endpoints
Instead of generic CRUD, endpoints are named for what admins want to do:
- ❌
PUT /api/admin/users/{id}(generic update) - ✅
PUT /api/admin/users/{id}/role(specific task: change role)
2. Helpful Error Messages
- "Cannot delete brand that is in use. Deactivate it instead."
- "Cannot remove the last admin user"
- "A brand with name 'X' already exists"
3. Soft Deletes
- Brands, lookups, etc. are deactivated rather than deleted
- Preserves data integrity
- Allows recovery if needed
4. Usage Statistics
- Shows how entities are being used
- Helps admins make informed decisions
- Example: "This species has 1,234 catches"
5. Pagination & Filtering
- All list endpoints support pagination
- Filtering by common criteria (role, status, etc.)
- Search functionality
What's Easy to Extend
Adding New Entity Management
To add admin management for a new entity (e.g., BoatManufacturer):
- Create Admin Controller:
[ApiController]
[Route("api/admin/boat-manufacturers")]
[AdminOnly]
public class AdminBoatManufacturerController : ControllerBase
{
// Follow same patterns as AdminBrandController
}
- Add Endpoints:
GET- List with pagination/filteringGET /{id}- Get specific itemPOST- CreatePUT /{id}- UpdateDELETE /{id}- Soft delete
- Add to Dashboard:
- Update
AdminDashboardControllerto include stats for new entity
Adding New Admin Features
- Bulk Operations: Add endpoints like
POST /api/admin/brands/bulk-deactivate - Import/Export: Add endpoints for CSV/JSON import/export
- Audit Logging: Track all admin actions
- Approval Workflows: For user-defined content that needs approval
Security Considerations
- Authorization: All endpoints require
AdminOnlyattribute - Validation: Input validation on all create/update operations
- Prevent Data Loss: Soft deletes, prevent deletion of critical data
- Audit Trail: Consider adding audit logging for admin actions
Frontend Integration
The API is designed to work with a frontend admin panel. Example frontend structure:
/admin
/dashboard - Overview statistics
/users - User management
/brands - Brand management
/fish-species - Species management
/lookups - Enum/lookup management
6. AdminRegulationController (/api/admin/regulations)
Manages state regulations, zones, and fishing rules.
User-Centric Features:
- Manage states and their DNR information
- Create/update fishing zones with boundaries
- Create/update regulations (bag limits, size limits, seasons)
- Mark regulations as verified/updated
- Track regulation sources and verification dates
Key Endpoints:
GET /api/admin/regulations/states- List all statesGET /api/admin/regulations/states/{id}- Get state with zones/regulationsPOST /api/admin/regulations/states- Create/update stateGET /api/admin/regulations/states/{stateId}/zones- Get zones for statePOST /api/admin/regulations/zones- Create/update zoneGET /api/admin/regulations/regulations- List regulations with filteringPOST /api/admin/regulations/regulations- Create/update regulationPOST /api/admin/regulations/states/{id}/mark-verified- Mark regulations verified
7. AdminTournamentController (/api/admin/tournaments)
Manages tournament approvals, especially for money-involved tournaments.
User-Centric Features:
- Approve/reject tournaments (critical for paid tournaments)
- Monitor high-value tournaments (fraud prevention)
- View financial summaries
- Suspend tournaments for violations
- Get tournaments needing attention
Key Endpoints:
GET /api/admin/tournaments/pending-approval- Get tournaments pending approvalGET /api/admin/tournaments/{id}- Get tournament detailsPOST /api/admin/tournaments/{id}/approve- Approve tournamentPOST /api/admin/tournaments/{id}/reject- Reject tournamentPOST /api/admin/tournaments/{id}/suspend- Suspend tournamentGET /api/admin/tournaments/high-value- Get high-value tournamentsGET /api/admin/tournaments/{id}/financial-summary- Get financial summaryGET /api/admin/tournaments/needs-attention- Get tournaments needing review
8. AdminTournamentOrganizerController (/api/admin/tournament-organizers)
Manages tournament organizer verification (critical for money handling).
User-Centric Features:
- Review organizer applications
- Verify organizers (check documents, identity, Stripe account)
- Set limits (max tournaments, max entry fees)
- Suspend organizers for violations
- View organizer statistics
Key Endpoints:
GET /api/admin/tournament-organizers/pending- Get pending verificationsGET /api/admin/tournament-organizers- List organizers with filteringGET /api/admin/tournament-organizers/{id}- Get organizer detailsPOST /api/admin/tournament-organizers/{id}/verify- Verify organizerPOST /api/admin/tournament-organizers/{id}/reject- Reject organizerPOST /api/admin/tournament-organizers/{id}/suspend- Suspend organizerGET /api/admin/tournament-organizers/{id}/statistics- Get organizer stats
9. AdminEventController (/api/admin/events)
Manages event approvals (expos, swap meets, etc.).
User-Centric Features:
- Approve/reject events
- Feature events (show prominently)
- Monitor paid events
- Get events needing attention
Key Endpoints:
GET /api/admin/events/pending- Get pending eventsGET /api/admin/events/{id}- Get event detailsPOST /api/admin/events/{id}/approve- Approve eventPOST /api/admin/events/{id}/reject- Reject eventPOST /api/admin/events/{id}/feature- Feature eventPOST /api/admin/events/{id}/unfeature- Unfeature eventGET /api/admin/events/needs-attention- Get events needing review
10. AdminModerationController (/api/admin/moderation)
AI-assisted moderation with admin review and override.
User-Centric Features:
- Review AI-flagged content
- Approve/reject flagged content (override AI decisions)
- View moderation statistics
- Monitor AI accuracy metrics
- Train/improve AI models (via logging)
Key Endpoints:
GET /api/admin/moderation/flagged- Get flagged contentPOST /api/admin/moderation/{contentType}/{id}/approve- Approve flagged contentPOST /api/admin/moderation/{contentType}/{id}/reject- Reject flagged contentGET /api/admin/moderation/statistics- Get moderation statsGET /api/admin/moderation/ai-metrics- Get AI accuracy metrics
11. AdminUserBanController (/api/admin/user-bans)
User ban management for violations (harassment, inappropriate content, etc.).
User-Centric Features:
- Ban users (temporary or permanent)
- Track ban reasons (harassment, inappropriate content, spam, etc.)
- Manage ban appeals
- View ban history
- Check if user is banned
- Ban statistics
Key Endpoints:
GET /api/admin/user-bans/active- Get all active bansGET /api/admin/user-bans- List bans with filtering/paginationGET /api/admin/user-bans/{id}- Get specific ban detailsGET /api/admin/user-bans/user/{userId}- Get user's ban historyPOST /api/admin/user-bans- Ban a userPOST /api/admin/user-bans/{id}/lift- Unban a userGET /api/admin/user-bans/appeals/pending- Get pending appealsPOST /api/admin/user-bans/{id}/appeal/review- Review ban appealGET /api/admin/user-bans/statistics- Get ban statisticsGET /api/admin/user-bans/user/{userId}/is-banned- Check if user is banned
Security & Compliance Features
Money-Involved Operations
Tournament Approvals:
- ✅ Verify organizer before approving paid tournaments
- ✅ Check Stripe account verification
- ✅ Monitor high-value tournaments
- ✅ Financial summaries for transparency
- ✅ Suspend organizers/tournaments for violations
Event Approvals:
- ✅ Verify organizer for paid events
- ✅ Monitor admission fees
- ✅ Track event attendance
Regulation Management
- ✅ Track regulation sources (URLs, APIs)
- ✅ Mark regulations as verified
- ✅ Track last update dates
- ✅ Manage regulation years
- ✅ Support multiple seasons per regulation
AI Moderation
- ✅ Admin can override AI decisions
- ✅ Track AI accuracy metrics
- ✅ Log moderation actions for training
- ✅ Review flagged content before action
- ✅ Monitor false positives/negatives
User Ban System
- ✅ Temporary and permanent bans
- ✅ Multiple ban reasons (harassment, inappropriate content, spam, etc.)
- ✅ Ban appeals with review workflow
- ✅ Ban history tracking
- ✅ Link bans to specific content violations
- ✅ Prevent banning last admin
- ✅ Ban statistics and reporting
Next Steps
-
Add More Entity Controllers:
AdminBoatManufacturerControllerAdminGearController(for Rods, Reels, Lures, Lines)AdminMasterAnglerController(for Master Angler submissions)
-
Add Advanced Features:
- Bulk operations
- Import/Export (CSV/JSON)
- Audit logging (track all admin actions)
- Email notifications for approvals/rejections
- AI integration hooks (for moderation)
-
Add Frontend:
- React/Vue admin panel
- Use the APIs created here
- User-friendly UI matching the user-centric API design
- Dashboard with key metrics
- Approval workflows with notifications
Summary
Creating an admin panel is moderate difficulty because:
- ✅ Existing infrastructure (lookup tables, authorization) helps significantly
- ✅ Clear patterns to follow
- ✅ Well-defined entities make CRUD straightforward
- ⚠️ Need to create multiple controllers
- ⚠️ Need to handle edge cases and validation
- ⚠️ Need to design user-friendly APIs
- ⚠️ Need to implement security checks for money-involved operations
The foundation is now in place with comprehensive coverage for:
- ✅ Reference data management (brands, species, lookups)
- ✅ User management
- ✅ User bans and suspensions
- ✅ Regulation management
- ✅ Tournament approvals (especially money-involved)
- ✅ Event approvals
- ✅ AI-assisted moderation
- ✅ Role hierarchy (Owner > Admin > Moderator)
- ✅ Granular permissions for employees
- ✅ Employee management (assign roles/permissions)
- ✅ Audit logging (track all admin actions)
- ✅ System settings (site-wide configuration)
- ✅ Site announcements (banners/notifications)
Adding new entity management is straightforward by following the established patterns.
Owner vs Admin vs Employee
Owner (You - Site Owner)
- Full access to everything
- Can manage system settings
- Can manage employees and permissions
- Cannot be demoted or banned
- Use
[OwnerOnly]attribute for owner-only endpoints
Admin (Your Employees)
- Can manage users, content, tournaments, events
- Can ban users
- Cannot modify system settings (unless granted permission)
- Cannot manage other admins' permissions
- Has permissions by default (unless explicitly denied)
- Use
[AdminOnly]attribute for admin endpoints
Moderator (Content Moderators)
- Can moderate content
- Cannot ban users or manage system
- Needs explicit permissions granted
- Use
[RequirePermission]attribute for specific permissions
See ADMIN_DOCUMENTATION.md for complete admin panel documentation.
Future Enhancements
High Priority:
- Bulk operations (bulk approve/reject)
- GDPR compliance (data export/deletion)
- Stripe refund integration (actual API calls)
Medium Priority:
- Email template management
- Error logging & monitoring
- API key management
- User-facing activity timeline
Low Priority:
- Support ticket system
- Backup & restore
- Database health monitoring
AI Moderation System ✅
Status: Fully Implemented
A complete AI-powered content moderation system that:
- ✅ Checks posts/comments before publishing
- ✅ Extensible provider system (add new AI providers without code changes)
- ✅ Admin-configurable settings
- ✅ Pre-moderation workflow (hold pending review)
- ✅ Review queue for admins
- ✅ Cost tracking and statistics
- ✅ OpenAI integration (ready to use)
- ✅ Placeholder for AWS Comprehend (easy to implement)
See AI_MODERATION_SETUP.md for complete setup and usage guide.