Skip to content

Dashboard

The CoSky Dashboard is a modern single-page application built with React 19, TypeScript, and Ant Design 6. It provides a visual management interface for all CoSky capabilities: service monitoring, configuration management, service topology visualization, RBAC administration, user management, and audit log review. The dashboard is served directly by the REST API server as static assets and communicates with the backend exclusively through the CoSky REST API.

At a Glance

AspectDetailKey FileSource
Frontend appReact 19 SPA with Ant Design 6dashboard/package.jsondashboard/package.json
SPA route servingServes index.html for all dashboard routesDashboardConfiguration.ktcosky-rest-api/.../DashboardConfiguration.kt:30
API clientAuto-generated from OpenAPI specdashboard/src/generated/dashboard/package.json:12

Tech Stack

TechnologyVersionPurpose
React19.2.6UI framework
TypeScript~5.9.3Type-safe development
Vite8.0.11Build tool and dev server
Ant Design6.3.7UI component library
React Router DOM7.15.0Client-side routing
@xyflow/react12.10.2Service topology visualization
Monaco Editor0.55.1Configuration text editor
@ahoo-wang/fetcher3.16.2HTTP client with CoSec auth
@ahoo-wang/fetcher-react3.16.2React hooks for API calls
@ahoo-wang/fetcher-cosec3.16.2CoSec token refresh integration
@ahoo-wang/fetcher-viewer3.16.2Data table and filter components
@ahoo-wang/fetcher-generator3.16.2OpenAPI code generation

Source: dashboard/package.json

DashboardConfiguration

DashboardConfiguration is a Spring @Controller that serves the SPA's index.html for all frontend routes. When the user navigates to any dashboard path, the server returns the same index.html file, and React Router handles client-side routing.

Mapped routes: /, /home, /config, /service, /namespace, /user, /role, /audit-log, /login.

Additionally, the legacy /dashboard/** path redirects (301 Moved Permanently) to /home for backward compatibility.

Source: cosky-rest-api/.../DashboardConfiguration.kt:30-78

Service Monitoring

Service Dashboard

The service dashboard provides an overview of all registered services within the selected namespace, including instance counts and health status.

Configuration Management

Config

The configuration management page supports CRUD operations on configs, version history browsing, rollback, and bulk import/export via ZIP files. The Monaco Editor provides syntax highlighting for config content.

Service Topology

Topology

The topology view renders an interactive dependency graph of services using @xyflow/react, showing how services depend on each other within a namespace.

RBAC Management

Role

The role management page allows administrators to create roles and assign namespace-scoped permissions (READ, WRITE, or READ_WRITE) to each role.

User Management

User

User management supports creating users, assigning roles, changing passwords, and unlocking locked accounts.

Audit Log

Audit Log

The audit log page displays a paginated list of all audited operations with operator, IP, path, action, status, and timestamp columns.

Login

Login

The login page authenticates users against the CoSky REST API and stores the JWT token pair in browser storage for subsequent requests.

Architecture

mermaid
flowchart TD
    subgraph "Browser"
        SPA["CoSky Dashboard<br>React SPA"]
        TokenStore["Token Storage<br>(fetcher-storage)"]
    end

    subgraph "REST API Server"
        DashboardConfig["DashboardConfiguration<br>SPA route serving"]
        API["REST API Controllers<br>/v1/*"]
        Security["CoSec Security<br>JWT + RBAC"]
    end

    subgraph "Redis"
        UserRedis["User Index<br>system:user_idx"]
        ConfigRedis["Configs<br>Namespaced keys"]
        ServiceRedis["Services<br>Namespaced keys"]
        AuditRedis["Audit Log<br>system:audit:log"]
    end

    SPA -->|"HTML/JS/CSS"| DashboardConfig
    SPA -->|"API calls + Bearer token"| API
    SPA -->|"Token storage"| TokenStore
    API --> Security
    Security --> UserRedis
    API --> ConfigRedis
    API --> ServiceRedis
    API --> AuditRedis

Data Flow: API Client Generation

mermaid
sequenceDiagram
    autonumber
    participant Dev as Developer
    participant Vite as Vite Dev Server
    participant API as REST API Server
    participant Generator as fetcher-generator
    participant Generated as src/generated/

    Dev->>API: Start server (OpenAPI at /v3/api-docs)
    Dev->>Vite: pnpm generate
    Vite->>Generator: fetcher-generator generate -i /v3/api-docs
    Generator->>API: GET /v3/api-docs
    API-->>Generator: OpenAPI 3.0 spec
    Generator-->>Generated: Type-safe API clients
    Note over Generated: ConfigApiClient, ServiceApiClient,<br>NamespaceApiClient, UserApiClient,<br>RoleApiClient, AuditLogApiClient,<br>StatApiClient, AuthenticateApiClient
    Dev->>Vite: pnpm dev
    Note over Vite: Hot-reloaded React SPA

Authentication Flow in Dashboard

mermaid
flowchart LR
    subgraph "Dashboard"
        Login["Login Page"]
        SecProvider["SecurityProvider<br>(fetcher-react)"]
        FetcherCoSec["Fetcher CoSec<br>Token Refresh"]
        ProtectedRoute["ProtectedRoute"]
    end

    subgraph "REST API"
        AuthAPI["/v1/authenticate"]
    end

    Login -->|"username + password"| AuthAPI
    AuthAPI -->|"JWT access + refresh"| SecProvider
    SecProvider -->|"Attach Bearer token"| FetcherCoSec
    FetcherCoSec -->|"Auto-refresh on 401"| AuthAPI
    SecProvider -->|"Auth state"| ProtectedRoute
    ProtectedRoute -->|"Render pages"| Pages["Config / Service /<br>Namespace / User /<br>Role / Audit"]

References

Released under the Apache License 2.0.