# wanasit/chrono architecture

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

- Interactive diagram: https://gitdiagram.com/wanasit/chrono
- Repository: https://github.com/wanasit/chrono

## Overview

##### High-Level Architecture Components

a) Input Layer
- Text input entry point
- Configuration options (strict/casual modes)
- Locale selection
- Reference date/timezone handling

b) Core Processing Pipeline
- Parser execution layer
- Refiner execution layer
- Results aggregation

c) Locale-Specific Components
- Language-specific parsers
- Language-specific refiners
- Constants and configurations

##### Component Relationships

**Input Text → Parser Layer → Refiner Layer → Parsed Results**
- ↑             ↑

- Locale Modules  Common Refiners

##### Detailed Component Breakdown

**Parser Components:**
- AbstractParserWithWordBoundary
- TimeExpressionParser
- CasualDateParser
- ISO/StandardFormatParser
- LocaleSpecificParsers

**Refiner Components:**
- MergeDateRangeRefiner
- MergeDateTimeRefiner
- ForwardDateRefiner
- TimezoneRefiner
- OverlapRemovalRefiner

**Utility Components:**
- Calculation Utils
- Pattern Utils
- TimeUnit Utils
- Timezone Handling

##### Configuration Points

Configuration entry points:
- Locale selection
- Strict/Casual mode switching
- Timezone configurations
- Custom parser/refiner injection points

##### Implementation Details

Implementation aspects:
- TypeScript interfaces
- Component inheritance structure
- Plugin architecture for parsers/refiners
- Result type definitions

##### The configuration flexibility

Use a hierarchical layout with clear separation between:
- Core processing logic
- Language-specific modules
- Utility functions
- Configuration components

This will create a comprehensive visualization that helps understand both the high-level architecture and the detailed implementation structure of the Chrono library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Core Component]:::core
        L2[Locale Component]:::locale
        L3[Configuration]:::config
        L4[Interface]:::interface
        L5[Utility]:::utility
    end

    subgraph Input["Input Layer"]
        Text[Text Input]:::interface
        Config["Configuration Options"]:::config
        click Config "https://github.com/wanasit/chrono/blob/master/src/configurations.ts"
        LocaleSelect["Locale Selection"]:::config
        TimeConfig["Timezone/Reference Date"]:::config
        click TimeConfig "https://github.com/wanasit/chrono/blob/master/src/timezone.ts"
    end

    subgraph Core["Core Processing Pipeline"]
        Parser["Parser Execution Layer"]:::core
        Refiner["Refiner Execution Layer"]:::core
        Results["Results Aggregation"]:::interface
        click Results "https://github.com/wanasit/chrono/blob/master/src/results.ts"
    end

    subgraph Parsers["Parser Components"]
        AbstractParser["AbstractParserWithWordBoundary"]:::core
        click AbstractParser "https://github.com/wanasit/chrono/blob/master/src/common/parsers/AbstractParserWithWordBoundary.ts"
        TimeParser["TimeExpressionParser"]:::core
        click TimeParser "https://github.com/wanasit/chrono/blob/master/src/common/parsers/AbstractTimeExpressionParser.ts"
        ISOParser["ISO Format Parser"]:::core
        click ISOParser "https://github.com/wanasit/chrono/blob/master/src/common/parsers/ISOFormatParser.ts"
        StandardParser["Standard Format Parser"]:::core
        click StandardParser "https://github.com/wanasit/chrono/blob/master/src/common/parsers/SlashDateFormatParser.ts"
    end

    subgraph Refiners["Refiner Components"]
        DateRangeRefiner["Merge Date Range Refiner"]:::core
        click DateRangeRefiner "https://github.com/wanasit/chrono/blob/master/src/common/refiners/AbstractMergeDateRangeRefiner.ts"
        DateTimeRefiner["Merge DateTime Refiner"]:::core
        click DateTimeRefiner "https://github.com/wanasit/chrono/blob/master/src/common/refiners/AbstractMergeDateTimeRefiner.ts"
        ForwardRefiner["Forward Date Refiner"]:::core
        click ForwardRefiner "https://github.com/wanasit/chrono/blob/master/src/common/refiners/ForwardDateRefiner.ts"
        TimezoneRefiner["Timezone Refiners"]:::core
        click TimezoneRefiner "https://github.com/wanasit/chrono/blob/master/src/common/refiners/ExtractTimezoneAbbrRefiner.ts"
        OverlapRefiner["Overlap Removal Refiner"]:::core
        click OverlapRefiner "https://github.com/wanasit/chrono/blob/master/src/common/refiners/OverlapRemovalRefiner.ts"
    end

    subgraph Utils["Utility Components"]
        CalcUtils["Calculation Utils"]:::utility
        click CalcUtils "https://github.com/wanasit/chrono/blob/master/src/calculation/mergingCalculation.ts"
        PatternUtils["Pattern Utils"]:::utility
        click PatternUtils "https://github.com/wanasit/chrono/blob/master/src/utils/pattern.ts"
        TimeUtils["TimeUnit Utils"]:::utility
        click TimeUtils "https://github.com/wanasit/chrono/blob/master/src/utils/timeunits.ts"
    end

    subgraph Locales["Locale-Specific Components"]
        EN["English"]:::locale
        click EN "https://github.com/wanasit/chrono/tree/master/src/locales/en"
        FR["French"]:::locale
        click FR "https://github.com/wanasit/chrono/tree/master/src/locales/fr"
        DE["German"]:::locale
        click DE "https://github.com/wanasit/chrono/tree/master/src/locales/de"
        JA["Japanese"]:::locale
        click JA "https://github.com/wanasit/chrono/tree/master/src/locales/ja"
        ZH_HANS["Chinese (Simplified)"]:::locale
        click ZH_HANS "https://github.com/wanasit/chrono/tree/master/src/locales/zh/hans"
        ZH_HANT["Chinese (Traditional)"]:::locale
        click ZH_HANT "https://github.com/wanasit/chrono/tree/master/src/locales/zh/hant"
        RU["Russian"]:::locale
        click RU "https://github.com/wanasit/chrono/tree/master/src/locales/ru"
        UK["Ukrainian"]:::locale
        click UK "https://github.com/wanasit/chrono/tree/master/src/locales/uk"
        NL["Dutch"]:::locale
        click NL "https://github.com/wanasit/chrono/tree/master/src/locales/nl"
        ES["Spanish"]:::locale
        click ES "https://github.com/wanasit/chrono/tree/master/src/locales/es"
        PT["Portuguese"]:::locale
        click PT "https://github.com/wanasit/chrono/tree/master/src/locales/pt"
    end

    Text --> Parser
    Config --> Parser
    LocaleSelect --> Parser
    TimeConfig --> Parser

    Parser --> Refiner
    Refiner --> Results

    Parsers --> Parser
    Refiners --> Refiner
    Utils --> Parser
    Utils --> Refiner
    Locales --> Parser
    Locales --> Refiner

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef locale fill:#4CAF50,stroke:#2E7D32,color:white
    classDef config fill:#FF9800,stroke:#EF6C00,color:white
    classDef interface fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef utility fill:#FF5722,stroke:#D84315,color:white
```
