# rafaelrcamargo/ds architecture

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

- Interactive diagram: https://gitdiagram.com/rafaelrcamargo/ds
- Repository: https://github.com/rafaelrcamargo/ds

## Overview

##### Main Components Identification

The system consists of these primary components:
- CLI Interface Layer
- Docker Stats Collection Layer
- Data Processing Layer
- Visualization Layer
- Container Integration Layer

**A. User Interface Layer (Top)**
- CLI Arguments Parser (src/cli.rs)
- Command Handling

**B. Core Processing Layer (Middle)**
- Docker Stats Collector
- Data Processing (src/data.rs)
- Utils/Helpers (src/utils.rs)

**C. Integration Layer (Bottom)**
- Docker Engine API Connection
- Container Stats Stream

##### Specific Implementation Details

**User Input → CLI Parser → Stats Collector ⇢ Docker Engine**
- ↓
- Data Processor
- ↓
- Terminal Visualization

##### Technical Stack Indicators

- Rust (as primary language)
- Docker Engine API
- Terminal UI Framework
- Real-time data streaming

##### Additional Notes

- A note about the startup delay mentioned in the README
- Where network mode affects the data collection (bridge vs. host)
- Where performance optimizations occur

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Components
    CLI[CLI Interface]:::ui
    Parser[Arguments Parser]:::ui
    StatsCol[Docker Stats Collector]:::processing
    DataProc[Data Processor]:::processing
    Utils[Utility Functions]:::processing
    DockerAPI[Docker Engine API]:::external
    TermUI[Terminal Visualization]:::visualization
    
    %% Data Stores
    ContainerStats[(Container Stats Stream)]:::datastore
    
    %% Subgraphs for organization
    subgraph Input
        CLI --> Parser
    end
    
    subgraph Processing
        StatsCol --> DataProc
        DataProc --> Utils
    end
    
    subgraph Integration
        DockerAPI --> ContainerStats
    end
    
    %% Connections
    Parser --> StatsCol
    StatsCol -.->|Async Stream| DockerAPI
    ContainerStats -.->|Real-time Data| DataProc
    DataProc -->|Processed Stats| TermUI
    
    %% Error Handling
    DockerAPI -->|Errors| CLI
    
    %% Circular Update Indicator
    UpdateLoop((Real-time<br>Updates)):::loop
    DataProc --> UpdateLoop
    UpdateLoop --> StatsCol
    
    %% Click Events
    click CLI "https://github.com/rafaelrcamargo/ds/blob/main/src/cli.rs"
    click DataProc "https://github.com/rafaelrcamargo/ds/blob/main/src/data.rs"
    click Utils "https://github.com/rafaelrcamargo/ds/blob/main/src/utils.rs"
    click Parser "https://github.com/rafaelrcamargo/ds/blob/main/src/main.rs"
    
    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef visualization fill:#9b59b6,stroke:#8e44ad,color:white
    classDef datastore fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef loop fill:#e74c3c,stroke:#c0392b,color:white
    
    %% Legend
    subgraph Legend
        L1[UI Component]:::ui
        L2[Processing Component]:::processing
        L3[External System]:::external
        L4[Visualization]:::visualization
        L5[(Data Store)]:::datastore
        L6((Update Loop)):::loop
    end
```
