# jjconsulting/jjmasterdata architecture

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

- Interactive diagram: https://gitdiagram.com/jjconsulting/jjmasterdata
- Repository: https://github.com/jjconsulting/jjmasterdata

## Overview

##### Main Components
- Frontend/UI Layer: Represented by the “src/Web” project. This includes Razor views, Components, TagHelpers, styles, and scripts. The “example/WebEntryPoint” gives an idea of a sample integration.
- API Layer: Represented by “src/WebApi.” This layer exposes REST endpoints (Controllers, Data transfer models, Swagger configuration) to interact with the dynamic CRUD functionalities.
- Core Library Layer: In “src/Core” (and portions of “src/Commons”) you have essential logic for data management. This contains:
– Data Dictionary handling (models, repository interfaces, structure)
– Data Manager functions for data exportation, importation, and business rules
– Logging, security, and utility services that support cross-cutting concerns
– UI Components that are built at runtime (the dynamic generation of components)
- Plugin Ecosystem: Contained in “src/Plugins” (with subdirectories like Brasil, Hangfire, MongoDB, Pdf, and Python). These modules extend the base functionality through well-defined plugin interfaces.
- Console Applications: Found under “src/ConsoleApps,” which include migrators and schema generators to support tasks such as metadata migration or exporting schemas.
- Configuration and Integration: The application-level configuration is provided in files such as “appsettings.json,” and the integration into an ASP.NET Core project is handled by extension methods (for instance, builder.Services.AddJJMasterDataWeb()) as shown in README.
- Documentation/Tests: The “doc” folder contains documentation (including build instructions and API docs), while the “test” folder organizes unit and integration tests across different layers.

##### Relationships and Interactions
- The frontend (Web) interacts with the Core via controllers (in both the Web and WebApi projects), which then work with the Core services (data dictionary, data manager, etc.).
- The Core layer relies on the “Commons” for lower-level utilities like data access, logging, security (encryption, hashing), and configuration.
- The Plugin infrastructure is invoked through extension methods and clearly defined interfaces, allowing the base functionality to be extended by third-party modules (e.g., Hangfire for background processing, MongoDB for alternative repository implementations).
- The console apps provide scripts and background processing tools that can be executed separately to migrate data or generate database schemas.
- The configuration (from appsettings.json and jjmasterdata.json) is propagated throughout the layers via dependency injection.

##### Architectural Patterns and Design Principles
- Layered Architecture: The system cleanly separates presentation (Web/UI/API), business core (data dictionary, data manager, services), and plugin extensibility.
- Dependency Injection and Extension Methods: Startup configuration in Program.cs demonstrates dependency injection. There’s extensive use of service collection extensions (in many “ServiceCollectionExtensions.cs” files).
- Plugin Pattern: The Plugins folder is designed to allow for easier extension of functionality through interface-based plugin actions (e.g., in “src/Plugins/Brasil” and “src/Plugins/Hangfire”).
- Modular Design: The solution is divided into multiple projects (Core, Commons, Web, WebApi, Plugins, ConsoleApps) that encapsulate specific responsibilities.

##### Relevant Technologies/Frameworks to be Noted
- .NET 8 (or .NET 5/6 in older instructions) as the primary framework.
- ASP.NET Core for the Web and API projects, using Razor, MVC, and potentially Blazor.
- TypeScript commands and NodeJS for managing front-end assets (as seen in “src/Web” with npm and tsconfig.json).
- SQL Server is the primary database system used (as indicated by the connection string examples), although alternative data providers are supported via plugins.
- NuGet package management for dependency distribution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["JJMasterData Web (UI)"]
        API["JJMasterData API"]
    end

    %% Business/Core Layer
    subgraph "Business/Core Layer"
        CORE["JJMasterData Core Library"]
        COMMONS["Commons Utilities"]
    end

    %% Plugin Ecosystem
    subgraph "Plugin Ecosystem"
        PLUGINS["Plugins Ecosystem"]
        BRA["Brasil Plugin"]
        HANG["Hangfire Plugin"]
        MONGO["MongoDB Plugin"]
        PDF["Pdf Plugin"]
        PYTHON["Python Plugin"]
    end

    %% Auxiliary/Console Apps
    subgraph "Auxiliary/Console Apps"
        CONSOLE["JJMasterData Console Apps"]
    end

    %% Configuration & Integration
    subgraph "Configuration & Integration"
        APPSET["appsettings.json"]
        JJM["jjmasterdata.json"]
        WEBCONF["Web Configuration"]
        CORECONF["Core Configuration"]
    end

    %% Documentation & Tests
    subgraph "Documentation & Tests"
        DOC["Documentation (doc)"]
        TEST["Tests (test)"]
    end

    %% Relationships and Data Flow
    UI -->|"calls"| CORE
    API -->|"calls"| CORE
    CORE -->|"uses"| COMMONS
    CORE <==>|"plugin_interface"| PLUGINS
    CONSOLE -->|"schema/migration"| CORE
    APPSET -->|"configures"| CORE
    JJM -->|"configures"| CORE
    WEBCONF -->|"configures"| CORE
    CORECONF -->|"configures"| CORE

    %% Click Events for Component Mapping
    click UI "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Web"
    click API "https://github.com/jjconsulting/jjmasterdata/tree/main/src/WebApi"
    click CORE "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Core"
    click COMMONS "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Commons"
    click PLUGINS "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins"
    click BRA "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins/Brasil"
    click HANG "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins/Hangfire"
    click MONGO "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins/MongoDB"
    click PDF "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins/Pdf"
    click PYTHON "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Plugins/Python"
    click CONSOLE "https://github.com/jjconsulting/jjmasterdata/tree/main/src/ConsoleApps"
    click APPSET "https://github.com/jjconsulting/jjmasterdata/blob/main/appsettings.json"
    click JJM "https://github.com/jjconsulting/jjmasterdata/blob/main/jjmasterdata.json"
    click WEBCONF "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Web/Configuration"
    click CORECONF "https://github.com/jjconsulting/jjmasterdata/tree/main/src/Core/Configuration"
    click DOC "https://github.com/jjconsulting/jjmasterdata/tree/main/doc"
    click TEST "https://github.com/jjconsulting/jjmasterdata/tree/main/test"

    %% Styling Classes
    classDef frontend fill:#fce4ec,stroke:#ec407a,stroke-width:2px;
    classDef api fill:#e1f5fe,stroke:#039be5,stroke-width:2px;
    classDef core fill:#e8f5e9,stroke:#43a047,stroke-width:2px;
    classDef plugin fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
    classDef console fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef config fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px;
    classDef doc fill:#fbe9e7,stroke:#d84315,stroke-width:2px;

    %% Assigning Node Classes
    class UI frontend;
    class API api;
    class CORE,COMMONS core;
    class PLUGINS,BRA,HANG,MONGO,PDF,PYTHON plugin;
    class CONSOLE console;
    class APPSET,JJM,WEBCONF,CORECONF config;
    class DOC,TEST doc;
```
