# thomascsd/ngx-dot-calendar architecture

> Architecture diagram of the GitHub repository thomascsd/ngx-dot-calendar, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thomascsd/ngx-dot-calendar
- Repository: https://github.com/thomascsd/ngx-dot-calendar

## Overview

##### Main Components
- Angular Application (Demo/Usage): Located in the “src” folder. This represents the host application where the calendar component is being used. It includes the main module, app component, header, standalone component, etc.
- ngx-dot-calendar Library:
– Modules and Components: Under “projects/ngx-dot-calendar/src/lib/components” you have the main calendar component, date and years sub-components along with their HTML, TS, and SCSS files.
– Directives: For example, the “dateHighlight.directive.ts” in the “directive” folder which adds extra behavior (like highlighting dates).
– Interfaces: These files under “interfaces” (e.g., DateContent, DateRenderer, and SelectedDateContext) define the contracts used within the library.
– Public API: The “public_api.ts” aggregates and exposes the library modules.
- External Dependencies:
– Angular (v14 and above): The project is designed to run on Angular which underpins both the host application and the library.
– date-fns: Listed as a peer dependency to handle date manipulations.
- Build and Test Tools:
– Angular CLI configuration (angular.json, Karma and Protractor for testing, etc.)
– Linting and formatting (tslint.json, .prettierrc, etc.)

##### Relationships and Interactions
- The host application integrates the ngx-dot-calendar library via module imports (see example usage in README). It communicates with the calendar component via property binding ([dateContents]) and event binding ((onSelect)).
- Within the ngx-dot-calendar library, the main calendar component breaks down into sub-components such as the dates and years components. These sub-components collaborate to render the calendar UI.
- The directive (dateHighlight.directive.ts) is applied to parts of the calendar to add conditional formatting/logic (e.g., highlighting Sundays).
- Interfaces define the types and expected contracts for inputs and outputs between components, ensuring proper data flow.
- External modules (like date-fns) are used within the component logic to compute dates and formats.

##### Important Architectural Patterns and Design Choices
- Modular Architecture: The separation between the main application (demo usage) and the reusable library module keeps concerns isolated.
- Component-driven Design: The library clearly uses the Angular component-based paradigm with additional support via directives and interfaces.
- Reusability and Extensibility: The library is designed with clear API contracts (attributes and callback events) and is easily integrated into other Angular projects.
- Configuration and Environment Separation: There are dedicated configurations for production, testing, and development (multiple tsconfig files, karma.conf.js, etc.) which are critical for maintainability.

##### Relevant Technologies, Frameworks, or Libraries
- Angular Framework: Core to the project, as it supports both the host application and library.
- date-fns: For date manipulation and formatting.
- Testing frameworks: Karma for unit tests and Protractor for end-to-end tests.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Demo Application"
        A["Angular Host Application (Demo)"]:::app
    end

    subgraph "ngx-dot-calendar Library"
        subgraph "Components"
            B["Main Calendar Component (dateContents,onSelect)"]:::comp
            C["Dates Sub-Component"]:::comp
            D["Years Sub-Component"]:::comp
        end
        E["Date Highlight Directive"]:::lib
        F["Interfaces (DateContent,DateRenderer,SelectedDateContext)"]:::lib
        G["Public API"]:::lib
    end

    subgraph "External & Tools"
        H["Angular Framework (v14+)"]:::ext
        I["date-fns"]:::ext
        J["Build&Test Tools (AngularCLI,Karma,etc.)"]:::ext
    end

    %% Relationships
    A -->|"imports"| G
    G -->|"exposes"| B
    B -->|"renders_dates"| C
    B -->|"renders_years"| D
    B -->|"applies"| E
    G -->|"exports_interfaces"| F
    B -->|"uses"| I
    A -->|"built_with"| H
    G -->|"built_with"| H
    A -->|"configured_by"| J
    G -->|"configured_by"| J

    %% Click Events
    click A "https://github.com/thomascsd/ngx-dot-calendar/tree/master/src/app"
    click B "https://github.com/thomascsd/ngx-dot-calendar/blob/master/projects/ngx-dot-calendar/src/lib/components/ngx-dot-calendar.component.ts"
    click C "https://github.com/thomascsd/ngx-dot-calendar/blob/master/projects/ngx-dot-calendar/src/lib/components/ngx-dot-calendar-dates.component.ts"
    click D "https://github.com/thomascsd/ngx-dot-calendar/blob/master/projects/ngx-dot-calendar/src/lib/components/ngx-dot-calendar-years.component.ts"
    click E "https://github.com/thomascsd/ngx-dot-calendar/blob/master/projects/ngx-dot-calendar/src/lib/directive/dateHighlight.directive.ts"
    click F "https://github.com/thomascsd/ngx-dot-calendar/tree/master/projects/ngx-dot-calendar/src/lib/interfaces"
    click G "https://github.com/thomascsd/ngx-dot-calendar/blob/master/projects/ngx-dot-calendar/src/public_api.ts"

    %% Styles
    classDef app fill:#FFD700,stroke:#FF8C00,stroke-width:2px;
    classDef lib fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef comp fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef ext fill:#FFB6C1,stroke:#FF0000,stroke-width:2px;
```
