# azlux/log2ram architecture

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

## Overview

##### Main Components

a) Core System Components:
- RAM Storage (tmpfs mount)
- Physical Disk Storage
- Log2Ram Service Manager
- Configuration System
- Synchronization System

b) Integration Points:
- System Logging Interface
- Systemd Integration
- ZRAM Integration (optional component)

##### System Interface Layer
- Integration with systemd
- Connection to system logging
- Journald integration point

##### Core Processing Layer
- Log2Ram Service Manager
- Configuration Manager
- Synchronization Manager

##### Storage Layer
- RAM Storage (tmpfs)
- Physical Disk Storage
- Optional ZRAM component

##### Key Flows

- Initial mount process (RAM setup)
- Log writing operations
- Periodic sync operations (daily timer)
- Shutdown sync process

##### Important Elements to Highlight

a) Service Components:
- log2ram.service
- log2ram-daily.service
- log2ram-daily.timer

b) Configuration Elements:
- log2ram.conf settings
- System integration points

##### Specific Implementation Details

- Blue: Core system components
- Green: Active data paths
- Yellow: Configuration components
- Red: Critical paths (shutdown sync)

##### Technical Specifications

Annotations showing:
- RAM size allocation
- Compression algorithms (if ZRAM is used)
- Sync mechanisms (rsync/cp)
- Path configurations

Create distinct sections for:
a) Runtime Operations:
- Normal logging flow
- RAM storage management

b) Maintenance Operations:
- Daily sync process
- Log rotation handling

c) Emergency Operations:
- Shutdown handling
- Error notification system

##### The configuration flexibility

Use standardized symbols:
- Rectangles for processing components
- Diamonds for decision points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef storage fill:#b3d9ff,stroke:#333
    classDef service fill:#98fb98,stroke:#333
    classDef config fill:#fff68f,stroke:#333
    classDef critical fill:#ff6b6b,stroke:#333
    classDef integration fill:#dda0dd,stroke:#333
    classDef optional fill:#f0f0f0,stroke:#dashed

    %% System Interface Layer
    subgraph SystemInterface
        SI[System Logging Interface]
        Systemd[Systemd Integration]
        Journald[Journald Integration]
    end

    %% Core Processing Layer
    subgraph CoreProcessing
        L2RM["Log2Ram Service Manager"]:::service
        CM["Configuration Manager"]:::config
        SM["Synchronization Manager"]:::service
        LRM["Log Rotation Manager"]:::service
    end

    %% Storage Layer
    subgraph StorageLayer
        RAM["RAM Storage (tmpfs)"]:::storage
        DISK["Physical Disk Storage"]:::storage
        ZRAM["ZRAM Storage"]:::optional
    end

    %% Installation and Configuration Components
    subgraph Management
        IC["Installation Manager"]:::integration
        UC["Uninstallation Manager"]:::integration
        MainService["Main Service"]:::service
        DailySync["Daily Sync Service"]:::service
        DailyTimer["Daily Sync Timer"]:::service
        Config["Configuration System"]:::config
    end

    %% Relationships
    SI --> L2RM
    Systemd --> L2RM
    L2RM --> RAM
    L2RM --> DISK
    CM --> L2RM
    SM --> RAM
    SM --> DISK
    LRM --> RAM
    MainService --> L2RM
    DailySync --> SM
    DailyTimer --> DailySync
    Config --> CM
    IC --> Systemd
    UC --> Systemd
    ZRAM -.-> RAM

    %% Click Events
    click L2RM "https://github.com/azlux/log2ram/tree/master/log2ram"
    click MainService "https://github.com/azlux/log2ram/blob/master/log2ram.service"
    click DailySync "https://github.com/azlux/log2ram/blob/master/log2ram-daily.service"
    click DailyTimer "https://github.com/azlux/log2ram/blob/master/log2ram-daily.timer"
    click Config "https://github.com/azlux/log2ram/blob/master/log2ram.conf"
    click LRM "https://github.com/azlux/log2ram/blob/master/log2ram.logrotate"
    click IC "https://github.com/azlux/log2ram/blob/master/install.sh"
    click UC "https://github.com/azlux/log2ram/blob/master/uninstall.sh"

    %% Legend
    subgraph Legend
        L1["Storage Components"]:::storage
        L2["Service Components"]:::service
        L3["Configuration Components"]:::config
        L4["Critical Components"]:::critical
        L5["Integration Components"]:::integration
        L6["Optional Components"]:::optional
    end
```
