Admin Panel (ui-web-admin)
Table of Contents
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Dependency Analysis
- Performance Considerations
- Troubleshooting Guide
- Conclusion
- Appendices
Introduction
This document describes the Admin Panel (ui-web-admin), a system administration interface built with Next.js 16 App Router. It covers the application’s architecture, component hierarchy, routing patterns, and administrative capabilities including user administration, tenant management, role-based access control, system configuration, and CMS content management. It also documents API integration patterns, authentication and authorization flows, security considerations, responsive design and accessibility, and practical workflows for common administrative tasks.
Project Structure
The Admin Panel follows Next.js 16 conventions with App Router. Key areas:
- Application shell and global styles under src/app
- Feature pages grouped by functional domain (dashboard, system, tenants, cms)
- Shared libraries for API, request handling, and CMS integration
- Environment-aware configuration and routing rewrites
Diagram sources
- [src/app/layout.tsx]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L1-L205)
- [src/app/login/page.tsx]
- [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L1-L113)
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L1-L234)
- [src/app/(dashboard)/cms/news/page.tsx]/cms/news/page.tsx#L1-L153)
- [src/lib/request.ts]
- [src/lib/api.ts]
- [src/lib/plasmic.ts]
- [src/config/env.ts]
- [next.config.ts]
Section sources
- [package.json]
- [next.config.ts]
- [src/config/env.ts]
- [src/app/layout.tsx]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L1-L205)
Core Components
- Authentication and session management via local storage and Bearer tokens
- Centralized request layer with unified error handling and 401 redirection
- Feature-specific API modules for system management, tenant management, and CMS
- Theme persistence and Arco Design integration
- Environment-driven routing rewrites to backend services or gateway
Key implementation references:
- Token handling and redirects on 401: [src/lib/request.ts]
- API surface for system and tenant operations: [src/lib/api.ts]
- Environment and gateway rewrites: [src/config/env.ts], [next.config.ts]
- Theme persistence and Arco compat: [src/app/layout.tsx], [src/components/ArcoCompat.tsx]
Section sources
Architecture Overview
The Admin Panel uses a layered architecture:
- Presentation layer: Next.js App Router pages and shared components
- Domain services: Feature-specific API modules (users, tenants, system, CMS)
- Infrastructure: Unified request layer with environment-aware routing
- Security: JWT-based Bearer tokens stored in browser local storage
Diagram sources
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L28-L74)
- [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L19-L36)
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L24-L60)
- [src/app/(dashboard)/cms/news/page.tsx]/cms/news/page.tsx#L17-L31)
- [src/lib/api.ts]
- [src/lib/request.ts]
- [src/config/env.ts]
- [next.config.ts]
Detailed Component Analysis
Authentication and Authorization Flow
- Login page posts credentials to the auth service and stores the Bearer token in local storage
- Dashboard layout fetches user info on mount and guards routes by checking token presence
- Request layer automatically attaches Authorization header and handles 401 by clearing token and redirecting to login
- Logout triggers backend logout and clears token
Diagram sources
- [src/app/login/page.tsx]
- [src/lib/api.ts]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L37-L54)
- [src/lib/request.ts]
Section sources
- [src/app/login/page.tsx]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L37-L93)
- [src/lib/request.ts]
- [src/lib/api.ts]
System Management: User Administration
- Lists users with pagination and filters
- CRUD operations with modal forms
- Password reset and status toggling
- Integrates with departments and roles for assignment
Diagram sources
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L24-L116)
- [src/lib/api.ts]
Section sources
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L1-L234)
- [src/lib/api.ts]
System Monitoring and Dashboard
- Loads summary statistics from tenant-m service via dashboardApi
- Renders KPI cards and customer status distribution
- Gracefully handles missing endpoints with fallback values
Diagram sources
- [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L27-L36)
- [src/lib/api.ts]
- [src/lib/request.ts]
- [next.config.ts]
Section sources
- [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L1-L113)
- [src/lib/api.ts]
CMS Management: News
- Integrates with Plasmic CMS via bi-sys configuration keys
- Queries, creates, updates, and deletes news entries
- Supports localized content and translation status tagging
- Uses an API Route proxy to avoid CORS and enforce auth
Diagram sources
- [src/app/(dashboard)/cms/news/page.tsx]/cms/news/page.tsx#L17-L31)
- [src/lib/plasmic.ts]
- [src/lib/api.ts]
Section sources
- [src/app/(dashboard)/cms/news/page.tsx]/cms/news/page.tsx#L1-L153)
- [src/lib/plasmic.ts]
- [src/lib/api.ts]
Routing Patterns and Navigation
- App Router groups: (dashboard) for authenticated area
- Sidebar navigation drives programmatic routing
- Environment-aware rewrites route API traffic to gateway or backend services
Diagram sources
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L127-L146)
- [next.config.ts]
Section sources
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L95-L104)
- [next.config.ts]
Dependency Analysis
- Next.js 16 runtime and App Router
- Arco Design for UI components and theming
- Plasmic loader for CMS integration
- Environment-driven configuration and rewrites
Diagram sources
- [package.json]
- [next.config.ts]
- [src/config/env.ts]
- [src/lib/request.ts]
- [src/lib/api.ts]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L1-L45)
Section sources
Performance Considerations
- Environment-aware rewrites reduce latency by routing through a gateway when configured
- Pagination on user listings prevents large payloads
- Local caching of theme preference avoids unnecessary DOM manipulation
- JSONBig parsing supports large numeric IDs consistently
Recommendations:
- Enable output: standalone for containerized deployments
- Consider enabling SWC transpilation for faster builds
- Monitor API latency per environment and adjust gateway routing accordingly
Section sources
- [next.config.ts]
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L166-L172)
Troubleshooting Guide
Common issues and resolutions:
Login fails or redirects to /login
- Verify token exists in local storage and is not expired
- Check backend auth service availability
- Review request.ts 401 handling and redirects
- References: [src/app/login/page.tsx], [src/lib/request.ts]
Users page shows empty list or errors
- Confirm pagination parameters and filters
- Ensure backend tenant-m service is reachable via rewrites
- References: [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L24-L40), [next.config.ts]
CMS news not loading
- Validate bi-sys configuration keys for Plasmic tokens and model ID
- Confirm /api/cms route is accessible and authorized
- References: [src/lib/plasmic.ts], [src/lib/plasmic.ts]
Theme not persisting
- Check localStorage key "arco-theme" and body attribute
- References: [src/app/layout.tsx], [src/app/(dashboard)/layout.tsx]/layout.tsx#L75-L84)
Section sources
- [src/app/login/page.tsx]
- [src/lib/request.ts]
- [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L24-L40)
- [next.config.ts]
- [src/lib/plasmic.ts]
- [src/lib/plasmic.ts]
- [src/app/layout.tsx]
- [src/app/(dashboard)/layout.tsx]/layout.tsx#L75-L84)
Conclusion
The Admin Panel leverages Next.js 16 App Router to deliver a secure, modular, and maintainable administration interface. Its layered design separates concerns across presentation, domain services, and infrastructure, while environment-aware routing and centralized request handling simplify integration with backend services and gateways. The system provides robust administrative capabilities for user management, tenant operations, system configuration, and CMS content management, with strong security and UX foundations.
Appendices
Administrative Tasks and Workflows
User administration
- Create, edit, toggle status, and reset passwords
- Assign departments and roles during creation/edit
- Reference: [src/app/(dashboard)/system/users/page.tsx]/system/users/page.tsx#L62-L116), [src/lib/api.ts]
System configuration
- Retrieve and update configuration keys via bi-sys
- Reference: [src/lib/api.ts], [src/lib/plasmic.ts]
CMS content management
- Query, create, update, and delete news entries
- Manage localized content and translation status
- Reference: [src/app/(dashboard)/cms/news/page.tsx]/cms/news/page.tsx#L17-L107), [src/lib/plasmic.ts]
System monitoring
- View dashboard KPIs and customer status distribution
- Reference: [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L27-L36)
Security Considerations
- Tokens stored in browser local storage; ensure HTTPS and secure cookies on backend
- 401 handling automatically logs out unauthorized sessions
- API Route proxy for CMS prevents direct browser-to-CMS CORS issues
- References: [src/lib/request.ts], [src/lib/plasmic.ts]
Accessibility and Responsive Design
- Dark/light theme toggle persisted in localStorage
- Arco Design components provide accessible defaults
- Responsive grid layouts and card-based content
- References: [src/app/layout.tsx], [src/app/(dashboard)/layout.tsx]/layout.tsx#L75-L84), [src/app/(dashboard)/dashboard/page.tsx]/dashboard/page.tsx#L49-L109)