I've created a comprehensive admin panel for Zerlin with full CRUD capabilities for managing users, alerts, and oracle configuration.
/admin/page.tsx- Main admin dashboard/admin/users/page.tsx- User management/admin/alerts/page.tsx- Alert management/admin/oracle/page.tsx- Oracle configuration
AdminDashboard.tsx- System overview with stats and health monitoringUserManagement.tsx- User list with pagination and delete functionalityAlertManagement.tsx- Alert list with toggle and delete actionsOracleManagement.tsx- Oracle configuration formsindex.ts- Component exports
adminApi.ts- Admin API client with methods for:- System stats
- User CRUD operations
- Alert management
- Oracle configuration
- Health checks
admin.ts- TypeScript interfaces for:- SystemStats
- UserWithStats
- OracleStatus
- AlertWithUser
- HealthStatus
admin.module.ts- Admin module configurationadmin.controller.ts- REST API endpointsadmin.service.ts- Business logicdto/admin.dto.ts- Data transfer objects
GET /api/admin/stats - System statistics
GET /api/admin/users - List users (paginated)
GET /api/admin/users/:id - Get user by ID
DELETE /api/admin/users/:id - Delete user
GET /api/admin/alerts - List alerts (paginated)
PATCH /api/admin/alerts/:id/toggle - Toggle alert status
DELETE /api/admin/alerts/:id - Delete alert
GET /fee-oracle/status - Oracle status
POST /fee-oracle/update-rate - Update fee rate
POST /fee-oracle/authorize - Authorize oracle
POST /fee-oracle/revoke - Revoke oracle
docs/ADMIN_GUIDE.md- Comprehensive admin guidefrontend/src/app/admin/README.md- Quick reference
- Updated
Navigation.tsxto include Admin link
- System Statistics
- Total users, alerts, estimates
- Average response time
- Cache hit rate
- Service Health
- Database, Redis, Stacks node status
- Real-time monitoring
- Quick Actions
- Links to all admin sections
- Auto-refresh every 30 seconds
- Paginated user list (20 per page)
- User details:
- Stacks address (truncated display)
- Alert count
- Creation date
- Last activity
- Delete users (with confirmation)
- Cascading delete (removes user's alerts)
- Paginated alert list (50 per page)
- Alert details:
- User address
- Condition (ABOVE/BELOW)
- Target fee
- Active status
- Creation date
- Trigger count
- Toggle alert active/inactive
- Delete alerts (with confirmation)
- Visual indicators for status
- Current Status Display
- Fee rate (µSTX/byte)
- Last update time
- Owner address
- Initialization status
- Fee Rate Updates
- Set new fee rate
- Configure congestion level
- Oracle Authorization
- View authorized oracles
- Authorize new addresses
- Revoke permissions
- Atomic Design: Components organized as organisms
- State Management: React hooks (useState, useEffect)
- API Client: Centralized API calls
- Type Safety: Full TypeScript coverage
- Error Handling: Toast notifications
- Loading States: Spinners and disabled states
- Responsive Design: Tailwind CSS utilities
- Module Pattern: NestJS modules for organization
- Service Layer: Business logic separation
- Repository Pattern: TypeORM repositories
- DTO Validation: class-validator decorators
- API Documentation: Swagger/OpenAPI
- Error Handling: HTTP exceptions
- Consistent Styling: Matches existing Zerlin design
- Dark Theme: Cyberpunk aesthetic
- Responsive Tables: Horizontal scroll on mobile
- Pagination: Efficient data loading
- Confirmations: Destructive actions require confirmation
- Visual Feedback: Toast notifications for all actions
- Loading States: Clear loading indicators
- Empty States: Helpful messages when no data
- Truncated Addresses: Better readability
- Relative Timestamps: "2 hours ago" format
- Status Badges: Color-coded indicators
-
Authentication
- Implement JWT or session-based auth
- Protect all
/admin/*routes - Add login page
-
Authorization
- Create admin role system
- Implement RBAC (Role-Based Access Control)
- Verify permissions on each endpoint
-
Audit Logging
- Log all admin actions
- Track who, what, when
- Store in database
-
Rate Limiting
- Prevent abuse
- Throttle requests
-
Input Validation
- Sanitize all inputs
- Prevent injection attacks
-
CORS Configuration
- Restrict origins in production
- Configure properly for admin routes
- Stats load correctly
- Health status displays
- Quick actions work
- Auto-refresh works
- User list loads
- Pagination works
- Delete user works
- Confirmation dialog shows
- Alert list loads
- Toggle status works
- Delete alert works
- Pagination works
- Status loads
- Fee rate update works
- Authorize oracle works
- Revoke oracle works
# Backend tests
cd backend
npm run test
# Frontend build
cd frontend
npm run build- Authentication & authorization
- Audit logging
- Search and filtering
- Bulk operations
- Advanced analytics
- Export data (CSV, JSON)
- Real-time updates (WebSocket)
- Activity timeline
- User impersonation (support)
- System configuration UI
- Database backup/restore
- Email notifications
frontend/
├── src/
│ ├── app/
│ │ └── admin/
│ │ ├── page.tsx # Dashboard
│ │ ├── users/page.tsx # User management
│ │ ├── alerts/page.tsx # Alert management
│ │ ├── oracle/page.tsx # Oracle config
│ │ └── README.md
│ ├── components/
│ │ └── organisms/
│ │ └── admin/
│ │ ├── AdminDashboard.tsx
│ │ ├── UserManagement.tsx
│ │ ├── AlertManagement.tsx
│ │ ├── OracleManagement.tsx
│ │ └── index.ts
│ ├── lib/
│ │ └── adminApi.ts # API client
│ └── types/
│ └── admin.ts # TypeScript types
backend/
├── src/
│ ├── admin/
│ │ ├── admin.module.ts
│ │ ├── admin.controller.ts
│ │ ├── admin.service.ts
│ │ └── dto/
│ │ └── admin.dto.ts
│ └── contracts/
│ └── fee-oracle/
│ └── fee-oracle-status.controller.ts
docs/
└── ADMIN_GUIDE.md # Comprehensive guide
# Start backend
cd backend
npm run start:dev
# Start frontend
cd frontend
npm run devhttp://localhost:3001/admin
- Dashboard:
/admin - Users:
/admin/users - Alerts:
/admin/alerts - Oracle:
/admin/oracle
The admin panel is fully integrated with:
- Existing database schema (User, Alert entities)
- TypeORM repositories
- Redis caching
- Stacks blockchain integration
- Existing API structure
- Navigation component
- All components use existing design system
- Follows project's coding standards
- Maintains consistency with existing pages
- Reuses existing utilities and hooks
- Compatible with current architecture
For questions or issues:
- Check
docs/ADMIN_GUIDE.md - Review component code
- Check API documentation at
/api(Swagger) - Review TypeScript types for data structures