# longhuu100/open-cdp-backend architecture

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

- Interactive diagram: https://gitdiagram.com/longhuu100/open-cdp-backend
- Repository: https://github.com/longhuu100/open-cdp-backend

## Overview

##### Project Type & Purpose
- This project is the backend service (“Open-Cdp-Backend”) for an enterprise application that integrates multiple subsystems. The README lists separate modules for Marketing, Sales, Production, Warehouse, and Customer Care, meaning it must process a variety of business workflows and data interactions.
- The system is built in Java (as seen in the “src/main/java” folder structure) and deployed as a single deployable JAR via Maven (pom.xml gives build details).

##### Key Components
a. Application Entry Point and Configuration:
– Represent the main startup class (CdpStart.java) as the entry point.
– Include configuration components such as “HibernateConfiguration”, “ResourceConfig”, “ConfigUtil”, and the external configuration files (application.properties, custom.properties, log4j2.xml) to indicate how properties and logging are managed.
b. Web Layer / Controllers:
– Indicate exception handling (ExceptionController & WebException) and the base controller that might share common request processing logic.
c. Service/Business Logic Layer:
d. Data Access / DAO / Repositories:
e. Domain Models / Entities Layer:
– Illustrate that the model layer contains the entity classes representing business objects (e.g., CustomerOrder, Product, Warehouse, User, etc.). These entities are used across DAO/repositories and service layers.
f. Security & Authentication:
– Include authentication components (JwtAuthTokenFilter, JwtProvider, SecurityConfiguration, custom authentication entry points) as a distinct component that secures the application.
g. Utility & Support Modules:
– Represent common utilities (date, JSON, SQL Builder, file uploads, etc.) as support services that are used across the application.
h. Orchestration / Messaging:
– The “orchestration” package is a key functional module providing PubSub capabilities (e.g., EventCenter, Publisher, Subscriber, Message), which may coordinate events internally or with external systems.
i. External Dependencies:
– Show the “public” directory for static files and email templates (templates for invoices and order notes) used for user notifications or reporting.
– Consider external APIs or other third-party integrations if needed (based on the nature of modules like marketing or customer service).

##### Architectural Patterns and Design Principles
– The separation of concerns is evident in the layered architecture: Controllers (presentation), Services (business logic), DAOs/Repositories (data access), and Domain Models.
– It is also apparent that RESTful APIs are likely used (given the controller folders) to interact with client-side applications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    User["User Request"]:::user

    %% Application Startup & Configuration Layer
    subgraph "Application Startup & Config"
        A1["Entry Point: CdpStart.java"]:::startup
        A2["Configuration Classes"]:::config
        A3["External Configuration Files"]:::config_files
    end

    %% Web/API Controllers Layer
    subgraph "Web/API Controllers"
        B1["Domain Controllers"]:::web
        B2["Exception Controller"]:::web
        W2["WebException"]:::web
    end

    %% Business Service Layer
    subgraph "Business Service Layer"
        C1["General Services"]:::service
        C2["Domain-specific Services (Marketting/Customer/Cskh/User)"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        D1["DAOs"]:::data
        D2["Repositories"]:::data
    end

    %% Domain Models Layer
    subgraph "Domain Models"
        E1["Entity Classes"]:::models
        E2["Domain Models"]:::models
    end

    %% Security & Authentication Layer
    subgraph "Security & Authentication"
        F1["JWT Components"]:::security
        F2["Spring Security Config"]:::security
    end

    %% Utility & Support Modules
    subgraph "Utility & Support"
        G1["Utility Modules"]:::utils
        G2["Pagination Support"]:::utils
    end

    %% Orchestration / Messaging
    subgraph "Orchestration / Messaging"
        H1["Event Center & PubSub"]:::orchestration
    end

    %% External Dependencies and Resources
    subgraph "External Dependencies"
        I1["Database"]:::database
        I2["Static Files & Templates"]:::external
    end

    %% Connections
    User -->|"sendsRequest"| B1

    %% Application Startup links
    A1 -->|"initializes"| B1
    A1 -->|"initializes"| C1
    A1 -->|"initializes"| D1
    A2 -->|"providesSettingsFor"| B1
    A2 -->|"providesSettingsFor"| C1
    A2 -->|"providesSettingsFor"| F2
    A3 -->|"loadsPropertiesFor"| A2

    %% Controller Layer connections
    B1 -->|"invokes"| C1
    B1 -->|"invokes"| C2
    B1 -->|"handledBy"| B2
    B2 -->|"delegatesTo"| W2
    B1 -->|"securedBy"| F2

    %% Service Layer connections
    C1 -->|"calls"| D1
    C1 -->|"calls"| D2
    C2 -->|"calls"| D1
    C2 -->|"calls"| D2
    C1 -->|"uses"| E1
    C1 -->|"uses"| E2
    C2 -->|"uses"| E1
    C2 -->|"uses"| E2
    C1 -->|"utilizes"| G1
    C1 -->|"utilizes"| G2
    C2 -->|"utilizes"| G1
    C2 -->|"utilizes"| G2

    %% Data Access connections
    D1 -->|"accesses"| I1
    D2 -->|"accesses"| I1

    %% Orchestration connection
    H1 -->|"broadcastsTo"| C2

    %% External Dependencies connections
    I2 -->|"suppliesAssetsTo"| B1
    I2 -->|"suppliesTemplatesTo"| C2

    %% Security Layer connections
    F1 -->|"secures"| B1
    F2 -->|"secures"| B1

    %% Click Events
    click A1 "https://github.com/longhuu100/open-cdp-backend/blob/master/src/main/java/vn/flast/CdpStart.java"
    click A2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/config"
    click A3 "https://github.com/longhuu100/open-cdp-backend/tree/master/conf/"
    click B1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/controller"
    click B2 "https://github.com/longhuu100/open-cdp-backend/blob/master/src/main/java/vn/flast/controller/excetion/ExceptionController.java"
    click W2 "https://github.com/longhuu100/open-cdp-backend/blob/master/src/main/java/vn/flast/components/WebException.java"
    click C1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/service"
    click C2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/service/marketting"
    click D1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/dao"
    click D2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/repositories"
    click E1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/entities"
    click E2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/models"
    click F1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/jwt"
    click F2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/security"
    click G1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/utils"
    click G2 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/pagination"
    click H1 "https://github.com/longhuu100/open-cdp-backend/tree/master/src/main/java/vn/flast/orchestration"
    click I1 "https://github.com/longhuu100/open-cdp-backend/blob/master/open-service.sql"
    click I2 "https://github.com/longhuu100/open-cdp-backend/tree/master/public/"

    %% Styles
    classDef startup fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef config fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef config_files fill:#ffeb99,stroke:#333,stroke-width:2px;
    classDef web fill:#87cefa,stroke:#333,stroke-width:2px;
    classDef service fill:#98fb98,stroke:#333,stroke-width:2px;
    classDef data fill:#ff7f7f,stroke:#333,stroke-width:2px;
    classDef models fill:#d8bfd8,stroke:#333,stroke-width:2px;
    classDef security fill:#f0e68c,stroke:#333,stroke-width:2px;
    classDef utils fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef orchestration fill:#f5a9a9,stroke:#333,stroke-width:2px;
    classDef database fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef external fill:#6495ed,stroke:#333,stroke-width:2px;
    classDef user fill:#dda0dd,stroke:#333,stroke-width:2px;
```
