# zylatis/turnstiles architecture

> Architecture diagram of the GitHub repository zylatis/turnstiles, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zylatis/turnstiles
- Repository: https://github.com/zylatis/turnstiles

## Overview

##### Project Type Analysis
This is a specialized Rust library that wraps the io::Write trait to provide file rotation capabilities, primarily aimed at log file management. It's a focused, single-purpose utility library.

##### Main Components

a) Core Components:
- FileRotator Wrapper (Main Component)
- IO Write Trait Implementation
- Rotation Condition Handlers
- Pruning Strategy Handlers

b) Supporting Components:
- Utility Functions
- Error Handling System

**Client Application Layer**

**Turnstiles Library Interface**

**FileRotator Implementation**

- Rotation Conditions
- None
- SizeMB
- Duration
- SizeLines (planned)

- Pruning Strategies
- None
- MaxFiles
- MaxAge

- IO Operations
- Write Trait Implementation

**File System Interface**

##### Key Relationships

- How the FileRotator wraps the io::Write trait
- Relationship between rotation conditions and the core FileRotator
- Demonstrate how pruning strategies interact with the file system
- Error propagation paths

##### Implementation Details to Highlight

- File rotation trigger mechanisms
- File system interaction points
- Error handling pathways
- Configuration flow

##### Scale and Detail Level

- Major components and their interactions
- Extension points
- Core functionality flow
- Integration boundaries

Remember to indicate that this is a work in progress, with some features planned for future implementation, and maintain clear separation between the implemented and planned features in the visual representation.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef implemented fill:#90EE90,stroke:#333,stroke-width:2px
    classDef planned fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef interface fill:#DCDCDC,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer["Client Application Layer"]
        Client["Client Application"]:::interface
    end

    %% Library Interface Layer
    subgraph LibraryInterface["Turnstiles Library Interface"]
        API["Public API"]:::core
    end

    %% Core Implementation Layer
    subgraph CoreLayer["Core Implementation"]
        FileRotator["FileRotator Wrapper"]:::implemented
        IOWrite["IO Write Trait Implementation"]:::implemented
        Utils["Utility Functions"]:::implemented
        
        subgraph RotationConditions["Rotation Conditions"]
            RCNone["None"]:::implemented
            RCSizeMB["SizeMB"]:::implemented
            RCDuration["Duration"]:::implemented
            RCSizeLines["SizeLines"]:::planned
        end
        
        subgraph PruningStrategies["Pruning Strategies"]
            PSNone["None"]:::implemented
            PSMaxFiles["MaxFiles"]:::implemented
            PSMaxAge["MaxAge"]:::implemented
        end
        
        Testing["Testing Infrastructure"]:::implemented
        TempDir["Temporary Directory Handler"]:::implemented
    end

    %% File System Layer
    subgraph FSLayer["File System Interface"]
        FS["File System Operations"]:::interface
    end

    %% Relationships
    Client --> API
    API --> FileRotator
    FileRotator --> IOWrite
    FileRotator --> Utils
    IOWrite --> FS
    
    FileRotator --> RotationConditions
    FileRotator --> PruningStrategies
    
    PruningStrategies --> FS
    Testing --> TempDir
    TempDir --> FS

    %% Click Events
    click FileRotator "https://github.com/zylatis/turnstiles/blob/main/src/lib.rs"
    click IOWrite "https://github.com/zylatis/turnstiles/blob/main/src/lib.rs"
    click Utils "https://github.com/zylatis/turnstiles/blob/main/src/utils.rs"
    click Testing "https://github.com/zylatis/turnstiles/blob/main/tests/integration_tests.rs"
    click TempDir "https://github.com/zylatis/turnstiles/blob/main/tempdir/src/lib.rs"

    %% Legend
    subgraph Legend
        L1["Implemented"]:::implemented
        L2["Planned"]:::planned
        L3["Core Component"]:::core
        L4["Interface"]:::interface
    end
```
