# qianxingchuan/doraemon architecture

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

- Interactive diagram: https://gitdiagram.com/qianxingchuan/doraemon
- Repository: https://github.com/qianxingchuan/doraemon

## Overview

##### Main Architectural Components
- Core Framework: Represented by the “asgard-doraemon” module. It provides the essential classes such as AsgardBundle, AsgardClassLoader, BundleConfiguration, and the main entry (RunDoraemonBundle). This is where the bundle lifecycle management is implemented.
- Bundle Interface/Service: The “doraemon-facade” defines the BundleService interface which every bundle must implement. This is core to keeping the plugin system loosely coupled.
- Bundle Project Archetype: “doraemon-project-archetype” offers the basic skeleton and structure for new bundles. It includes configuration (like bundle.properties) that details the init-class and skip-class settings.
- Sample Bundles and Projects: In “doraemon-sample”, you have sample implementations (e.g., sample-auth-bundle1, sample-auth-bundle2) that demonstrate different implementations of an authentication service. Also, sample-auth-facade and sample-auth-project illustrate how bundles are operated and integrated.
- Integration Modules: The spring boot examples (“doraemon-spring-boot-expample” and “doraemon-spring-boot-starter”) show how the framework integrates into a Spring Boot environment.

##### Relationships and Interactions
- Each bundle (in sample-auth-bundle1 and sample-auth-bundle2) implements its own BundleService which is registered and then discovered by the core.
- The bundle.properties file in each bundle defines configuration directives. The “init-class” is loaded by the bundle’s own ClassLoader to invoke its business logic. In contrast, “skip-class” denotes classes that remain in the application’s default class loader.
- The service façade provides a common API to the application (or main runner) to interact with the loaded bundles.
- For projects that integrate with Spring Boot, the starter module auto-configures the framework (via DoraemonAutoConfigure) to scan and load bundles seamlessly upon application startup.

##### Architectural Patterns and Principles
- Plugin / Modular Architecture: Emphasize the isolation and pluggability. The entire design revolves around allowing bundles to be developed, packaged (as ZIP files), and dynamically loaded.
- ClassLoader Isolation: Illustrate how each bundle is loaded with its own class loader (An instance of AsgardClassLoader) ensuring that bundles are independent and shielded from each other.
- Inversion of Control: Notice the use of Spring (in some modules) and the decoupled architecture that lets the application retrieve implementations via the facade.
- Configuration Driving: Bundle-specific behavior is defined in external configuration files (bundle.properties) that dynamically influence module loading.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core Modules"
        CF["Core Framework\n(asgard-doraemon)"]:::core
        CFComponents["AsgardBundle, AsgardClassLoader,\nBundleConfiguration, RunDoraemonBundle"]:::core
        CF --> CFComponents
    end

    subgraph "Service Interface"
        BI["Bundle Service Interface\n(doraemon-facade)"]:::facade
    end

    subgraph "Bundle Projects"
        Archetype["Bundle Project Archetype\n(doraemon-project-archetype)"]:::archetype
        subgraph "Sample Bundles"
            SB1["Sample Bundle 1\n(sample-auth-bundle1)"]:::bundle
            SB2["Sample Bundle 2\n(sample-auth-bundle2)"]:::bundle
        end
        SA["Sample Application/Runner\n(sample-auth-project)"]:::sampleApp
    end

    subgraph "Spring Boot Integration"
        SBExp["Spring Boot Example\n(doraemon-spring-boot-expample)"]:::spring
        SBStarter["Spring Boot Starter\n(doraemon-spring-boot-starter)"]:::spring
    end

    CF -->|"loads"| SB1
    CF -->|"loads"| SB2
    BI -->|"definedBy"| SB1
    BI -->|"definedBy"| SB2
    Archetype -->|"providesConfig"| SB1
    Archetype -->|"providesConfig"| SB2
    SA -->|"calls"| BI
    SBStarter -->|"autoConfigures"| CF
    SBStarter -->|"scans"| SB1
    SBStarter -->|"scans"| SB2
    SBExp -->|"demonstrates"| SBStarter

    classDef core fill:#f1c40f,stroke:#d35400,stroke-width:2px;
    classDef facade fill:#2ecc71,stroke:#27ae60,stroke-width:2px;
    classDef archetype fill:#9b59b6,stroke:#8e44ad,stroke-width:2px;
    classDef bundle fill:#e67e22,stroke:#d35400,stroke-width:2px;
    classDef sampleApp fill:#3498db,stroke:#2980b9,stroke-width:2px;
    classDef spring fill:#1abc9c,stroke:#16a085,stroke-width:2px;

    click CF "https://github.com/qianxingchuan/doraemon/tree/master/asgard-doraemon/src/main/java/io/github/qianxingchuan/framework/doraemon"
    click BI "https://github.com/qianxingchuan/doraemon/blob/master/doraemon-facade/src/main/java/io/github/qianxingchuan/framework/doraemon/BundleService.java"
    click Archetype "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-project-archetype/src/main/resources/archetype-resources"
    click SB1 "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-sample/sample-auth-bundle1"
    click SB2 "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-sample/sample-auth-bundle2"
    click SA "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-sample/sample-auth-project"
    click SBExp "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-spring-boot-expample"
    click SBStarter "https://github.com/qianxingchuan/doraemon/tree/master/doraemon-spring-boot-starter"
```
