# rutaks/deja-vu architecture

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

- Interactive diagram: https://gitdiagram.com/rutaks/deja-vu
- Repository: https://github.com/rutaks/deja-vu

## Overview

##### Main Components

a) Core Domain Model:
- Schedule Management
- Temporal Expressions
- JSON Parsing Layer

##### Component Relationships

**┌─────────────────────────────────────────────────────────────┐**
- Client Application                       │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- JSON Configuration                       │
- {scheduleCode, scheduleConfig: {schedule: [{...}]}}        │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- ScheduleJsonParser                        │
- ┬─────────────────────────────────┘
- ↓
**┌─────────────────────────────────────────────────────────────┐**
- Temporal Expressions                      │
- ┬─────────────────┬────────────────────────┤
- Basic Types   │  Composite Types│    Schedule Types      │
- DayInMonthTE  │ - UnionTE      │  - BasicSchedule       │
- DayInWeekTE   │ - DifferenceTE │  - ScheduleElement     │
- RangeEveryYearTE│- IntersectionTE│                      │
- ┴─────────────────┴────────────────────────┘

##### Implementation Details to Highlight

a) Input Layer:
- JSON configuration format
- Schedule configuration structure
- Validation rules

b) Processing Layer:
- ScheduleJsonParser transformation logic
- Temporal Expression hierarchy
- Schedule composition

c) Domain Model:
- Different types of temporal expressions
- Composite pattern implementation
- Schedule generation rules

##### Key Architectural Patterns

- Composite Pattern: For temporal expressions (UnionTE, DifferenceTE, etc.)
- Strategy Pattern: For different schedule types
- Factory Pattern: For creating temporal expressions
- Builder Pattern: For constructing schedules

##### Additional Notes

- TE suffix: Temporal Expression
- Relationship types between components
- Configuration format examples
- Common use cases (like the examples in README)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        CA[Client Code]
    end

    subgraph JSON["JSON Configuration Layer"]
        JC["JSON Config"]:::json
        BSJ["BasicScheduleJsonElement"]:::json
        SWS["ScheduleWithSlotScheduleJsonElement"]:::json
        SC["ScheduleConfig"]:::json
    end

    subgraph Parser["JSON Parsing Layer"]
        SJP["ScheduleJsonParser"]:::parser
    end

    subgraph Core["Core Interfaces"]
        SI["Schedule Interface"]:::interface
        TI["TemporalExpression Interface"]:::interface
    end

    subgraph Basic["Basic Temporal Expressions"]
        DIM["DayInMonthTE"]:::basic
        DIW["DayInWeekTE"]:::basic
        REY["RangeEveryYearTE"]:::basic
    end

    subgraph Composite["Composite Temporal Expressions"]
        CTE["CompositeTE"]:::composite
        UTE["UnionTE"]:::composite
        DTE["DifferenceTE"]:::composite
        ITE["IntersectionTE"]:::composite
    end

    subgraph Schedule["Schedule Types"]
        BS["BasicSchedule"]:::schedule
        SE["ScheduleElement"]:::schedule
    end

    subgraph Types["Type Definitions"]
        TET["TemporalExpressionType"]:::enum
        RET["RangeEveryYearExpression"]:::enum
    end

    CA --> JC
    JC --> BSJ & SWS & SC
    BSJ & SWS & SC --> SJP
    SJP --> SI
    SI --> TI
    TI --> DIM & DIW & REY
    TI --> CTE
    CTE --> UTE & DTE & ITE
    SI --> BS
    BS --> SE
    TET --> DIM & DIW & REY
    RET --> REY

    %% Click events for component mapping
    click BSJ "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/dtos/BasicScheduleJsonElement.java"
    click SWS "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/dtos/ScheduleWithSlotScheduleJsonElement.java"
    click SC "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/dtos/ScheduleConfig.java"
    click SJP "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/utils/ScheduleJsonParser.java"
    click SI "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/interfaces/Schedule.java"
    click TI "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/interfaces/TemporalExpression.java"
    click DIM "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/DayInMonthTE.java"
    click DIW "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/DayInWeekTE.java"
    click REY "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/RangeEveryYearTE.java"
    click CTE "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/CompositeTE.java"
    click UTE "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/UnionTE.java"
    click DTE "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/DifferenceTE.java"
    click ITE "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/IntersectionTE.java"
    click BS "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/BasicSchedule.java"
    click SE "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/models/ScheduleElement.java"
    click TET "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/enums/TemporalExpressionType.java"
    click RET "https://github.com/rutaks/deja-vu/blob/main/src/main/java/rw/rutaks/deja_vu/enums/RangeEveryYearExpression.java"

    %% Styling
    classDef json fill:#LightBlue
    classDef parser fill:#90EE90
    classDef interface fill:#FFE4B5
    classDef basic fill:#98FB98
    classDef composite fill:#DDA0DD
    classDef schedule fill:#F0E68C
    classDef enum fill:#D3D3D3

    %% Legend
    subgraph Legend
        L1[JSON Components]:::json
        L2[Parser Components]:::parser
        L3[Interfaces]:::interface
        L4[Basic TEs]:::basic
        L5[Composite TEs]:::composite
        L6[Schedule Types]:::schedule
        L7[Enums]:::enum
    end
```
