# d3george/slash-admin architecture

> Architecture diagram of the GitHub repository d3george/slash-admin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d3george/slash-admin
- Repository: https://github.com/d3george/slash-admin

## Overview

##### Project type and purpose
- This is a frontend-only, single-page admin dashboard template (“Slash Admin”) built with React 18, Vite, Ant Design, and TypeScript.
- It provides a complete UI framework—components, pages, routing, theming, state management, data-fetching, mocking—so developers can scaffold powerful admin systems quickly.

##### File structure
- Top-level directories & files:
- public/ (static assets, service worker)
- src/ (all application code)
- Dockerfile, docker-compose.yaml (packaging the built app as a container)
- vite.config.ts, tailwind.config.ts (build and styling config)
- Inside src/:
- api/ (apiClient + service modules)
- _mock/ (MSW‐based mock handlers & utils)
- components/, ui/ (atomic & composite UI pieces)
- layouts/ (page skeletons: dashboard, simple)
- pages/ (feature pages organized by domain)
- router/ (route definitions, protected routes)
- store/ (Zustand stores: userStore, settingStore)
- theme/ (theme provider, tokens, adapter, hooks)
- hooks/, utils/, assets/, types/ (shared logic & types)
- Notice architectural patterns:
- Component‐based (atomic + composite)
- Feature modules under pages/ with their own sub‐components
- Provider pattern (store, theme, query, mock)
- Separation of concerns: UI → state → data‐fetching → API / mocks

##### README for additional insights
- Key tech: React-Query for data caching, Zustand for client state, MSW + Faker for dev mocking, Ant Design as CSS/ component library, i18n for localization.
- Dev vs production: Vite dev server + MSW mocks; built files served by Docker container (port 80 → host 3001).

##### Detailed capture of architectural elements
- MSW handler tree under “Mock Layer” with domain handlers.
- Router/modules → nested routes for each feature domain (dashboard, management, sys).
- Theme adapter bridging Ant Design with custom tokens.
- Call out i18n loader reading JSON from src/locales.

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% External Entities
  Browser["Browser"]:::external

  %% Infrastructure Layer
  subgraph "Infrastructure" 
    direction TB
    Vite["Vite Dev Server"]:::infra
    Nginx["Static File Server (Nginx)"]:::infra
    Docker["Docker Container"]:::infra
  end

  Browser -->|GET index.html + JS/CSS| Nginx
  Browser -->|Dev Requests| Vite
  Vite -->|Bundles SPA| Browser
  Docker -->|Serves Bundled SPA| Nginx

  %% React SPA
  subgraph "React SPA" 
    direction TB
    Main["main.tsx"]:::infra
    App["App.tsx"]:::app

    subgraph "Providers"
      ThemeProv["ThemeProvider"]:::state
      QueryProv["QueryClientProvider"]:::state
      StoreProv["Zustand Stores"]:::state
      MockSW["MockServiceWorker"]:::data
    end

    subgraph "Routing & Pages"
      Router["Routing Layer"]:::nav
      Pages["Page Modules"]:::ui
      Layouts["Layouts"]:::ui
    end

    subgraph "UI Components"
      Atomic["Atomic Components"]:::ui
      Composite["Composite Components"]:::ui
      Primitives["Design Primitives"]:::ui
    end

    subgraph "Data Layer"
      APIClient["apiClient"]:::data
      Services["API Services"]:::data
      ReactQuery["React-Query"]:::data
      MockLayer["MSW Mock Layer"]:::data
    end

    App --> Main
    Main --> ThemeProv
    Main --> QueryProv
    Main --> StoreProv
    Main --> Router
    Main --> MockSW

    Router --> Pages
    Pages --> Layouts
    Pages --> Atomic
    Pages --> Composite

    Atomic --> Primitives
    Composite --> Primitives

    QueryProv --> ReactQuery
    StoreProv --> ReactQuery

    ReactQuery --> APIClient
    APIClient --> Services
    APIClient --> MockLayer
  end

  %% External Backend
  REST["Real REST API"]:::external
  APIClient -->|Prod| REST
  APIClient -->|Dev| MockLayer

  %% Styling & Assets
  subgraph "Assets & Config"
    Public["public/"]:::infra
    Assets["src/assets/"]:::infra
    Configs["vite.config.ts & tailwind.config.ts"]:::infra
    Dockerfile["Dockerfile"]:::infra
    Compose["docker-compose.yaml"]:::infra
  end

  Browser --> Public
  App --> Assets
  App --> Configs
  App --> Dockerfile
  App --> Compose

  %% Click Events
  click APIClient "https://github.com/d3george/slash-admin/blob/main/src/api/apiClient.ts"
  click Services "https://github.com/d3george/slash-admin/blob/main/src/api/services/demoService.ts"
  click Services "https://github.com/d3george/slash-admin/blob/main/src/api/services/orgService.ts"
  click Services "https://github.com/d3george/slash-admin/blob/main/src/api/services/userService.ts"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/index.js"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/handlers/_demo.js"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/handlers/_org.js"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/handlers/_user.js"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/utils.js"
  click MockLayer "https://github.com/d3george/slash-admin/blob/main/src/_mock/assets.js"
  click Atomic "https://github.com/d3george/slash-admin/tree/main/src/components/"
  click Primitives "https://github.com/d3george/slash-admin/tree/main/src/ui/"
  click Layouts "https://github.com/d3george/slash-admin/tree/main/src/layouts/"
  click Layouts "https://github.com/d3george/slash-admin/blob/main/src/layouts/dashboard/index.tsx"
  click Layouts "https://github.com/d3george/slash-admin/blob/main/src/layouts/dashboard/main.tsx"
  click Layouts "https://github.com/d3george/slash-admin/blob/main/src/layouts/dashboard/header.tsx"
  click Layouts "https://github.com/d3george/slash-admin/blob/main/src/layouts/dashboard/nav-bar/index.tsx"
  click Pages "https://github.com/d3george/slash-admin/tree/main/src/pages/"
  click Router "https://github.com/d3george/slash-admin/blob/main/src/router/index.tsx"
  click Router "https://github.com/d3george/slash-admin/tree/main/src/router/routes/modules/"
  click Router "https://github.com/d3george/slash-admin/blob/main/src/router/components/protected-route.tsx"
  click StoreProv "https://github.com/d3george/slash-admin/blob/main/src/store/userStore.ts"
  click StoreProv "https://github.com/d3george/slash-admin/blob/main/src/store/settingStore.ts"
  click ThemeProv "https://github.com/d3george/slash-admin/blob/main/src/theme/theme-provider.tsx"
  click ThemeProv "https://github.com/d3george/slash-admin/blob/main/src/theme/adapter/antd.adapter.tsx"
  click ThemeProv "https://github.com/d3george/slash-admin/blob/main/src/theme/hooks/use-theme.ts"
  click Main "https://github.com/d3george/slash-admin/blob/main/src/main.tsx"
  click App "https://github.com/d3george/slash-admin/blob/main/src/App.tsx"
  click Assets "https://github.com/d3george/slash-admin/tree/main/src/assets/"
  click Public "https://github.com/d3george/slash-admin/tree/main/public/"
  click StoreProv "https://github.com/d3george/slash-admin/blob/main/src/store/userStore.ts"
  click StoreProv "https://github.com/d3george/slash-admin/blob/main/src/store/settingStore.ts"

  %% Styles
  classDef external fill:#eeeeee,stroke:#999,stroke-width:1px
  classDef infra fill:#cccccc,stroke:#888,stroke-width:1px
  classDef app fill:#f9f,stroke:#c0c,stroke-width:1px
  classDef ui fill:#99ccff,stroke:#3399ff,stroke-width:1px
  classDef state fill:#ccff99,stroke:#66cc33,stroke-width:1px
  classDef data fill:#ffcc99,stroke:#ff9933,stroke-width:1px
  classDef nav fill:#ccf,stroke:#66c,stroke-width:1px
```
