How getdokan/dokan works
Major subsystems/components
• WordPress Plugin Core – The entry point (dokan.php, dokan-class.php) and the overall “glue” that integrates with WordPress and WooCommerce.
• PHP Backend & Business Logic – Organized into “includes”, “deprecated” (legacy code), and “lib” directories. This section hosts most of the core functionalities:
• Abstract classes and core controllers (for REST endpoints, dependency management, upgrade processes, etc.).
• Specific modules for commission calculations, vendor management, orders, withdrawals, emails, and reports. For instance, the various “includes/Commission”, “includes/Vendor”, “includes/Order”, “includes/Withdraw”, and “includes/REST” directories show a separation of responsibilities.
• Utility classes, cache management, dependency container (using League’s Container), and service providers offering dependency injection.
• UI Components – Divided by frontend and admin:
• Frontend UI: Under “src/frontend”, there is another Vue application that invokes vendor dashboard and store-front interactions.
• Templates: The “templates” directory holds PHP template files to render various parts of the plugin’s user interface. This includes account pages, admin pages, emails (both HTML and plain versions), and widgets.
• REST API & AJAX Endpoints – The “includes/REST” directory encapsulates various controllers that expose endpoints for admin, vendor, and customer interactions. Additionally, “includes/Ajax.php” and similar hooks let the plugin interact asynchronously.
• External Integrations & Modules – The README lists many integrations (payment gateways, shipping, Stripe, etc.) and additional modules. Elements like “includes/Emails”, “includes/Analytics”, and configuration files indicate that the plugin communicates with multiple external services and maintains compliance with standards enforced by WooCommerce.
Relationships & data flow between these components
• WordPress Core calls the Dokan plugin’s main file which then loads the PHP backend components (controllers, hooks, dependency injection container).
• The backend components execute business logic (handling commission calculations, vendor registrations, order processing, and so on) and expose REST endpoints.
• The UI layer (both admin and frontend Vue apps) communicates with these backend controllers via AJAX calls or REST API endpoints.
• Template files act as the glue between WordPress’s theming system and Dokan’s PHP output, ensuring that vendor dashboards, email templates, and various UI elements are correctly rendered.
• External integrations (payment gateways, shipping apps, analytics tools) are managed here as either separate modules or injected into the dependency container.
• The testing suite validates both backend (PHP unit tests under tests/php) and frontend (Playwright, API tests under tests/pw) components, ensuring robust interactions.
Notable architectural patterns & design principles
• Modular Design – The project is broken into many discrete modules (commissions, orders, vendor management, REST APIs, etc.) to keep responsibilities isolated.
• Dependency Injection – Use of League’s Container and service provider patterns can be shown to emphasize loose coupling and extendability.
• MV* Patterns in UI – The separation between Vue components (view layer) for admin and frontend applications and their corresponding business logic.
• WordPress Hooks – Since it’s a WordPress plugin, actions and filters are central to how components interact.
• Layering – The separation between frontend (templates and Vue apps), middle layer (REST API controllers and backend business logic) and external modules/integrations.
Final advice
• Start at a high level by visualizing the entire plugin as an integration layer that transforms a standard WooCommerce installation into a multivendor marketplace.
• Drill down to show the layered architecture: from WordPress hooks (entry points) to backend modules (business logic, REST APIs, dependency management), and then to the user-facing components (admin dashboards, vendor storefronts, email templates).
• Use annotations to highlight key design patterns (e.g., dependency injection, modular separation, MVC/MVVM in the Vue apps) that are critical for understanding the architecture.