# Task 1 - AdminServer Component and Server API Routes

## Summary

Added AdminServer component and server API routes by adapting from the v0.0.8 project source.

## Files Created

1. **`/src/components/admin/AdminServer.tsx`** - Full server management UI component with 8 expandable sections:
   - Platform Server Status (CPU, Memory, Disk, Uptime, Versions, Traffic Estimator)
   - Application & Server Configuration
   - Storage Link Status
   - Cron Job (Scheduled Tasks)
   - Quick Maintenance (Clear Cache, Optimize DB, Refresh Stats)
   - Smart Deployment Troubleshooter (Diagnostics)
   - Platform Update Manager (Version info, Update instructions, ZIP upload/deploy)
   - System Warnings

2. **`/src/app/api/admin/server/route.ts`** - Server stats and maintenance API
   - GET: Returns system stats (CPU, memory, disk, uptime, versions, DB size, API routes, warnings)
   - POST: Maintenance actions (clear-cache, clear-uploads-temp, optimize-db, run-diagnostics, check-updates, deploy-update)
   - Uses `verifyAdminAuth` from `@/lib/auth`, super_admin required for POST

3. **`/src/app/api/admin/server/update/route.ts`** - Update deployment API
   - POST: Upload and deploy ZIP updates (backup, extract, copy with protected item exclusion, install deps, prisma generate, db push)
   - GET: Returns update instructions and project info
   - Uses `verifyAdminAuth`, super_admin required for POST

4. **`/src/app/api/admin/upload/route.ts`** - Image upload API
   - POST: Upload images (logo, favicon, etc.) to `public/uploads/` with type/size validation
   - DELETE: Remove uploaded files
   - Uses `verifyAdminAuth` for authentication

5. **`/src/components/DynamicFavicon.tsx`** - Client component that fetches admin settings on mount and dynamically updates favicon and page title

6. **`public/uploads/`** - Directory for uploaded files

## Files Modified

1. **`/src/app/api/admin/settings/route.ts`** - Added PATCH handler for individual key updates via upsert
2. **`/src/components/modules/AdminModule.tsx`** - Added Server tab:
   - Imported `AdminServer` and `ServerIcon`
   - Added server tab to tabs array (between Customizer and Settings)
   - Added `case 'server'` to renderContent switch
3. **`/src/app/layout.tsx`** - Added `DynamicFavicon` component inside Providers

## Key Adaptations from v0.0.8

- Uses `useAppStore` from `@/lib/store` (with `language`, `adminToken`, `adminUser` properties)
- Uses `x-admin-token` header for admin auth (matching existing project pattern)
- Uses `verifyAdminAuth` from `@/lib/auth` for API route authentication
- Uses `db` from `@/lib/db` (Prisma) for database operations
- DynamicFavicon uses a simple fetch-based approach instead of `useAppEnv` hook
