# dushixiang/next-terminal architecture

> Architecture diagram of the GitHub repository dushixiang/next-terminal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dushixiang/next-terminal
- Repository: https://github.com/dushixiang/next-terminal

## Overview

##### Project type and purpose
- From the file‐tree and README, this repo is the *front‐end* of Next Terminal: a React/TypeScript/Vite single‐page application (SPA) that provides an interactive auditing dashboard and terminal access UI.  It is part of a larger full‐stack system where the UI communicates with a REST/gateway backend to manage remote sessions (RDP, SSH, VNC, etc.), recording, auditing, and compliance.

##### File structure
- Top‐level:
- `index.html` + `src/main.tsx` bootstraps the React app via Vite.
- `src/App.tsx` is the root component.
- `src/pages/…` holds route‐based page components (access, account, identity, audit, sysops, etc.).
- `src/components/…`, `components/ui/…`, and `components/theme-provider.tsx` implement reusable UI primitives (buttons, tables, charts, modals, theme).
- `src/api/…` contains a thin REST client layer—one file per endpoint—built atop `src/api/core` (generic request, event emitter).
- `src/layout/…` defines application shells (ManagerLayout, UserLayout, header/footer).
- `src/hook/…` holds custom React hooks for state, theme, language, session, Guacamole integration.
- `src/utils/…`, `lib/utils.ts`: utility functions.
- `public`, `assets`: static assets and images.
- Configs: `vite.config.ts`, `tsconfig.json`, `tailwind.config.js`, PostCSS.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layer 1: Client Browser
    subgraph "Client-side" 
        direction TB
        Browser["Browser"]:::client
        EntryHTML["index.html"]:::client
        MainTSX["src/main.tsx"]:::client
    end
    click EntryHTML "https://github.com/dushixiang/next-terminal/blob/master/index.html"
    click MainTSX "https://github.com/dushixiang/next-terminal/blob/master/src/main.tsx"

    %% Layer 2: React SPA Internals
    subgraph "React SPA (Vite + React/TypeScript)" 
        direction TB
        AppRoot["src/App.tsx"]:::client
        Routing["Page Routing (src/pages/)"]:::client
        UIComponents["UI Components (components/ui/, src/components/, components/theme-provider.tsx)"]:::client
        Layouts["Layouts (src/layout/)"]:::client
        Hooks["Custom Hooks (src/hook/)"]:::client
        APIClient["API Layer (src/api/)"]:::client
        CoreAPI["Core API Utils"]:::client
        Utils["Utilities (lib/utils.ts, src/utils/)"]:::client
        Assets["Static Assets (public/, src/assets/)"]:::client
        Configs["Config Files (vite.config.ts, tsconfig.json, tailwind.config.js, postcss.config.js)"]:::client
    end

    click AppRoot "https://github.com/dushixiang/next-terminal/blob/master/src/App.tsx"
    click Routing "https://github.com/dushixiang/next-terminal/tree/master/src/pages/"
    click UIComponents "https://github.com/dushixiang/next-terminal/tree/master/components/ui/"
    click UIComponents "https://github.com/dushixiang/next-terminal/tree/master/src/components/"
    click UIComponents "https://github.com/dushixiang/next-terminal/blob/master/components/theme-provider.tsx"
    click Layouts "https://github.com/dushixiang/next-terminal/tree/master/src/layout/"
    click Hooks "https://github.com/dushixiang/next-terminal/tree/master/src/hook/"
    click APIClient "https://github.com/dushixiang/next-terminal/tree/master/src/api/"
    click CoreAPI "https://github.com/dushixiang/next-terminal/blob/master/src/api/core/requests.ts"
    click CoreAPI "https://github.com/dushixiang/next-terminal/blob/master/src/api/core/api.ts"
    click CoreAPI "https://github.com/dushixiang/next-terminal/blob/master/src/api/core/event-emitter.ts"
    click Utils "https://github.com/dushixiang/next-terminal/blob/master/lib/utils.ts"
    click Utils "https://github.com/dushixiang/next-terminal/tree/master/src/utils/"
    click Assets "https://github.com/dushixiang/next-terminal/tree/master/public/"
    click Assets "https://github.com/dushixiang/next-terminal/tree/master/src/assets/"
    click Configs "https://github.com/dushixiang/next-terminal/blob/master/vite.config.ts"
    click Configs "https://github.com/dushixiang/next-terminal/blob/master/tsconfig.json"
    click Configs "https://github.com/dushixiang/next-terminal/blob/master/tailwind.config.js"
    click Configs "https://github.com/dushixiang/next-terminal/blob/master/postcss.config.js"

    %% Layer 3: API Gateway & Services
    subgraph "Server-side: API Gateway & Microservices" 
        direction TB
        APIGateway["API Gateway"]:::server
        subgraph "Microservices"
            direction TB
            AuthService["Auth Service"]:::server
            AuditService["Audit Service"]:::server
            AccessService["Access Control Service"]:::server
        end
    end

    %% Layer 4: External Systems & Storage
    subgraph "External Systems & Storage"
        direction TB
        GuacamoleExt["Guacamole/SSH/RDP Proxy"]:::external
        LDAP["LDAP / Identity Provider"]:::external
        Database["Database"]:::storage
        StorageSys["Storage (Recordings, Logs)"]:::storage
    end

    %% Connections
    Browser -->|"loads"| EntryHTML
    EntryHTML -->|"bootstraps"| MainTSX
    MainTSX -->|"renders"| AppRoot
    AppRoot --> Routing
    AppRoot --> UIComponents
    AppRoot --> Layouts
    AppRoot --> Hooks
    AppRoot --> APIClient
    AppRoot --> Utils
    AppRoot --> Assets

    APIClient -->|"HTTPS /api/*"| APIGateway
    APIGateway -->|"Auth APIs"| AuthService
    APIGateway -->|"Audit APIs"| AuditService
    APIGateway -->|"Access APIs"| AccessService

    AuthService --> LDAP
    AuditService --> Database
    AuditService --> StorageSys
    AccessService --> GuacamoleExt
    AccessService --> Database

    %% Classes
    classDef client fill:#E3F2FD,stroke:#90CAF9,color:#0D47A1;
    classDef server fill:#E8F5E9,stroke:#66BB6A,color:#1B5E20;
    classDef external fill:#EEEEEE,stroke:#BDBDBD,color:#424242;
    classDef storage fill:#FFF3E0,stroke:#FFB74D,color:#E65100;
```
