# hev-admin/admin architecture

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

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

## Overview

##### Main Components
- Frontend Clients:
- Client built with React (packages/client-react)
- Client built with Vue 3 (packages/client-vue)
(These are the user interfaces and are built on Vite, which is evident from each client’s vite.config.js.)
- Backend Server:
- Built using Koa (packages/server-koa) that contains the core application logic, API controllers, models, and database handling modules.
- Utility & Admin Creator:
- There is a package (packages/create-hev-admin) that likely bootstraps or scaffolds new admin projects based on this framework.
- Documentation and Support Files:
- A docs folder that contains user-facing documentation, examples, and configuration for the docs site.
- Configuration & Workspace:
- Root-level configuration files (.editorconfig, eslint.config.js, pnpm-workspace.yaml, etc.) that define the overall environment and workspace management.

##### Relationships and Interactions
- The Koa server is structured with controllers, models, and utility modules (including features like Auth, JWT handling, sessions, logging, and database seeding). Represent layers within the server side:
- Controller Layer: Handles incoming HTTP requests.
- Model/Database Layer: Manages ORM, data seeding, and database operations.
- Utility Modules: Provide cross-cutting functionalities such as cryptography, logging, JWT, and session management.
- The create-hev-admin package might be used as a scaffolding tool to generate new projects based on this admin framework; show it as an optional “project generator” utility that interacts with project initialization.
- Drawing out the docs component is also useful, showing how it supports user onboarding, API examples, and markdown guidelines.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Frontend and backend are clearly decoupled. The Koa server follows a modular architecture (controllers, models, utilities), indicating adherence to MVC-like patterns.
- Scalability and Maintainability: The multiple packages (client-react, client-vue, server-koa) are isolated in the “packages” directory, which aligns with modern monorepo practices.
- Extensibility: With a dedicated package for creating new admin projects (create-hev-admin) and a clear separation between frameworks (React vs. Vue frontends), the design favors extension and customization.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: Vite, Vue 3 (client-vue) and React (client-react)
- Backend: Koa, possibly Node.js for server runtime, and middleware or ORM libraries (as shown by the presence of directories like “database” and “model”)
- Build and Development Tools: Vite, ESLint, and pnpm for workspace dependency management
- Documentation: Vitepress is used in the docs folder, indicating an emphasis on a modern documentation approach.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Clients Subgraph
    subgraph "Frontend Clients"
        FR["Client (React)"]
        FV["Client (Vue)"]
    end

    %% Backend Server Subgraph
    subgraph "Backend Server (Koa)"
        S1["Main Application"]
        S2["Controllers"]
        S3["Models"]
        S4["Database"]
        S5["Utilities"]
    end

    %% Other Components
    AC["Admin Creator"]
    DOC["Documentation"]

    %% Frontend to Backend Communication
    FR -->|"HTTP_API"| S1
    FV -->|"HTTP_API"| S1

    %% Internal Backend Data Flow
    S1 -->|"invokes"| S2
    S2 -->|"calls"| S3
    S3 -->|"queries"| S4
    S2 -->|"uses"| S5

    %% Admin Creator Interaction (Project Scaffolding)
    AC -->|"generates"| S1
    AC -->|"generates"| FR
    AC -->|"generates"| FV

    %% Documentation Connections
    DOC -->|"provides_info"| FR
    DOC -->|"provides_info"| FV
    DOC -->|"provides_info"| S1
    DOC -->|"provides_info"| AC

    %% Click Events
    click FR "https://github.com/hev-admin/admin/tree/main/packages/client-react"
    click FV "https://github.com/hev-admin/admin/tree/main/packages/client-vue"
    click S1 "https://github.com/hev-admin/admin/tree/main/packages/server-koa"
    click S2 "https://github.com/hev-admin/admin/tree/main/packages/server-koa/src/controller"
    click S3 "https://github.com/hev-admin/admin/tree/main/packages/server-koa/src/model"
    click S4 "https://github.com/hev-admin/admin/tree/main/packages/server-koa/src/database"
    click S5 "https://github.com/hev-admin/admin/tree/main/packages/server-koa/src/utils"
    click AC "https://github.com/hev-admin/admin/tree/main/packages/create-hev-admin"
    click DOC "https://github.com/hev-admin/admin/tree/main/docs"

    %% Styles
    classDef frontend fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef backend fill:#c5e1a5,stroke:#33691e,stroke-width:2px;
    classDef utility fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef admin fill:#d1c4e9,stroke:#4a148c,stroke-width:2px;
    classDef docs fill:#eeeeee,stroke:#424242,stroke-width:2px;

    class FR,FV frontend;
    class S1,S2,S3,S4 backend;
    class S5 utility;
    class AC admin;
    class DOC docs;
```
