# svetlitski/fcp architecture

> Architecture diagram of the GitHub repository svetlitski/fcp, 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/svetlitski/fcp
- Repository: https://github.com/svetlitski/fcp

## Overview

- User input → CLI
- CLI → Copy Engine
- Copy Engine → Worker Pool
- Worker Pool → Filesystem

- Error handling paths
- Status reporting

##### Key Subsystems (Use nested components)

a. Filesystem Interface
- File operations
- Directory traversal
- Permission handling

b. Performance Optimization Layer
- Parallel processing
- Platform-specific optimizations
- I/O queue management

##### Important Elements to Highlight

a. Parallelization System
- How work is distributed across cores
- Queue depth management
- Demonstrate I/O request distribution

b. Platform-Specific Features
- Copy-on-write functionality for macOS
- Filesystem-specific optimizations

c. Error Handling Paths
- Error propagation
- Error reporting back to user

##### Technical Details in Notes

- Minimum Rust version requirement (1.53.0)
- Supported filesystems (APFS, XFS)
- Performance characteristics
- System requirements

##### A Performance Layer

- How I/O requests are queued
- SSD optimization paths
- Demonstrate parallel processing flows

##### How work is distributed across available CPU cores

Remember to maintain a balance between showing the high-level architecture while including enough detail to explain the performance characteristics that make this tool unique, particularly the parallelization and platform-specific optimizations.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    CLI["Command Line Interface"]:::ui
    click CLI "https://github.com/Svetlitski/fcp/blob/master/src/main.rs"
    
    Core["Core Copy Engine"]:::core
    click Core "https://github.com/Svetlitski/fcp/blob/master/src/lib.rs"
    
    FSModule["Filesystem Operations"]:::core
    click FSModule "https://github.com/Svetlitski/fcp/blob/master/src/filesystem.rs"
    
    ErrorSystem["Error Handling System"]:::error
    click ErrorSystem "https://github.com/Svetlitski/fcp/blob/master/src/error.rs"
    
    subgraph Platform["Platform-Specific Optimizations"]
        MacOS["macOS Optimizations<br/>- copy-on-write<br/>- fclonefileat<br/>- fcopyfile"]:::platform
        Linux["Linux Optimizations"]:::platform
    end
    
    subgraph WorkerSystem["Worker Pool System"]
        WorkerPool(("Thread Pool")):::worker
        WorkQueue["Work Distribution"]:::worker
    end
    
    subgraph Performance["Performance Layer"]
        IOQueue["I/O Queue Manager"]:::perf
        ParallelOps["Parallel Processing"]:::perf
        SSDOpt["SSD Optimizations"]:::perf
    end
    
    subgraph Testing["Testing & Quality"]
        Benchmark["Performance Benchmarks"]:::test
        click Benchmark "https://github.com/Svetlitski/fcp/blob/master/benches/fcp_benchmark.rs"
        Tests["Test Suite"]:::test
        click Tests "https://github.com/Svetlitski/fcp/blob/master/tests/tests.rs"
        TestFixtures["Test Fixtures"]:::test
        click TestFixtures "https://github.com/Svetlitski/fcp/tree/master/fixtures/"
        CI["CI Pipeline"]:::test
        click CI "https://github.com/Svetlitski/fcp/blob/master/.github/workflows/continuous_integration.yml"
    end
    
    %% Development Tools
    DevUtils["Development Utilities"]:::dev
    click DevUtils "https://github.com/Svetlitski/fcp/blob/master/dev_utils/src/lib.rs"
    
    %% Relationships
    CLI --> Core
    Core --> FSModule
    Core --> ErrorSystem
    Core --> Platform
    Core --> WorkerSystem
    
    WorkerPool --> WorkQueue
    WorkQueue --> FSModule
    
    FSModule --> Performance
    IOQueue --> ParallelOps
    ParallelOps --> SSDOpt
    
    ErrorSystem -.-> CLI
    
    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef platform fill:#f1c40f,stroke:#f39c12,color:black
    classDef worker fill:#e67e22,stroke:#d35400,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white
    classDef perf fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef dev fill:#1abc9c,stroke:#16a085,color:white
    
    %% Legend
    subgraph Legend
        UI["User Interface"]:::ui
        CoreComp["Core Components"]:::core
        PlatformOpt["Platform Optimizations"]:::platform
        WorkerComp["Worker Components"]:::worker
        ErrorComp["Error Handling"]:::error
        PerfComp["Performance Components"]:::perf
        TestComp["Testing Components"]:::test
        DevComp["Development Tools"]:::dev
    end
```
