# entropy-cloud/nop-app-mall architecture

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

- Interactive diagram: https://gitdiagram.com/entropy-cloud/nop-app-mall
- Repository: https://github.com/entropy-cloud/nop-app-mall

## Overview

##### Project Type and Purpose
- This is a full‑stack, multi‑module Java sample application (“app‑mall”) demonstrating the Nop platform’s development flow.
- It includes a code‑generation step driven by an Excel data model, a layered backend (API, DAO, Service), a Quarkus-based application runner, plus two frontends: a browser UI (app‑mall‑web) and a WeChat mini‑app client (app‑mall‑wx).

##### File Structure
- Top‑level modules (Maven sub‑projects):
- app‑mall-api: Service interfaces (Java beans, REST contracts)
- app‑mall-codegen: Reads model/app‑mall.orm.xlsx, generates boilerplate DAO/Service code
- app‑mall-dao: Data access layer (entities, mappers, SQL templates)
- app‑mall-service: Business logic layer (BizModel classes, service implementations)
- app‑mall-app: Quarkus application runner (packs API + Service + DAO into a JAR, supports native image)
- app‑mall-web: Front‑end web UI (XJS, XML views, YAML page metadata)
- app‑mall-wx: WeChat mini‑app client integration
- app‑mall-delta & app‑mall-meta: Plugins/extensions to support dynamic model deltas and metadata for codegen
- deploy/: auto‑generated database DDL scripts for MySQL, Oracle, PostgreSQL
- Helpers & scripts: run‑dev.sh, build.sh, codegen.sh, reverse‑db.sh, nop-cli.jar (CLI codegen tool)
- model/: Excel and PDM files define the canonical data model.

##### Key Insights from README
- Code‑gen driven by Excel model → generates DAO/Service code at build-time.
- Layers reflect classical “API → Service → DAO → Database” separation.
- Frontend communicates over HTTP to the REST API exposed by app‑mall-app.
- Nop‑entropy (external platform) dependency provides underlying runtime and code‑generation support.

a. Main Components:
- Data Model (Excel, PDM)
- Code Generation Tool (nop-cli.jar + app‑mall-codegen)
- API Layer (app‑mall‑api)
- Service Layer (app‑mall‑service)
- DAO Layer (app‑mall‑dao)
- Application Runner (Quarkus‑based app‑mall‑app)
- Frontends: Web UI (app‑mall‑web), WeChat Mini‑app (app‑mall‑wx)
- Database(s): MySQL/PostgreSQL/Oracle (deploy scripts)
- External Platform: Nop‑Entropy runtime

b. Data Flows & Interactions:
1. Developer updates model/app‑mall.orm.xlsx → runs codegen.sh → app‑mall-codegen (using nop-cli.jar) outputs new DAO & BizModel classes.
2. Maven build compiles modules; app‑mall-app packages API, Service, DAO as a RESTful microservice.
3. At runtime, client (browser or WeChat) sends HTTP requests → Quarkus REST endpoints (app‑mall-api) → Service implementations (app‑mall-service) → DAO mappers (app‑mall‑dao) → SQL → DB.
4. DB returns data → mapped to entities → BizModel → DTOs → JSON → client.

c. Architectural Patterns & Principles:
- Layered architecture (API / Service / DAO / DB)
- Code‑first data model (Excel → codegen → typed entities)
- Convention‑over‑configuration via Nop platform’s VFS and bean XMLs
- Micro‑kernel extensibility (delta & meta modules plug new data models)
- Quarkus for native‑image support and fast startup

d. Key Technologies & Frameworks:
- Java 17, Maven multi‑module
- Quarkus (app‑mall-app)
- Nop‑Entropy CLI & VFS framework
- MyBatis or custom mapper (app‑mall‑dao)
- XML / YAML page definitions + XJS (app‑mall‑web)
- WeChat SDK (app‑mall‑wx)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build-Time Layer
    subgraph "Build-Time" 
        direction TB
        DM["Data Model\n(Excel/PDM)"]:::build
        CG["Code Generation Tool"]:::build
        DM -->|reads model| CG
        CG -->|generates DAO & BizModel| DAO
        CG -->|generates Service Interfaces| API
        click DM "https://github.com/entropy-cloud/nop-app-mall/blob/master/model/app-mall.orm.xlsx"
        click DM "https://github.com/entropy-cloud/nop-app-mall/blob/master/model/app-mall.api.xlsx"
        click DM "https://github.com/entropy-cloud/nop-app-mall/blob/master/model/nop-auth-delta.orm.xlsx"
        click DM "https://github.com/entropy-cloud/nop-app-mall/blob/master/model/test.pdm"
        click DM "https://github.com/entropy-cloud/nop-app-mall/blob/master/model/test.pdma.json"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-codegen/pom.xml"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-codegen/postcompile/gen-orm.xgen"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-codegen/src/test/java/app/mall/codegen/AppMallCodeGen.java"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/nop-cli.jar"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/codegen.sh"
        click CG "https://github.com/entropy-cloud/nop-app-mall/blob/master/codegen.bat"
    end

    %% Runtime Backend Layer
    subgraph "Backend Runtime" 
        direction TB
        App["Quarkus Runner\n(app-mall-app)"]:::runtime
        API["API Layer\n(app-mall-api)"]:::runtime
        SRV["Service Layer\n(app-mall-service)"]:::runtime
        DAO["DAO Layer\n(app-mall-dao)"]:::runtime
        App -->|hosts REST API| API
        API -->|invokes| SRV
        SRV -->|calls| DAO
        click App "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-app/pom.xml"
        click App "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-app/src/main/java/app/mall/app/AppMallApplication.java"
        click App "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-app/src/main/resources/application.yaml"
        click App "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-app/src/main/resources/bootstrap.yaml"
        click App "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-app/src/main/resources/META-INF/native-image"
        click App "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-app/src/main/resources/_vfs"
        click API "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-api/pom.xml"
        click API "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-api/src/main/java/app/mall/pay/PayService.java"
        click API "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-api/src/main/java/app/mall/pay/PayRefundRequestBean.java"
        click API "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-api/src/main/java/app/mall/pay/PayRefundResponseBean.java"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/pom.xml"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/src/main/java/app/mall/service/AppMallConfigs.java"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/src/main/java/app/mall/service/AppMallConstants.java"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/src/main/java/app/mall/service/AppMallErrors.java"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-service/src/main/java/app/mall/service/entity"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/src/main/resources/_vfs/app/mall/beans/_service.beans.xml"
        click SRV "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-service/src/main/resources/_vfs/app/mall/beans/app-service.beans.xml"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-dao/pom.xml"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-dao/src/main/java/app/mall/dao/AppMallDaoConstants.java"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-dao/src/main/java/app/mall/dao/entity"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-dao/src/main/java/app/mall/dao/mapper"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-dao/src/main/resources/_vfs/app/mall/beans/_dao.beans.xml"
        click DAO "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-dao/src/main/resources/_vfs/app/mall/orm/app.orm.xml"
    end

    %% Persistence Layer
    subgraph "Persistence" 
        direction TB
        DB["Database\n(MySQL/PostgreSQL/Oracle)"]:::db
        DAO -->|executes SQL| DB
        click DB "https://github.com/entropy-cloud/nop-app-mall/blob/master/deploy/sql/mysql/_create_app-mall.sql"
        click DB "https://github.com/entropy-cloud/nop-app-mall/blob/master/deploy/sql/mysql/litemall_data.sql"
        click DB "https://github.com/entropy-cloud/nop-app-mall/blob/master/deploy/sql/oracle/_create_app-mall.sql"
        click DB "https://github.com/entropy-cloud/nop-app-mall/blob/master/deploy/sql/postgresql/_create_app-mall.sql"
    end

    %% Extensions
    subgraph "Extensions" 
        direction TB
        Delta["Delta Extensions\n(app-mall-delta)"]:::ext
        Meta["Meta Extensions\n(app-mall-meta)"]:::ext
        click Delta "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-delta/pom.xml"
        click Delta "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-delta/src/main/java/app/mall/delta"
        click Delta "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-delta/src/main/resources/_vfs/_delta/default/nop/auth"
        click Meta "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-meta/pom.xml"
        click Meta "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-meta/_templates"
        click Meta "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-meta/src/main/resources/_vfs/app/mall/model"
    end

    %% Frontend Layer
    subgraph "Frontends" 
        direction TB
        Web["Web UI\n(app-mall-web)"]:::frontend
        WX["WeChat Mini-app\n(app-mall-wx)"]:::frontend
        Web -->|HTTP REST| App
        WX -->|HTTP REST| App
        click Web "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-web/pom.xml"
        click Web "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-web/precompile/gen-page.xgen"
        click Web "https://github.com/entropy-cloud/nop-app-mall/tree/master/app-mall-web/src/main/resources/_vfs/app/mall/pages"
        click Web "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-web/src/main/resources/_vfs/app/mall/auth/app-mall.action-auth.xml"
        click WX "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-wx/pom.xml"
        click WX "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-wx/src/main/java/app/mall/wx/WxPayServiceImpl.java"
        click WX "https://github.com/entropy-cloud/nop-app-mall/blob/master/app-mall-wx/src/main/resources/_vfs/app/mall/beans/app-wx.beans.xml"
    end

    %% External Platform
    NE["Nop-Entropy Platform"]:::external
    NE --> CG
    NE --> App

    %% Styles
    classDef build fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef runtime fill:#C8E6C9,stroke:#388E3C,color:#1B5E20;
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef frontend fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef ext fill:#EEEEEE,stroke:#9E9E9E,color:#424242;
    classDef external fill:#FFCDD2,stroke:#E53935,color:#B71C1C;
```
