# tudborg/elixir_interval architecture

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

- Interactive diagram: https://gitdiagram.com/tudborg/elixir_interval
- Repository: https://github.com/tudborg/elixir_interval

## Overview

##### Component Relationships

a) Behavioral Relationships
- `Interval.Behaviour` as a contract that all interval types implement
- `Intervalable` protocol to all implementing types

b) Database Integration
- `Interval.Support.EctoType` connecting to the interval types
- A connection to PostgreSQL's range types (external system)

##### Specific Elements

a) Core Components (Rectangles):
**┌─────────────────┐**
- Interval Module │
- ┘

**┌─────────────────┐  ┌─────────────────┐**
- Integer Type    │  │ Float Type      │
- ┘  └─────────────────┘
- ...etc...

b) Interfaces (Interfaces/Protocols):
**╭─────────────────╮**
- Intervalable    │
- Protocol        │
**╰─────────────────╯**

c) External Systems:
**┌──────────────┐**
- PostgreSQL   │
- Range Types  │
- ┘

##### Important Details to Capture

- That all interval types can be either discrete or continuous
- Ecto integration capability
- Relationship with PostgreSQL range types
- A note about bound types ([], (), [), (])

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Interface Layer
    Interval["Interval Module"]:::main
    click Interval "https://github.com/tudborg/elixir_interval/blob/main/lib/interval.ex"

    %% Behavior and Protocol Layer
    subgraph Contracts
        Behaviour["Interval.Behaviour"]:::behavior
        click Behaviour "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/behaviour.ex"
        Protocol["Intervalable Protocol"]:::protocol
        click Protocol "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/intervalable.ex"
    end

    %% Type Implementation Layer
    subgraph "Interval Types"
        Integer["Integer Interval"]:::type
        click Integer "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/integer.ex"
        Float["Float Interval"]:::type
        click Float "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/float.ex"
        Decimal["Decimal Interval"]:::type
        click Decimal "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/decimal.ex"
        Date["Date Interval"]:::type
        click Date "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/date.ex"
        DateTime["DateTime Interval"]:::type
        click DateTime "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/date_time.ex"
        NaiveDateTime["NaiveDateTime Interval"]:::type
        click NaiveDateTime "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/naive_date_time.ex"
    end

    %% Support Layer
    subgraph "Database Integration"
        EctoType["Ecto Type Support"]:::support
        click EctoType "https://github.com/tudborg/elixir_interval/blob/main/lib/interval/support/ecto_type.ex"
        Postgres["PostgreSQL Range Types"]:::external
    end

    %% Relationships
    Interval --> Protocol
    Protocol --> |implements| Integer
    Protocol --> |implements| Float
    Protocol --> |implements| Decimal
    Protocol --> |implements| Date
    Protocol --> |implements| DateTime
    Protocol --> |implements| NaiveDateTime
    
    Behaviour --> |defines| Integer
    Behaviour --> |defines| Float
    Behaviour --> |defines| Decimal
    Behaviour --> |defines| Date
    Behaviour --> |defines| DateTime
    Behaviour --> |defines| NaiveDateTime

    Integer --> |converts| EctoType
    Float --> |converts| EctoType
    Decimal --> |converts| EctoType
    Date --> |converts| EctoType
    DateTime --> |converts| EctoType
    NaiveDateTime --> |converts| EctoType
    
    EctoType --> |maps to| Postgres

    %% Styles
    classDef main fill:#f9f,stroke:#333,stroke-width:2px
    classDef type fill:#aef,stroke:#333
    classDef protocol fill:#bfb,stroke:#333
    classDef behavior fill:#bfb,stroke:#333
    classDef support fill:#ff9,stroke:#333
    classDef external fill:#ddd,stroke:#333

    %% Legend
    subgraph Legend
        L1["Main Module"]:::main
        L2["Interval Type"]:::type
        L3["Protocol/Behavior"]:::protocol
        L4["Support Module"]:::support
        L5["External System"]:::external
    end
```
