# zmrid/imes-factory architecture

> Architecture diagram of the GitHub repository zmrid/imes-factory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zmrid/imes-factory
- Repository: https://github.com/zmrid/imes-factory

## Overview

1. This is a split full-stack MES/MOM system with two top-level apps: a .NET backend under iMES.Net and a Vue 3 frontend under iMES.Vue3. The backend exposes a large REST API surface plus SignalR hubs; the frontend is a dynamic admin/business UI built around generated pages and reusable table/form components.

2. The backend is organized as a modular monolith by business domain. Major domain assemblies are System, Calendar, Custom, Warehouse, Tools, Quality, Equip, Report, and Builder. Each module repeats the same layered pattern: Controllers in iMES.WebApi, Services and Repositories in a domain project, and entity/mapping types in iMES.Entity.

3. The core architecture uses a repository/service pattern on top of EF Core and some Dapper support. iMES.Core contains the shared abstractions, base classes, DB and tenancy helpers, caching, middleware, logging, Quartz integration, Kafka integration, workflow, validation, and security utilities. Domain-specific repositories/services depend on these base abstractions rather than each other.

4. Data access is split between EF Core and Dapper. EF Core contexts live in iMES.Core/EFDbContext and map to the entity models in iMES.Entity/DomainModels with explicit mapping configuration classes. Dapper is available for lower-level SQL access and custom query handling, which is relevant for reporting and optimized reads.

5. The database boundary is explicit and vendor-aware. SQL scripts are provided for both MySQL and SQL Server under DB/MySQL and DB/SQLServer, and the appsettings configuration selects the database type. This means the same domain model is intended to run against different relational backends.

6. The business data model is broad but consistent: system/auth tables, workflow/form tables, calendar/shift planning, inventory/warehouse documents, quality inspection records, equipment maintenance assets, tools circulation, and reporting views. Many “View_” entities indicate read-only reporting projections backed by database views.

7. Controllers in iMES.WebApi are almost entirely thin endpoints grouped by module. They map API requests to the corresponding service layer, and there are “Partial” controller/service/repository patterns throughout the repo. That pattern is a key architectural boundary: generated base code lives alongside handwritten extension code without overwriting custom logic.

8. The Builder module is the code-generation subsystem. It inspects table metadata through sys-table information services and produces backend/frontend artifacts from templates stored in iMES.WebApi/Template. This generator is the core of the framework’s “rapid development” story and explains the repeated file structure across modules.

9. Cross-cutting runtime services are centralized in iMES.Core. Notable concerns include JWT/auth filters, permission filters, exception and request middleware, caching via memory or Redis, Quartz scheduled jobs, Kafka producers/consumers, workflow approval helpers, and utility functions for file, PDF, Excel, mail, encryption, and verification codes.

10. Authentication and authorization are enforced at the framework level rather than in individual modules. The repo includes JWT-based authorization, action permission filters, role/user context objects, and menu/permission entities. This supports a menu-driven admin UI and module-level permission checks.

11. Real-time and background integration points are present but secondary to the CRUD backbone. SignalR is used for the home page message hub and likely push notifications, while Quartz handles scheduled tasks and logging of job execution. Kafka classes exist for async message handling, and there is a dedicated MqDataHandle controller in the web API.

12. The frontend mirrors the backend’s modular structure. In src/extension, each backend entity/module has a corresponding generated API binding, page definition, and often custom Vue extensions. Views, components, and route tables are organized by module, with shared generic components for grids, forms, uploads, workflow, redirects, and dashboards.

13. The frontend is designed for dynamic configuration, not hardcoded screens. Table/grid/form metadata, permission-driven menus, and reusable “ViewGrid” and “MesForm” components make the UI behave like a configurable admin framework. This matches the backend’s code generation and metadata-driven model.

14. Static assets and generated artifacts are stored inside the backend web root as well as the frontend app. The backend’s wwwroot/Upload/Tables contains generated code, exports, templates, and uploaded files tied to table names, which indicates the system persists generated artifacts and attachments alongside runtime files.

15. A useful diagram boundary is: browser UI → Vue app state/router/components → REST/SignalR endpoints in WebApi → module services → repositories/EF/Dapper → relational database, with shared Core services providing auth, caching, jobs, messaging, and utility functions across the entire backend.

Main entry points: [`iMES.Net/iMES.WebApi`](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.WebApi) (Web API), [`iMES.Net/iMES.Core`](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Core) (Core), [`iMES.Net/iMES.Entity`](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Entity) (Entity), [`iMES.Vue3/src/extension`](https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/extension) (UI Extensions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Repo"]
end

subgraph group_backend["iMES.Net"]
  node_webapi["Web API<br/>.NET host<br/>[iMES.WebApi]"]
  node_core["Core<br/>shared framework<br/>[iMES.Core]"]
  node_entity["Entity<br/>domain models<br/>[iMES.Entity]"]
  node_systemmod["System<br/>auth/admin module<br/>[iMES.System]"]
  node_custommod["Custom<br/>process/master-data module<br/>[iMES.Custom]"]
  node_calmod["Calendar<br/>planning module<br/>[iMES.Calendar]"]
  node_warehousemod["Warehouse<br/>inventory module<br/>[iMES.Warehouse]"]
  node_qualitymod["Quality<br/>inspection module<br/>[iMES.Quality]"]
  node_equipmod["Equip<br/>[iMES.Equip]"]
  node_toolmod["Tools<br/>tooling module<br/>[iMES.Tools]"]
  node_reportmod["Report<br/>[iMES.Report]"]
  node_buildermod["Builder<br/>codegen module<br/>[iMES.Builder]"]
  node_dbuploads["Generated Files<br/>runtime artifacts<br/>[Tables]"]
end

subgraph group_frontend["iMES.Vue3"]
  node_vueapp["Vue App<br/>frontend host<br/>[src]"]
  node_ui_core["UI Core<br/>shared components<br/>[basic]"]
  node_ui_ext["UI Extensions<br/>generated modules<br/>[extension]"]
  node_ui_views["Views<br/>pages<br/>[views]"]
end

subgraph group_database["DB"]
  node_dbscripts[("SQL Scripts<br/>database scripts")]
end

node_webapi -->|"uses"| node_core
node_webapi -->|"maps"| node_entity
node_webapi -->|"hosts"| node_systemmod
node_webapi -->|"hosts"| node_custommod
node_webapi -->|"hosts"| node_calmod
node_webapi -->|"hosts"| node_warehousemod
node_webapi -->|"hosts"| node_qualitymod
node_webapi -->|"hosts"| node_equipmod
node_webapi -->|"hosts"| node_toolmod
node_webapi -->|"hosts"| node_reportmod
node_buildermod -->|"generates"| node_webapi
node_buildermod -->|"generates"| node_ui_ext
node_entity -->|"mirrors"| node_dbscripts
node_core -->|"configures"| node_dbscripts
node_core -->|"bases on"| node_entity
node_vueapp -->|"composes"| node_ui_core
node_vueapp -->|"loads"| node_ui_ext
node_ui_ext -->|"feeds"| node_ui_views
node_ui_views -->|"calls"| node_webapi
node_webapi -->|"stores"| node_dbuploads

click node_webapi "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.WebApi"
click node_core "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Core"
click node_entity "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Entity"
click node_systemmod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.System"
click node_custommod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Custom"
click node_calmod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Calendar"
click node_warehousemod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Warehouse"
click node_qualitymod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Quality"
click node_equipmod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Equip"
click node_toolmod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Tools"
click node_reportmod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Report"
click node_buildermod "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Builder"
click node_vueapp "https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src"
click node_ui_core "https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/components/basic"
click node_ui_ext "https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/extension"
click node_ui_views "https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/views"
click node_dbscripts "https://github.com/zmrid/imes-factory/tree/main/DB"
click node_dbuploads "https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.WebApi/wwwroot/Upload/Tables"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapi,node_core,node_entity,node_systemmod,node_custommod,node_calmod,node_warehousemod,node_qualitymod,node_equipmod,node_toolmod,node_reportmod,node_buildermod,node_dbuploads toneAmber
class node_vueapp,node_ui_core,node_ui_ext,node_ui_views toneMint
class node_dbscripts toneRose
```

## Components

### iMES.Net

ASP.NET modular monolith backend and shared framework code.

- [Web API](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.WebApi): .NET host · Thin REST controllers, SignalR hubs, and templates for generated artifacts. · `iMES.Net/iMES.WebApi`
- [Core](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Core): shared framework · Cross-cutting abstractions: base repo/service types, auth, caching, middleware, jobs, Kafka, workflow, validation, utilities, and EF/Dapper helpers. · `iMES.Net/iMES.Core`
- [Entity](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Entity): domain models · Shared entity classes and EF mapping configurations for all business domains. · `iMES.Net/iMES.Entity`
- [System](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.System): auth/admin module · Users, roles, menus, permissions, dictionaries, workflow metadata, forms, logs, and Quartz options. · `iMES.Net/iMES.System`
- [Custom](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Custom): process/master-data module · Factory-specific master data such as products, workshops, processes, notices, and rules. · `iMES.Net/iMES.Custom`
- [Calendar](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Calendar): planning module · Holiday, team, plan, and shift planning services. · `iMES.Net/iMES.Calendar`
- [Warehouse](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Warehouse): inventory module · Warehouse bills and stock balance/reporting views. · `iMES.Net/iMES.Warehouse`
- [Quality](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Quality): inspection module · Incoming, process, and outgoing inspection records plus test items and templates. · `iMES.Net/iMES.Quality`
- [Equip](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Equip): equipment module · Device catalogs, assets, spot maintenance plans, and work orders. · `iMES.Net/iMES.Equip`
- [Tools](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Tools): tooling module · Tool types, tool inventory, receiving, and return flows. · `iMES.Net/iMES.Tools`
- [Report](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Report): reporting module · Read-only reporting views and summary outputs, likely optimized with Dapper. · `iMES.Net/iMES.Report`
- [Builder](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.Builder): codegen module · Metadata-driven generator that emits backend and frontend artifacts from templates. · `iMES.Net/iMES.Builder`
- [Generated Files](https://github.com/zmrid/imes-factory/blob/main/iMES.Net/iMES.WebApi/wwwroot/Upload/Tables): runtime artifacts · Uploaded files, exported code, templates, and table-scoped artifacts stored under the web root. · `iMES.Net/iMES.WebApi/wwwroot/Upload/Tables`

### iMES.Vue3

Vue 3 admin UI and generated module pages.

- [Vue App](https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src): frontend host · Vue 3 application shell, router, store, and bootstrap entrypoint. · `iMES.Vue3/src`
- [UI Core](https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/components/basic): shared components · Reusable grid, form, upload, workflow, redirect, and menu components. · `iMES.Vue3/src/components/basic`
- [UI Extensions](https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/extension): generated modules · Module-specific API bindings, page configs, and custom Vue extensions mirrored from backend domains. · `iMES.Vue3/src/extension`
- [Views](https://github.com/zmrid/imes-factory/blob/main/iMES.Vue3/src/views): pages · Renderable screens for system, business modules, dashboards, login, and generated CRUD pages. · `iMES.Vue3/src/views`

### DB

Vendor-specific SQL scripts and schema assets.

- [SQL Scripts](https://github.com/zmrid/imes-factory/tree/main/DB): database scripts · MySQL and SQL Server schema/data scripts for the same domain model. · `DB`

## Connections

- Web API → Core: uses · Controllers and host pipeline depend on shared framework services and abstractions.
- Web API → Entity: maps · API layer passes entity and DTO models through controllers and generated endpoints.
- Web API → System: hosts · System controllers expose admin/auth/workflow APIs.
- Web API → Custom: hosts · Custom domain controllers expose process and master-data APIs.
- Web API → Calendar: hosts · Calendar controllers expose planning APIs.
- Web API → Warehouse: hosts · Warehouse controllers expose stock and bill APIs.
- Web API → Quality: hosts · Quality controllers expose inspection APIs.
- Web API → Equip: hosts · Equipment controllers expose maintenance APIs.
- Web API → Tools: hosts · Tools controllers expose circulation APIs.
- Web API → Report: hosts · Report controllers expose projection endpoints.
- Builder → Web API: generates · Generator writes backend controllers, repositories, services, and templates.
- Builder → UI Extensions: generates · Generator emits frontend extension metadata and page artifacts.
- Entity → SQL Scripts: mirrors · Entity model is intended to fit vendor-specific relational schemas.
- Core → SQL Scripts: configures · DB helpers and configuration select database type and connections.
- Core → Entity: bases on · Shared base entity and mapping infrastructure support domain models.
- Vue App → UI Core: composes · Application shell renders reusable UI primitives.
- Vue App → UI Extensions: loads · Routes and page definitions are assembled from generated extensions.
- UI Extensions → Views: feeds · Module extensions connect metadata to concrete pages.
- Views → Web API: calls · Pages invoke REST endpoints and SignalR-facing features.
- Web API → Generated Files: stores · Generated outputs, exports, and upload artifacts live in the web root.
