# webvella/webvella-erp architecture

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

- Interactive diagram: https://gitdiagram.com/webvella/webvella-erp
- Repository: https://github.com/webvella/webvella-erp

## Overview

This project is a robust, open-source ERP system designed for extreme customization and plugability. It is built in ASP.NET Core 7 and primarily targets PostgreSQL as its database. The purpose of the project is to manage a wide array of business data and processes via a modular, extensible architecture. Its components are organized into a core ERP system, numerous plugins (such as CRM, Mail, MicrosoftCDM, Project, Next, and SDK), several site and web interface projects (including web, site, and even WebAssembly client/server applications), and support for console-based utilities and background jobs.

##### Main Components Identification
- Core ERP Kernel – Representing the central business logic and services (found in the “WebVella.Erp” folder). This includes fundamental APIs, entity management, hook managers, job/process managers, utilities (like authentication, logging, and security), and data access repositories.
- Plugins Layer – A modular collection of additional business functionality. Each plugin (CRM, Mail, MicrosoftCDM, Next, Project, SDK, etc.) is its own project/component that depends on the core ERP kernel while adding or overriding specific functionality.
- Presentation/UI Layer – Several web frontends are implemented:
- ASP.NET Core based sites and web projects (e.g., “WebVella.Erp.Site”, “WebVella.Erp.Web”) that serve the primary user interface using Razor Views, controllers, and tag helpers.
- A WebAssembly client–server pair that provides a modern, client-side SPA experience.
- Console Application – A separate project for tasks such as initialization, maintenance, or background operations.
- Background Jobs and Middleware – Components that handle scheduled tasks, error handling, security concerns, and other cross-cutting concerns.
- Database Layer – Although not directly part of the code tree, annotate the PostgreSQL database as the persistence layer supporting the system.

##### Relationships and Interactions
- The Core ERP Kernel is at the center of the system; the Plugins register and interact with this core through well-defined hooks and APIs.
- The Presentation/UI Layer interacts with the Core ERP Kernel through API controllers and service calls, leveraging middleware (e.g., authentication, error handling) to manage requests.
- The background jobs subsystem asynchronously processes tasks; this part interacts with the core services and sometimes with plugins.
- Data access components (repository classes, data source managers) sit between the core logic and the PostgreSQL database.
- The WebAssembly projects feature a client (browser) and server integration that communicates with the API and core system via custom services.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate the system into presentation, business, plugin, and data layers.
- Modular/Plugin Architecture: Emphasize the extensibility points (hooks, service interfaces) where plugins register with and extend core functionality.
- Dependency Injection and Middleware: Components such as controllers, repositories, and job managers use dependency injection provided by ASP.NET Core.
- Event-based and Hook-Driven Processing: Detail the hook managers and event-driven modules where different actions (record creation, update, deletion, etc.) have extensibility points.

##### Relevant Technologies and Frameworks
- ASP.NET Core 7 for the core framework.
- PostgreSQL as the database.
- Razor Views, Controllers, and TagHelpers for the web front end.
- WebAssembly for the client-side SPA module.
- C# and .NET libraries.
- Build, deployment, and configuration files (such as JSON config files) that govern the environment setup.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation/UI Layer
    subgraph "Presentation/UI Layer"
        UI1["ASP.NET Core Site"] 
        UI2["ASP.NET Core Web"]
        UI3["WebAssembly Client/Server"]
    end

    %% Core ERP Layer
    subgraph "Core ERP Layer"
        ERP["ERP Core"]
    end

    %% Plugins Layer
    subgraph "Plugins Layer"
        P1["CRM Plugin"]
        P2["Mail Plugin"]
        P3["MicrosoftCDM Plugin"]
        P4["Next Plugin"]
        P5["Project Plugin"]
        P6["SDK Plugin"]
    end

    %% Console & Background Layer
    subgraph "Console & Background Layer"
        Console["Console App"]
        subgraph "Background Jobs & Middleware"
            BM1["Mail Jobs"]
            BM2["Project Jobs"]
            BM3["Core Middleware"]
            BM4["Core Jobs"]
        end
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["PostgreSQL Database"]
    end

    %% Connections from UI Layer to Core ERP via Middleware
    UI1 -->|"API_call"| BM3
    UI2 -->|"API_call"| BM3
    UI3 -->|"API_call"| BM3
    BM3 -->|"forwards"| ERP

    %% Console App calls ERP Core
    Console -->|"maintenance_call"| ERP

    %% ERP Core connects to Plugins (Plugins register hooks with Core)
    P1 -->|"hooks"| ERP
    P2 -->|"hooks"| ERP
    P3 -->|"hooks"| ERP
    P4 -->|"hooks"| ERP
    P5 -->|"hooks"| ERP
    P6 -->|"hooks"| ERP

    %% ERP Core uses Data Access to communicate with Database
    ERP -->|"data_access"| DB

    %% Background Jobs relation with Plugins and Core
    P2 -->|"job_trigger"| BM1
    P5 -->|"job_trigger"| BM2
    ERP -->|"schedules"| BM4

    %% Styling
    classDef ui fill:#f4f0ff,stroke:#4b0082,stroke-width:2px;
    classDef core fill:#d0e8ff,stroke:#00509e,stroke-width:2px;
    classDef plugin fill:#e0ffe0,stroke:#228b22,stroke-width:2px;
    classDef console fill:#fff0e0,stroke:#d2691e,stroke-width:2px;
    classDef db fill:#e6f9ff,stroke:#008b8b,stroke-width:2px;

    class UI1,UI2,UI3 ui;
    class ERP core;
    class P1,P2,P3,P4,P5,P6 plugin;
    class Console,BM1,BM2,BM3,BM4 console;
    class DB db;

    %% Click Events
    click ERP "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp"
    click P1 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.Crm"
    click P2 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.Mail"
    click P3 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.MicrosoftCDM"
    click P4 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.Next"
    click P5 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.Project"
    click P6 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Plugins.SDK"
    click UI1 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Site"
    click UI2 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.Web"
    click UI3 "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.WebAssembly"
    click Console "https://github.com/webvella/webvella-erp/blob/master/WebVella.Erp.ConsoleApp"
    click BM1 "https://github.com/webvella/webvella-erp/tree/master/WebVella.Erp.Plugins.Mail/Jobs"
    click BM2 "https://github.com/webvella/webvella-erp/tree/master/WebVella.Erp.Plugins.Project/Jobs"
    click BM3 "https://github.com/webvella/webvella-erp/tree/master/WebVella.Erp.Web/Middleware"
    click BM4 "https://github.com/webvella/webvella-erp/tree/master/WebVella.Erp/Jobs"
    click DB "https://github.com/webvella/webvella-erp/tree/master/WebVella.Erp/Database"
```
