# joaomatossilva/datetimeextensions architecture

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

- Interactive diagram: https://gitdiagram.com/joaomatossilva/datetimeextensions
- Repository: https://github.com/joaomatossilva/datetimeextensions

## Overview

##### Main Components
- Library Core: This includes the primary assembly (located within src/DateTimeExtensions) that provides the extension methods (e.g., BusinessHoursExtensions, TimeExtensions, GeneralDateTimeExtensions).
- Working Days Module: Found under src/DateTimeExtensions/WorkingDays, this module handles holiday and working day calculations. It also includes culture-specific implementations (e.g., various HolidayStrategy classes in the CultureStrategies folder), interfaces like IHolidayStrategy and IWorkingDayCultureInfo, and helper classes like GlobalHolidays and DayInYear.
- Natural Text Module: Located in src/DateTimeExtensions/NaturalText, this module converts date differences into human-readable text. It uses a strategy pattern via interfaces such as INaturalTimeStrategy, along with various culture-specific strategies (like EN_GBNaturalTimeStrategy, FR_FRNaturalTimeStrategy, etc.).
- Export Module: Under src/DateTimeExtensions/Export, this component supports calendar export functionality. It provides mechanisms, such as via the ExportHolidayFormatLocator and IExportHolidaysFormat, to export holidays in different formats.
- Common Utilities: Components in src/DateTimeExtensions/Common (like DictionaryExtensions, ConcurrentLazyDictionary, and Locale-related classes) offer shared helper methods and abstractions that support the core library.
- Testing Suite: The tests directory contains comprehensive unit tests for all the features (covering business hours, working days, natural text, export functionalities, and culture-specific behaviors).

##### Relationships and Interactions
- The Core component is the entry point and integrates with all other modules. It exposes extension methods that internally call into the Working Days and Natural Text modules.
- The Working Days module provides strategies (using the Strategy pattern) to determine holidays and working days based on region-specific logic, interacting with the Common utilities for shared functionality.
- The Natural Text module retrieves the right culture-specific strategy to generate human-readable differences between dates.
- The Export module interacts with the Working Days module to retrieve holiday data which it then formats suitably.
- Testing components interact with all these modules to ensure that each function behaves as expected.

##### Architectural Patterns and Design Principles
- Modularity: The project separates the core functionality into distinct modules which encapsulate responsibilities (extensions, working days, natural text, export, and helpers).
- Strategy Pattern: Both the Natural Text and Working Days modules use the strategy pattern extensively, allowing different implementations per culture.
- Interface-Driven Design: Interfaces such as IExportHolidaysFormat, IHolidayStrategy, INaturalTimeStrategy, etc., decouple implementations from usage.
- Test-Driven: A dedicated tests suite ensures proper functionality; tests are organized per functional area and even for culture-specific behaviors.

##### Relevant Technologies, Frameworks, or Libraries
- .NET Framework / .NET Core (as implied by the use of C# and .csproj files).
- NuGet package management for distribution (as noted in the README).
- Source Link for debugging and transparency.
- GitHub Actions for CI/CD (.github/workflows/dotnet.yml).

- “Core API” sits at the center.
- “Core API” to three key modules: “Working Days”, “Natural Text”, and “Export”.
- Under “Natural Text”, show the variety of culture-specific time strategies.
- Link “Common Utilities” to both the “Working Days” and “Core API” modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client/Application"]:::external
    Core["Core Extensions"]:::core
    WD["Working Days Module"]:::module
    NT["Natural Text Module"]:::module
    EX["Export Module"]:::module
    CU["Common Utilities"]:::utility
    TS["Tests Suite"]:::tests

    Client -->|"calls"| Core
    Core -->|"uses"| WD
    Core -->|"uses"| NT
    Core -->|"calls"| EX
    Core -->|"utilizes"| CU
    WD -->|"leverages"| CU
    EX -->|"retrievesHolidayDataFrom"| WD

    TS -.->|"covers"| Core
    TS -.->|"covers"| WD
    TS -.->|"covers"| NT
    TS -.->|"covers"| EX
    TS -.->|"covers"| CU

    subgraph "Working Days Module Details"
        WD1["GlobalHolidays & DayInYear"]:::helper
        WD2["CultureStrategies (HolidayStrategy)"]:::strategy
        WD --> WD1
        WD --> WD2
    end

    subgraph "Natural Text Module Details"
        NT1["Culture-specific NaturalTime Strategies"]:::strategy
        NT --> NT1
    end

    %% Click Events
    click Core "https://github.com/joaomatossilva/datetimeextensions/tree/master/src/DateTimeExtensions"
    click WD "https://github.com/joaomatossilva/datetimeextensions/tree/master/src/DateTimeExtensions/WorkingDays"
    click NT "https://github.com/joaomatossilva/datetimeextensions/tree/master/src/DateTimeExtensions/NaturalText"
    click EX "https://github.com/joaomatossilva/datetimeextensions/tree/master/src/DateTimeExtensions/Export"
    click CU "https://github.com/joaomatossilva/datetimeextensions/tree/master/src/DateTimeExtensions/Common"
    click TS "https://github.com/joaomatossilva/datetimeextensions/blob/master/tests/DateTimeExtensions.Tests"

    %% Styles
    classDef core fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef module fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef utility fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef tests fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef helper fill:#e6ccff,stroke:#333,stroke-width:2px;
    classDef strategy fill:#fffacd,stroke:#333,stroke-width:2px;
    classDef external fill:#d1e7dd,stroke:#333,stroke-width:2px;
```
