# liukuo362573/yishaadmin architecture

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

- Interactive diagram: https://gitdiagram.com/liukuo362573/yishaadmin
- Repository: https://github.com/liukuo362573/yishaadmin

## Overview

##### Project Type and Purpose
- YiShaAdmin is a full-stack .NET Core web management system. It provides both a browser-based UI (YiSha.Admin.Web) and a RESTful API (YiSha.Admin.WebApi) backed by layered services, data access, and a scheduler for background jobs. It targets CMS/CRM/ERP/OA scenarios.

##### High-Level Architecture
- Layered, modular design:
- Presentation Layer
– YiSha.Admin.Web (MVC Razor UI)
– YiSha.Admin.WebApi (REST API)
- Service/Business Layer
– YiSha.Service (Service classes implementing business logic)
– YiSha.Business (BLL classes, AutoJob scheduling)
- Data Layer
– YiSha.Data.EF (Entity Framework DbContexts, database provider implementations)
– YiSha.Data.Repository (Repository pattern)
– YiSha.Data (low-level helper & extensions, multi-DB support)
- Domain Model
– YiSha.Entity (entities, enums, DTO models)
- Utilities
– YiSha.Util (ID generator, code generator, helpers, caching)
- Infrastructure
– Redis cache (YiSha.Cache)
– Scheduler (YiSha.Business.AutoJob)
– Nginx config, publish scripts

##### Main Components & Responsibilities
- Browser UI (Razor pages + JS assets)
- API endpoints (Controllers for CRUD operations, file uploads, auth)
- Controller layer invokes Services (e.g., UserService, MenuService)
- Services call BLL to enforce business rules and to orchestrate data operations
- BLL uses RepositoryFactory to obtain repositories for CRUD
- EF DbContexts (MySqlDbContext, SqlServerDbContext) manage ORM to underlying SQL databases
- Scheduler uses IJobTask implementations (e.g., DatabasesBackupJob) to run periodic tasks
- Utilities provide cross-cutting functions: code generation, Snowflake ID, Excel/JSON helpers, validation, caching

##### Component Interactions & Data Flow
- User → Web UI Controller → Service → BLL → Repository → EF DbContext → Database
- Third-party or mobile client → API Controller → Service/BLL → Data Layer → Database
- Scheduler triggers AutoJobBLL → JobCenter → JobExecute → performs tasks via Data Layer
- Utilities (e.g., RedisCache) are injected at Service/BLL layer for caching; Log filters capture API/operation/login logs

##### Architectural Patterns & Principles
- Separation of Concerns: distinct layers for presentation, business, data access
- Dependency Injection: controllers/services/bll/repositories registered in Startup.cs
- Repository Pattern: data access abstracted behind IRepository
- Unit of Work implied by EF DbContext
- Modularization: domain organized by feature (OrganizationManage, SystemManage, ToolManage)
- Background Scheduler using custom JobScheduler

##### Technologies & Frameworks
- .NET Core 6.0+ (ASP.NET Core MVC, ASP.NET Core Web API)
- Entity Framework Core with multi-database support (MySQL, SQL Server, Oracle)
- Razor + jQuery + Bootstrap + various JS libraries for UI
- Redis (YiSha.Cache)
- NLog for logging
- Shell/BAT scripts for CI/CD publishing
- Nginx as reverse proxy

##### Final Advice
- Modules from the file tree, grouping by layer and feature set
- Technology choices (EF Core, Redis, NLog, Quartz-style scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        WebUI["Web Admin UI<br/>(YiSha.Admin.Web)"]:::presentation
        WebAPI["Web API<br/>(YiSha.Admin.WebApi)"]:::presentation
    end

    %% Service / Business Layer
    subgraph "Service / Business Layer"
        direction TB
        Services["Business Services<br/>(YiSha.Service)"]:::business
        BLL["Business Logic & BLL<br/>(YiSha.Business)"]:::business
        Scheduler["AutoJob Scheduler<br/>(YiSha.Business.AutoJob)"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Repos["Repositories<br/>(YiSha.Data.Repository)"]:::data
        EF["EF DbContexts & Providers<br/>(YiSha.Data.EF)"]:::data
        DataHelpers["DB Helpers & Extensions<br/>(YiSha.Data)"]:::data
    end

    %% Domain Model
    subgraph "Domain Model"
        direction TB
        Entities["Entities & DTOs<br/>(YiSha.Entity)"]:::domain
        Enums["Enums<br/>(YiSha.Enum)"]:::domain
        Models["Request/Response Models<br/>(YiSha.Model)"]:::domain
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        CodeGen["Code Generator<br/>(YiSha.CodeGenerator)"]:::util
        IDGen["ID Generator<br/>(YiSha.IdGenerator)"]:::util
        Helpers["General Helpers & Caching<br/>(YiSha.Util)"]:::util
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        RedisCache[(Redis Cache)]:::infra
        DatabaseProvider["Database Provider"]:::infra
        MySQL[(MySQL)]:::infra
        SQLServer[(SQL Server)]:::infra
        Nginx["Nginx Config<br/>(nginx.conf)"]:::infra
        CICD["CI/CD & Deploy Scripts"]:::infra
    end

    %% Relationships
    WebUI -->|"HTTP Calls"| Services
    WebAPI -->|"REST Calls"| Services
    Services -->|"Invoke Business Logic"| BLL
    Scheduler -->|"Schedules Tasks"| BLL
    BLL -->|"Use Repositories"| Repos
    Repos -->|"EF Interactions"| EF
    EF -->|"SQL Operations"| DatabaseProvider
    DatabaseProvider --> MySQL
    DatabaseProvider --> SQLServer
    Services ---|Cache R/W| RedisCache
    BLL ---|Cache R/W| RedisCache
    Services -->|"Use Domain Models"| Entities
    Services --> Enums
    Services --> Models
    BLL --> Entities
    BLL --> Models
    CodeGen -->|"Utility"| Services
    IDGen -->|"Utility"| Services
    Helpers -->|"Utility"| Services
    RedisCache -->|"Backed by"| DatabaseProvider
    CICD -->|"Deploys"| WebUI
    CICD --> WebAPI
    CICD --> Services
    CICD --> BLL
    Nginx --> WebAPI
    Nginx --> WebUI

    %% Scheduler Flow
    Scheduler -->|"Trigger"| JobCenter("Job Center"):::infra
    JobCenter -->|"Executes Jobs"| JobExecute("Job Execute"):::infra
    JobExecute --> BLL

    %% Click Events
    click WebUI "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Web/YiSha.Admin.Web/"
    click WebAPI "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Web/YiSha.Admin.WebApi/"
    click Services "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Business/YiSha.Service/"
    click BLL "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Business/YiSha.Business/"
    click Scheduler "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Business/YiSha.Business.AutoJob/"
    click EF "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Data/YiSha.Data.EF/"
    click Repos "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Data/YiSha.Data.Repository/"
    click DataHelpers "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Data/YiSha.Data/"
    click Entities "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Entity/YiSha.Entity/"
    click Enums "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Entity/YiSha.Enum/"
    click Models "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Entity/YiSha.Model/"
    click CodeGen "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Util/YiSha.CodeGenerator/"
    click IDGen "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Util/YiSha.IdGenerator/"
    click Helpers "https://github.com/liukuo362573/yishaadmin/tree/master/YiSha.Util/YiSha.Util/"

    %% Styles
    classDef presentation fill:#D6EAF8,stroke:#1F618D,color:#1B4F72;
    classDef business fill:#D5F5E3,stroke:#196F3D,color:#145A32;
    classDef data fill:#FDEBD0,stroke:#B9770E,color:#7E5109;
    classDef domain fill:#E8DAEF,stroke:#7D3C98,color:#512E5F;
    classDef util fill:#FCF3CF,stroke:#B7950B,color:#7D6608;
    classDef infra fill:#F5B7B1,stroke:#922B21,color:#641E16;
```
