# mouhamed-git/slash-admin architecture

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

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

## Overview

##### Project type and purpose
- Slash Admin is a frontend single-page application (SPA) template / admin dashboard built with React 18, Vite, Ant Design, TypeScript.
- It provides a ready-made admin UI, mock data (MSW + Faker), routing, state management (Zustand), data fetching (React-Query), theming, i18n, and a Dockerized build/deploy pipeline.

##### File structure analysis
- Top-level config: Dockerfile, docker-compose.yaml, CI (/.github/workflows/ci.yml), Vite config, TypeScript config, lint/prettier/husky, .env files.
- Public: index.html, static assets, service worker.
- src:
- App entry: main.tsx, App.tsx
- API layer: src/api/apiClient.ts, services/*.ts
- Mock layer: src/_mock + public/mockServiceWorker.js
- Layouts: dashboard and simple wrappers, nav, headers
- Pages: organized by feature (components demos, dashboard, functions, management, sys, menu-level)
- Router: route definitions, auth guards, hooks
- State: Zustand stores in src/store
- Theme & styles: AntD theme overrides, Tailwind, global CSS
- Utilities & types

##### README insights
- Emphasizes React hooks, Vite, AntD, TypeScript, HMR, responsive design, nested routing, access control, i18n, mocking, state mgmt, data fetching, Docker support, GitHub Actions.

##### Main components
a. Developer / CI/CD layer
- GitHub repository → CI workflow → Docker image → Docker Compose → Production container.
b. Build pipeline
- Vite dev server (HMR) for development
- Vite production build → static assets
c. Browser / Client
- React SPA
- Router (react-router or custom)
- UI components (AntD + custom)
- Pages & Layouts
- State stores (Zustand)
- Data fetching (React-Query)
- API client (axios/fetch wrapper)
- Mock Service Worker (MSW + Faker) in development
- Static assets & images
- i18n engine
- Theming engine (AntD overrides + Tailwind)
d. External services
- Real backend API (user/org/demo endpoints)
- Authentication / Authorization service (role-based)
- CDN / Static file host

##### Relationships and interactions
- Developer pushes code → CI builds + lints/tests → docker image → container deploy → serves static files.
- In development: Browser ← Vite dev server (HMR) → React App ← Mock Service Worker simulating API.
- In production: Browser ← CDN / Docker container serving static bundle → React App → API client calls real backend.
- UI components dispatch React-Query hooks → API client → backend or mock → state updates in cache/Zustand → UI re-renders.
- Router handles navigation, auth-guard checks userStore → redirects to login if unauthorized.
- i18n module loads language resources, toggled via locale-picker.

##### Architectural patterns & design principles
- SPA with client-side routing
- Container-presentational (pages vs components)
- Service layer for API abstraction
- Hook-based composition (React hooks for events, theming, locale)
- Atomic design for UI components (small, reusable)
- Mocking abstraction decoupled from production code (MSW)
- Unidirectional data flow (React-Query + Zustand)
- Theming via CSS-in-JS and global styles

## Diagram (Mermaid)

```mermaid
flowchart TB
  %% Developer & CI/CD
  subgraph "Developer & CI/CD"
    direction TB
    GitHub["GitHub Repo"]:::developer
    CI["CI Workflow"]:::developer
    DockerfileNode["Dockerfile"]:::developer
    DockerCompose["docker-compose.yaml"]:::developer
    DockerImage["Docker Image"]:::build
    DockerContainer["Docker Container"]:::deploy
    GitHub --> CI
    CI --> DockerImage
    DockerImage --> DockerCompose
    DockerCompose --> DockerContainer
  end

  %% Build Pipeline
  subgraph "Build Pipeline"
    direction TB
    ViteDev["Vite Dev Server"]:::build
    ProdBuild["Vite Prod Build"]:::build
    ViteDev -->|HMR| ReactApp
    ProdBuild -->|Static Assets| DockerContainer
  end

  %% Runtime Client
  subgraph "Runtime Client"
    direction TB
    ReactApp["React SPA"]:::client
    Router["Router"]:::client
    AuthGuard["Auth Guard"]:::client
    RouterHooks["Router Hooks"]:::client
    Pages["Pages & Layouts"]:::client
    LayoutsDashboard["Dashboard Layout"]:::client
    LayoutsSimple["Simple Layout"]:::client
    LayoutsCommon["Common Layout"]:::client
    UILibrary["UI Library (AntD + Custom)"]:::client
    Theme["Theming Engine"]:::client
    i18n["i18n Engine"]:::client
    StateZustand["Zustand Stores"]:::storage
    ReactQuery["React-Query"]:::client
    APIClient["API Client"]:::client
    APIServices["API Services"]:::client
    MockLayer["MSW Mock Layer"]:::mock
    MockSrc["Mock Handlers"]:::mock
    MockIndex["Mock Index"]:::mock
    MockUtils["Mock Utils"]:::mock
    Assets["Static Assets"]:::client
    Icons["Icons"]:::client
    Utils["Utilities"]:::client
    Types["Types"]:::client

    ReactApp --> Router
    Router --> AuthGuard
    Router --> RouterHooks
    ReactApp --> Pages
    Pages --> LayoutsDashboard
    Pages --> LayoutsSimple
    Pages --> LayoutsCommon
    ReactApp --> UILibrary
    ReactApp --> Theme
    ReactApp --> i18n
    ReactApp --> StateZustand
    ReactApp --> ReactQuery
    ReactQuery --> APIClient
    APIClient --> APIServices
    ReactApp --> MockLayer
    MockLayer --> MockSrc
    MockLayer --> MockIndex
    MockLayer --> MockUtils
    ReactApp --> Assets
    Assets --> Icons
    ReactApp --> Utils
    ReactApp --> Types
  end

  %% External Services
  subgraph "External Services"
    direction TB
    Backend["Backend API"]:::external
    AuthService["Auth Service"]:::external
    CDN["CDN / Static Host"]:::external
    APIClient --> Backend
    APIClient --> AuthService
    DockerContainer --> CDN
    CDN --> ReactApp
  end

  %% Click Events
  click CI "https://github.com/mouhamed-git/slash-admin/blob/main/.github/workflows/ci.yml"
  click DockerfileNode "https://github.com/mouhamed-git/slash-admin/tree/main/Dockerfile"
  click DockerCompose "https://github.com/mouhamed-git/slash-admin/blob/main/docker-compose.yaml"
  click ViteDev "https://github.com/mouhamed-git/slash-admin/blob/main/vite.config.ts"
  click ReactApp "https://github.com/mouhamed-git/slash-admin/blob/main/src/main.tsx"
  click Router "https://github.com/mouhamed-git/slash-admin/blob/main/src/router/index.tsx"
  click AuthGuard "https://github.com/mouhamed-git/slash-admin/blob/main/src/router/components/auth-guard.tsx"
  click RouterHooks "https://github.com/mouhamed-git/slash-admin/tree/main/src/router/hooks/"
  click UILibrary "https://github.com/mouhamed-git/slash-admin/tree/main/src/components/"
  click Theme "https://github.com/mouhamed-git/slash-admin/tree/main/src/theme/"
  click i18n "https://github.com/mouhamed-git/slash-admin/blob/main/src/locales/i18n.ts"
  click Pages "https://github.com/mouhamed-git/slash-admin/tree/main/src/pages/"
  click LayoutsDashboard "https://github.com/mouhamed-git/slash-admin/tree/main/src/layouts/dashboard/"
  click LayoutsSimple "https://github.com/mouhamed-git/slash-admin/tree/main/src/layouts/simple/"
  click LayoutsCommon "https://github.com/mouhamed-git/slash-admin/tree/main/src/layouts/_common/"
  click StateZustand "https://github.com/mouhamed-git/slash-admin/blob/main/src/store/userStore.ts"
  click APIClient "https://github.com/mouhamed-git/slash-admin/blob/main/src/api/apiClient.ts"
  click APIServices "https://github.com/mouhamed-git/slash-admin/blob/main/src/api/services/*.ts"
  click MockLayer "https://github.com/mouhamed-git/slash-admin/blob/main/public/mockServiceWorker.js"
  click MockSrc "https://github.com/mouhamed-git/slash-admin/tree/main/src/_mock/handlers/"
  click MockIndex "https://github.com/mouhamed-git/slash-admin/blob/main/src/_mock/index.js"
  click MockUtils "https://github.com/mouhamed-git/slash-admin/blob/main/src/_mock/utils.js"
  click Assets "https://github.com/mouhamed-git/slash-admin/tree/main/src/assets/images/"
  click Icons "https://github.com/mouhamed-git/slash-admin/tree/main/src/assets/icons/"
  click Utils "https://github.com/mouhamed-git/slash-admin/tree/main/src/utils/"
  click Types "https://github.com/mouhamed-git/slash-admin/tree/main/types/"

  %% Styles
  classDef developer fill:#f9f,stroke:#333,stroke-width:1px
  classDef build fill:#bbf,stroke:#333,stroke-width:1px
  classDef client fill:#bfb,stroke:#333,stroke-width:1px
  classDef storage fill:#ffb,stroke:#333,stroke-width:1px
  classDef external fill:#fdd,stroke:#333,stroke-width:1px
  classDef mock fill:#eee,stroke-dasharray:5 5,stroke:#666
  classDef deploy fill:#dfd,stroke:#333,stroke-width:1px
```
