# pleerock/ngx-modal architecture

> Architecture diagram of the GitHub repository pleerock/ngx-modal, 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/pleerock/ngx-modal
- Repository: https://github.com/pleerock/ngx-modal

## Overview

##### Main components of the system
- Library Core:
- The files in the “src” folder (Modal.ts, RouteModal.ts, and index.ts) represent the core of the modal functionality. These encapsulate the modal components, including the basic modal and the router modal.
- Build/Configuration:
- The presence of gulp files (gulpfile.js and gulpfile.ts), package.json, tsconfig.json and other config files indicate that there is an automated build process and TypeScript configuration.
- Sample Implementations:
- The “sample” directory contains multiple examples (e.g., sample1-simple-usage and sample2-routing-modal) showcasing how to integrate and use the modals within Angular applications.

##### Relationships and interactions
- Angular Application Integration:
- The library is intended to be imported into an Angular application (as shown in the README sample usage), where the ModalModule is included in the Angular module’s imports.
- Modal Components:
- The “modal” component is composed of sub-components (modal-header, modal-content, modal-footer) that encapsulate different parts of the modal, and event bindings (onOpen, onClose, onSubmit) are employed to control modal behavior.
- Router Modal:
- There is an alternative “route-modal” component that is used when modals need to be opened based on Angular routing. This provides a different way of handling modal presentation.
- External Dependencies:
- The implementation leverages Angular2 and Bootstrap3. Thus, it should be clear which parts of the UI are handled by the Angular components and which styling or behavior is provided by Bootstrap.

##### Architectural patterns and design principles
- Modular Design:
- The library is structured to be easily imported and integrated in various Angular applications, promoting reusability.
- Separation of Concerns:
- The core functionality (definition of modals) is separated from the sample usage, which demonstrates how the components can be used in different contexts (basic usage vs. router-based modals).
- Event-driven Architecture:
- User actions such as opening, closing, or submitting within the modal trigger events that are handled elsewhere in the Angular application.

- Use clear labels for each component block (e.g., “Modal Module”, “Router Modal”, “Angular App”, “Build & Configuration”, “Sample Usage”).
- Event flows – for instance, from the Modal Component “onOpen” event to the Angular application’s response.
- Dependency injection:
- That the ModalModule is imported into the Angular App Module, ensuring the modal’s functionality is accessible across components.
- If desired, add callouts that explain how each sample interacts with the core library to showcase the versatility of modal features (custom headers, routing, event callbacks).

##### Be detailed and comprehensive
- One zone for the library core and public API.
- A separate zone for build and configuration processes.
- Separate zones to illustrate how the sample implementations use the library to handle different modal scenarios.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    Angular("Angular Framework"):::external
    Bootstrap("Bootstrap3 / Custom CSS"):::external

    %% Angular Application
    App("Angular App Module"):::app

    %% Library Core subgraph
    subgraph "Library Core"
        MExport("Main Export Module"):::core
        Modal("Modal Component"):::core
        RouteModal("Route Modal Component"):::core
    end

    %% Configuration & Build subgraph
    subgraph "Configuration & Build"
        GulpJS("Gulp Task (gulpfile.js)"):::build
        GulpTS("Gulp Task (gulpfile.ts)"):::build
        TSConfig("TypeScript (tsconfig.json)"):::build
        TSAOT("TypeScript (tsconfig-aot.json)"):::build
        TSLint("TypeScript (tslint.json)"):::build
    end

    %% Sample Implementations subgraph
    subgraph "Sample Implementations"
        Sample1("Sample1: Simple Modal Usage"):::sample
        Sample2("Sample2: Routing Modal Usage"):::sample
    end

    %% Relationships
    App -->|"imports"| MExport
    MExport -->|"aggregates"| Modal
    MExport -->|"aggregates"| RouteModal
    Modal -->|"triggersEvents"| App

    Angular -->|"framework"| App
    Angular -->|"drives"| MExport
    Bootstrap -->|"styles"| Modal
    Bootstrap -->|"styles"| App

    GulpJS -->|"builds"| MExport
    GulpTS -->|"builds"| MExport
    TSConfig -->|"configures"| MExport
    TSAOT -->|"configures"| MExport
    TSLint -->|"enforcesStandards"| MExport

    Sample1 -->|"integrates"| MExport
    Sample2 -->|"integrates"| MExport
    App -->|"demonstratesUsage"| Sample1
    App -->|"demonstratesUsage"| Sample2

    %% Click Events
    click Modal "https://github.com/pleerock/ngx-modal/blob/master/src/Modal.ts"
    click RouteModal "https://github.com/pleerock/ngx-modal/blob/master/src/RouteModal.ts"
    click MExport "https://github.com/pleerock/ngx-modal/blob/master/src/index.ts"
    click GulpJS "https://github.com/pleerock/ngx-modal/blob/master/gulpfile.js"
    click GulpTS "https://github.com/pleerock/ngx-modal/blob/master/gulpfile.ts"
    click TSConfig "https://github.com/pleerock/ngx-modal/blob/master/tsconfig.json"
    click TSAOT "https://github.com/pleerock/ngx-modal/blob/master/tsconfig-aot.json"
    click TSLint "https://github.com/pleerock/ngx-modal/blob/master/tslint.json"
    click Sample1 "https://github.com/pleerock/ngx-modal/tree/master/sample/sample1-simple-usage"
    click Sample2 "https://github.com/pleerock/ngx-modal/tree/master/sample/sample2-routing-modal"

    %% Styles
    classDef external fill:#fdd,stroke:#900,stroke-width:2px;
    classDef app fill:#ddf,stroke:#009,stroke-width:2px;
    classDef core fill:#dfd,stroke:#090,stroke-width:2px;
    classDef build fill:#ffd,stroke:#990,stroke-width:2px;
    classDef sample fill:#cdf,stroke:#039,stroke-width:2px;
```
