# drdo/redu architecture

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

- Interactive diagram: https://gitdiagram.com/drdo/redu
- Repository: https://github.com/drdo/redu

## Overview

##### Main Components

a) Core Components:
- CLI Interface Layer
- Cache Management System
- Restic Repository Interface
- File Tree Analysis Engine
- User Interface (TUI)

b) Data Storage:
- SQLite Cache (evident from SQL migration files)
- External Restic Repository (integration point)

##### Component Relationships

**[User Input] → [CLI Interface]**
- ↓
**[Restic Repository] ← [Repository Interface] → [Cache Management]**
- ↓
- [SQLite Cache Store]
- ↓
- [File Tree Analysis]
- ↓
- [TUI Renderer]

##### Key Architectural Elements

Aspects:
- Cache versioning system (shown by SQL migration files)
- Command processing pipeline
- File tree representation
- Snapshot aggregation logic

##### Technical Specifications

Elements:
- Rust-specific components
- External dependencies (restic)
- Cache schema versions
- File tree structure representation

**Top Layer: User Interface (CLI/TUI)**
**Middle Layer: Business Logic (Cache/Analysis)**
**Bottom Layer: Storage (SQLite/Restic)**

##### Important Details to Capture

- Persistence system
- Snapshot synchronization flow
- Cache update mechanism
- File tree traversal pattern

##### Component Interactions

Key flows:
- Initial repository scanning
- Cache synchronization
- Management
- Exclude list generation

##### User Interface Components

- Blue: User interface components
- Green: Data processing
- Yellow: Storage systems
- Red: Critical paths

Annotations for:
- Cache version migrations
- Snapshot aggregation logic
- Persistence
- Performance-critical paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        CLI["CLI Interface"]
        TUI["Terminal UI"]
    end

    subgraph "Core Processing Layer"
        RI["Repository Interface"]
        CMS["Cache Management System"]
        FTA["File Tree Analysis"]
        UTIL["Utility Functions"]
    end

    subgraph "Storage Layer"
        SQLITE[("SQLite Cache")]
        RESTIC[("Restic Repository")]
    end

    %% Relationships
    CLI --> RI
    CLI --> CMS
    RI --> RESTIC
    RI --> CMS
    CMS --> SQLITE
    CMS --> FTA
    FTA --> TUI
    UTIL --> CMS
    UTIL --> FTA

    %% Click events for component mapping
    click CLI "https://github.com/drdo/redu/blob/main/src/args.rs"
    click TUI "https://github.com/drdo/redu/blob/main/src/ui.rs"
    click RI "https://github.com/drdo/redu/blob/main/src/restic.rs"
    click CMS "https://github.com/drdo/redu/blob/main/src/cache/mod.rs"
    click FTA "https://github.com/drdo/redu/blob/main/src/cache/filetree.rs"
    click UTIL "https://github.com/drdo/redu/blob/main/src/util.rs"
    click SQLITE "https://github.com/drdo/redu/tree/main/src/cache/sql/"

    %% Styling
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef processing fill:#90EE90,stroke:#333,stroke-width:2px
    classDef storage fill:#FFD700,stroke:#333,stroke-width:2px
    classDef critical fill:#FF6B6B,stroke:#333,stroke-width:2px

    class CLI,TUI ui
    class RI,CMS,FTA,UTIL processing
    class SQLITE,RESTIC storage

    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        PROC["Processing"]:::processing
        STORE["Storage"]:::storage
    end
```
