Skip to content

Admin Panel Overview

**Referenced Files in This Document** - [[package.json]](file/ui-web-admin/package.json) - [[next.config.ts]](file/ui-web-admin/next.config.ts) - [[tsconfig.json]](file/ui-web-admin/tsconfig.json) - [[postcss.config.mjs]](file/ui-web-admin/postcss.config.mjs) - [[src/app/layout.tsx]](file/ui-web-admin/src/app/layout.tsx) - [[src/app/page.tsx]](file/ui-web-admin/src/app/page.tsx) - [[src/config/env.ts]](file/ui-web-admin/src/config/env.ts) - [[src/components/ArcoCompat.tsx]](file/ui-web-admin/src/components/arcocompat.tsx) - [[src/lib/request.ts]](file/ui-web-admin/src/lib/request.ts) - [[src/lib/api.ts]](file/ui-web-admin/src/lib/api.ts) - [[src/app/(dashboard)/layout.tsx]](file/ui-web-admin/src/app/dashboard)/layout.tsx) - [[src/app/login/page.tsx]](file/ui-web-admin/src/app/login/page.tsx) - [[src/app/(dashboard)/dashboard/page.tsx]](file/ui-web-admin/src/app/dashboard)/dashboard/page.tsx)

Table of Contents

  1. Introduction
  2. Project Structure
  3. Core Components
  4. Architecture Overview
  5. Detailed Component Analysis
  6. Dependency Analysis
  7. Performance Considerations
  8. Troubleshooting Guide
  9. Conclusion
  10. Appendices

Introduction

This document provides a comprehensive overview of the Admin Panel (ui-web-admin) built with Next.js 16 and TypeScript. It explains the architecture, routing strategy, component composition, styling approach with Arco Design React and Tailwind CSS, environment configuration, and the application lifecycle. It also covers development setup, build and deployment guidance, and environment variable management across development, test, staging, and production environments.

Project Structure

The ui-web-admin project follows Next.js App Router conventions with a strict file-based routing under the src/app directory. Key areas include:

  • App shell and global layout
  • Authentication and protected dashboard routes
  • Feature modules for system management, tenants, and CMS
  • Shared libraries for API requests and typed endpoints
  • Environment-specific configuration and Next.js configuration

Diagram sources

Section sources

Core Components

  • Environment configuration: Centralized environment selection and API endpoint mapping for gateway and service URLs.
  • Request abstraction: Unified fetch wrapper with token injection, 401 handling, JSON parsing, and error messaging.
  • API facade: Typed endpoints for auth, dashboard, tenants, system management, and dictionaries.
  • Arco Design React compatibility: React 19 compatibility initialization for Arco components.
  • Global layout and theme: Root layout with Arco CSS, dark/light theme persistence, and icon font integration.
  • Routing and navigation: App Router with dynamic groups, protected routes via session checks, and sidebar navigation.

Section sources

Architecture Overview

The Admin Panel uses Next.js 16 App Router with a modern build pipeline. It integrates Arco Design React for UI components and Tailwind CSS for utility-first styling. Environment variables drive runtime configuration, including API endpoints and gateway mode. Next.js rewrites proxy API traffic either to a gateway or individual backend services depending on the environment.

Diagram sources

Detailed Component Analysis

Environment Configuration and Build System

  • Environment selection: NEXT_PUBLIC_APP_ENV determines the active environment, mapped to gateway/service URLs.
  • Gateway vs direct mode: Rewrites route prefixes to a gateway or direct backend services based on environment.
  • Build output: Standalone output for containerized deployments.
  • Transpilation: Arco Design React and a shared bi package are transpiled for compatibility.

Diagram sources

Section sources

Routing Strategy and Page Structure

  • Root redirect: The home page redirects to either the dashboard or login based on token presence.
  • Protected dashboard: The dashboard layout fetches user info and enforces token presence.
  • Dynamic groups: Feature areas are grouped under (dashboard) to organize routes cleanly.
  • Login page: Provides a form to authenticate and persist tokens.

Diagram sources

Section sources

Application Lifecycle

  • Initialization: Root layout injects Arco CSS and theme initialization script, sets up Arco compatibility.
  • Navigation: Sidebar menu drives navigation; theme toggles persist to localStorage and update DOM attributes.
  • Authentication: On mount, token is checked; user info is fetched; logout clears token and navigates to login.
  • Dashboard: Stats are loaded on mount with loading states and graceful fallbacks.

Diagram sources

Section sources

Arco Design React Integration and Tailwind CSS Styling

  • Arco Design React: Installed and imported globally in the root layout; compatibility initialized for React 19.
  • Tailwind CSS: Configured via PostCSS plugin; path aliases configured in tsconfig; utility classes used throughout.
  • Dark/light theme: Controlled via localStorage and DOM attributes; persisted across sessions.

Diagram sources

Section sources

API Layer and Request Handling

  • Unified request wrapper: Handles URL construction, query params, Authorization header, 401 logout, JSON parsing, and error messaging.
  • API facade: Provides typed endpoints for auth, dashboard, tenants, system management, and dictionaries; supports mock switch.
  • Parameter flattening: Converts nested params to dot notation for pagination and filtering.

Diagram sources

Section sources

Dependency Analysis

  • Core framework: Next.js 16, React 19, TypeScript.
  • UI framework: Arco Design React with compatibility shim for React 19.
  • Styling: Tailwind CSS via PostCSS plugin.
  • Utilities: crypto-js for encryption helpers, json-bigint for large-number JSON support.
  • Build and linting: ESLint, PostCSS, autoprefixer, Tailwind, TypeScript.

Diagram sources

Section sources

Performance Considerations

  • Transpiling: Arco Design React and the shared bi package are transpiled to improve compatibility and reduce bundling overhead.
  • Standalone output: Ensures minimal runtime footprint for containerized deployments.
  • JSON parsing: Uses JSONBig to handle large numeric values safely.
  • Conditional mocks: API facade supports a mock flag to reduce network overhead during development.

[No sources needed since this section provides general guidance]

Troubleshooting Guide

  • 401 Unauthorized: The request wrapper removes the token and redirects to the login page automatically.
  • Network errors: Errors are surfaced via Arco Message; inspect browser console for raw response text.
  • Theme not applying: Verify localStorage key and DOM attribute updates; confirm Arco compatibility initialization runs.
  • API routing: Confirm NEXT_PUBLIC_APP_ENV matches the intended environment and that rewrites are active.

Section sources

Conclusion

The Admin Panel leverages Next.js 16’s modern features with a clean separation of concerns: environment-driven configuration, a robust request layer, and a cohesive UI powered by Arco Design React and Tailwind CSS. The routing model and protected layouts ensure secure and intuitive navigation, while the build configuration supports efficient standalone deployments across environments.

[No sources needed since this section summarizes without analyzing specific files]

Appendices

Setup Instructions for Local Development

  • Install dependencies: Use the package manager configured in the repository.
  • Start development server:
    • Development: run the dev script with the desired environment.
    • Available scripts include dev, dev:local, dev:test, dev:staging.
  • Build for production:
    • Use build scripts for each environment (dev, test, staging, prod).
  • Run production server:
    • Use the start script after building.

Environment variable management:

  • NEXT_PUBLIC_APP_ENV controls environment selection and API routing.
  • Supported values align with the EnvType union and map to predefined EnvConfig entries.

Deployment configuration:

  • Standalone output is enabled for containerized deployments.
  • Re-write rules proxy API traffic to either a gateway or direct backend services based on the environment.

Section sources