# virtocommerce/vc-module-catalog architecture

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

- Interactive diagram: https://gitdiagram.com/virtocommerce/vc-module-catalog
- Repository: https://github.com/virtocommerce/vc-module-catalog

## Overview

This project is the Catalog Module from Virto Commerce – a component within an e-commerce platform concerned with managing product catalogs, categories, and related functionalities. Its purpose is to provide robust catalog management (with support for master/virtual catalogs, multi-language, multi-currency, SEO, and more) to serve as a backbone for an online store’s product organization.

##### Main Architectural Layers and Components
- Web/API Layer: Represented by the “VirtoCommerce.CatalogModule.Web” directory. This layer contains the controllers (API endpoints), localization files, client-side scripts (views and Angular/JavaScript components), and presentation logic for managing catalogs.
- Core/Domain Layer: Found under “VirtoCommerce.CatalogModule.Core”, this holds the domain models, business rules, events, extensions, and interfaces that encapsulate the catalog’s core logic. This layer adheres to Domain-Driven Design (DDD) principles.
- Data Access Layer: The “VirtoCommerce.CatalogModule.Data” directories (with subdirectories for MySQL, PostgreSQL, SQLServer) contain migrations, repositories, EF DbContext configurations, caching mechanisms, and implementation of data access patterns. They abstract the underlying persistence details.
- Bulk Actions Module: The “VirtoCommerce.CatalogModule.BulkActions” directory encapsulates operations for bulk updates, category changes, and mass property updates. This can be seen as a specialized domain service supporting transactional operations.
- Integration & Support Services: Elements like caching, event handlers, export/import functionality, and search/indexing reside across both the Data and Core layers. Event handlers in the “Handlers” subdirectories respond to changes (such as CatalogChangedEvent or ProductChangedEvent) propagating actions like indexing, synchronization, or logging.
- Testing Infrastructure: The “tests” directory hosts unit tests targeting many of these components to ensure functionality and regression protection.
- Deployment & Configuration: Files in “.github”, “.deployment”, and related configuration/build scripts support CI/CD pipelines, ensuring proper integration, testing, and deployment to various environments.

##### Relationships & Data Flow
- The Web/API layer interfaces directly with client applications (admin dashboards or GraphQL APIs) and calls services provided by the Core/Domain layer.
- The Core layer encapsulates business logic and communicates with the Data Access layer via repository interfaces to fetch and persist catalog information.
- The Data Access layer is responsible for interacting with the database; it includes specific implementations for multiple database systems, making use of EF migrations and context factories.
- Bulk Actions orchestrate batch operations and call into both the Core and Data layers to process and validate mass operations.
- Eventing and caching (spread across Core and Data) use events (for example, CatalogChangedEvent, ProductChangingEvent) to trigger domain notifications and update search indexes, ensuring responsiveness across the system.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clear separation between UI (web), business logic (core), and persistence/data access.
- Domain-Driven Design: The “Core” directory includes domain models, value objects, events, and aggregate roots.
- Repository Pattern: The Data layer implements repositories and raw command classes abstracting the storage mechanism.
- Event-Driven Approach: Multiple “Event” and “EventHandler” components manage domain change notifications, coupling domain events with indexing and caching.
- Modular Design: Each module (Core, Data, BulkActions, Web) is self-contained, promoting high cohesion and low coupling.

##### Technologies, Frameworks, and Tools
- .NET and C#: Indicated by the C# project files (.csproj) in all layers.
- Entity Framework (or similar ORM) for data migrations and database interactions.
- CI/CD workflows defined in “.github/workflows” for automated testing, deployment, and NuGet package publication.
- JavaScript/Angular components within the Web layer for client-side interaction.
- Multi-database support is provided through separate Data projects (SQL Server, MySQL, PostgreSQL).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Application Layers
    subgraph "Application Layers"
        Web["CatalogModule.Web (API/UI Layer)"]:::web
        Core["CatalogModule.Core (Domain Layer)"]:::core
        Web -->|"calls"| Core
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Data["CatalogModule.Data (Persistence Layer)"]:::data
        MySQL["MySQL Adapter"]:::data
        PostgreSQL["PostgreSQL Adapter"]:::data
        SQLServer["SQL Server Adapter"]:::data
        Data --> MySQL
        Data --> PostgreSQL
        Data --> SQLServer
        Core -->|"repository-calls"| Data
    end

    %% Batch Operations
    subgraph "Batch Operations"
        Bulk["CatalogModule.BulkActions (Batch Processing)"]:::bulk
    end
    Bulk -->|"calls"| Core
    Bulk -->|"calls"| Data

    %% Integration & Support
    subgraph "Integration & Support"
        Integration["Integration & Support (EventHandlers,Caching)"]:::integration
    end
    Core -->|"triggers-events"| Integration

    %% Support
    subgraph "Support"
        Testing["Testing Infrastructure"]:::testing
        Deployment1["Deployment (.github)"]:::deployment
        Deployment2["Deployment (.deployment)"]:::deployment
    end

    %% Click Events
    click Web "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Web"
    click Core "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Core"
    click Data "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Data"
    click MySQL "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Data.MySql"
    click PostgreSQL "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Data.PostgreSql"
    click SQLServer "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.Data.SqlServer"
    click Bulk "https://github.com/virtocommerce/vc-module-catalog/blob/dev/src/VirtoCommerce.CatalogModule.BulkActions"
    click Integration "https://github.com/virtocommerce/vc-module-catalog/tree/dev/src/VirtoCommerce.CatalogModule.Data/Handlers"
    click Testing "https://github.com/virtocommerce/vc-module-catalog/tree/dev/tests"
    click Deployment1 "https://github.com/virtocommerce/vc-module-catalog/blob/dev/.github"
    click Deployment2 "https://github.com/virtocommerce/vc-module-catalog/blob/dev/.deployment"

    %% Styles
    classDef web fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef data fill:#abebc6,stroke:#239b56,stroke-width:2px;
    classDef bulk fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef integration fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
    classDef testing fill:#f9e79f,stroke:#d68910,stroke-width:2px;
    classDef deployment fill:#fadbd8,stroke:#a93226,stroke-width:2px;
```
