How virtocommerce/vc-module-catalog works
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).