# tranduc312/shopizer architecture

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

- Interactive diagram: https://gitdiagram.com/tranduc312/shopizer
- Repository: https://github.com/tranduc312/shopizer

## Overview

##### Project Type & Purpose
- Shopizer is an open-source, headless e-commerce platform implemented as a multi-module Maven project.
- It exposes REST APIs (Spring Boot) for commerce operations (catalog, cart, checkout, etc.).
- It is consumed by separate frontends (Angular admin, React shop), but this repo contains only the Java backend.

##### High-Level Architecture
- sm-core-model – Domain Entities & Value Objects
- sm-core-modules – Pluggable integration modules (payment, shipping, order total, CMS cache)
- sm-core – Business logic layer (services, event configuration, Drools rule engine)
- sm-shop-model – DTOs / API models (mappers between domain and REST representations)
- sm-shop – Presentation layer (Spring Boot controllers, REST APIs, security, configuration)

##### Component Relationships & Data Flow
- User / Client (Angular Admin or React Shop) → HTTP(S) → sm-shop Controllers
- Controllers → (via Mapper) → Service Layer in sm-core
- Services → Business Modules (from sm-core-modules) + Domain Model (sm-core-model)
- Services → Repositories (JPA/Hibernate) → Relational DB (MySQL/H2)
- Some services fire Asynchronous Events → Event Listeners (indexing, cache invalidation)
- Integration modules invoke external systems:
– Payment gateways (Stripe, Braintree, PayPal)
– Shipping providers (UPS, USPS, custom)
– Cloud storage (AWS S3, GCP) for product and content files
– Email services (SES, SMTP)
– Search Engine (Elasticsearch) via mappings in sm-core resources

##### Architectural Patterns & Key Principles
- Layered Architecture:
– Presentation (sm-shop)
– Application Services (sm-core)
– Domain Model (sm-core-model)
– Infrastructure (Repositories, external modules)
- Modular / Plugin Pattern: sm-core-modules provides extension points for payment, shipping, order-total logic.
- Event-Driven Subsystem: Asynchronous event publishing and Drools for business rules.
- Configuration Profiles: Spring profiles for AWS, GCP, local, MySQL, etc.
- CI/CD & Deployment: Dockerfile for sm-shop, CircleCI, Jenkins pipelines, Maven wrapper across all modules.

2. To its right, stack two layers:
– sm-shop-model (DTO / Mapper)
– sm-core (Service Layer, Event Config, Drools)
3. Below sm-core, place sm-core-model (Domain Entities) and sm-core-modules (Plugins) side by side.
4. At the bottom, show “Relational DB (MySQL/H2)” and “Elasticsearch” side by side.
5. On the far right, attach clouds for “Payment Gateway”, “Shipping Provider”, “S3/GCP Storage”, “Email Service”.
– Controllers → mappers → services → domain/modules → repositories → DB
– Services → external modules → external services
– Services → event bus → listeners (e.g., indexing)
– Configuration loading from profiles (annotate Spring Config).
7. Cross-cutting concerns: Security filter chain (JWT, CORS, XSS), Configuration classes, Profile mechanisms.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "sm-shop (Presentation Layer)"
        direction TB
        Controllers["REST Controllers (Spring Boot)"]:::api
        AppConfig["Spring Boot App & Config"]:::internal
        Filters["CORS/XSS Filters"]:::internal
        Security["Admin/Security Handlers"]:::internal
    end

    %% DTO / Mapping Layer
    subgraph "sm-shop-model (DTOs/API Models)"
        direction TB
        DTOs["DTOs / API Models"]:::internal
        Mappers["Mappers"]:::internal
    end

    %% Business Logic Layer
    subgraph "sm-core (Business Logic)"
        direction TB
        Service["Service Layer"]:::internal
        Events["Event Config & Listeners"]:::internal
        Drools["Drools Rule Engine"]:::internal
        CoreConfig["Core App Configuration"]:::internal
    end

    %% Domain Model & Plugin Modules
    subgraph "Domain & Plugins"
        direction LR
        Domain["Domain Model"]:::internal
        Plugins["Modular Plugins"]:::internal
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        Repos["Repositories (JPA/Hibernate)"]:::internal
    end

    %% Databases
    subgraph "Databases"
        direction LR
        RDBMS["Relational DB\n(MySQL/H2)"]:::db
        ES["Elasticsearch"]:::db
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        PG["Payment Gateway"]:::external
        SP["Shipping Provider"]:::external
        CS["Cloud Storage (S3/GCP)"]:::external
        ESvc["Email Service"]:::external
    end

    %% Profiles & CI/CD
    subgraph "Profiles & CI/CD"
        direction TB
        ProfilesCore["Core Profiles"]:::internal
        ProfilesShop["Shop Profiles"]:::internal
        Docker["Dockerfile"]:::internal
        CI["CircleCI Config"]:::internal
        Jenkins["Jenkins Pipeline"]:::internal
    end

    %% Connections
    Controllers -->|calls| DTOs
    DTOs -->|maps| Mappers
    Mappers -->|invokes| Service
    Service -->|uses| Domain
    Service -->|plugins| Plugins
    Service -->|persists| Repos
    Repos -->|stores| RDBMS
    Service -->|indexes| ES
    Service -->|async| Events
    Service -->|rules| Drools
    Service -->|config| CoreConfig
    Service -->|calls| PG
    Service -->|calls| SP
    Service -->|calls| CS
    Service -->|calls| ESvc
    CoreConfig --> ProfilesCore
    AppConfig --> ProfilesShop
    AppConfig --> Docker
    AppConfig --> CI
    AppConfig --> Jenkins

    %% Click Events
    click Domain "https://github.com/tranduc312/shopizer/tree/main/sm-core-model/src/main/java/com/salesmanager/core/model"
    click Plugins "https://github.com/tranduc312/shopizer/tree/main/sm-core-modules/src/main/java/com/salesmanager/core/modules"
    click Service "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/java/com/salesmanager/core/business/services"
    click Events "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/java/com/salesmanager/core/business/configuration/events"
    click Drools "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/resources/com/salesmanager/drools/rules"
    click CoreConfig "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/java/com/salesmanager/core/business/configuration"
    click Repos "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/java/com/salesmanager/core/business/repositories"
    click DTOs "https://github.com/tranduc312/shopizer/tree/main/sm-shop-model/src/main/java/com/salesmanager/shop/model"
    click Controllers "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/java/com/salesmanager/shop/store/api"
    click AppConfig "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/java/com/salesmanager/shop/application"
    click Mappers "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/java/com/salesmanager/shop/mapper"
    click Filters "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/java/com/salesmanager/shop/filter"
    click Security "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/java/com/salesmanager/shop/admin/security"
    click ProfilesCore "https://github.com/tranduc312/shopizer/tree/main/sm-core/src/main/resources/profiles"
    click ProfilesShop "https://github.com/tranduc312/shopizer/tree/main/sm-shop/src/main/resources/profiles"
    click Docker "https://github.com/tranduc312/shopizer/tree/main/sm-shop/Dockerfile"
    click CI "https://github.com/tranduc312/shopizer/blob/main/.circleci/config.yml"
    click Jenkins "https://github.com/tranduc312/shopizer/tree/main/Jenkinsfile"

    %% Styles
    classDef internal fill:#DAE8FC,stroke:#6C8EBF,color:#000000
    classDef api fill:#E1D5E7,stroke:#9673A6,color:#000000
    classDef db fill:#D5E8D4,stroke:#82B366,color:#000000
    classDef external fill:#F8CECC,stroke:#B85450,color:#000000
```
