# norbinsh/logs-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/norbinsh/logs-downloader
- Repository: https://github.com/norbinsh/logs-downloader

## Overview

Project Type: This is a utility script/service project designed to download log files from Incapsula's service, with support for running as a system service on Linux systems.

##### Main Components

a. Core Components:
- LogsDownloader Script (Central Component)
- Configuration Management System
- Encryption System
- Logging System
- Incapsula External Service

b. Integration Points:
- Linux Service Integration
- File System Interaction Points

##### Central Component (LogsDownloader.py)
- Use a prominent rectangle in the center
- Internal modules:
- Configuration Parser
- Encryption Handler (M2Crypto)
- Logging Module (loggerglue)

- Authentication flow (Private Key → Incapsula)
- Log data flow (Incapsula → Script → Local Storage)
- Configuration flow (Config Files → Script)
- System logging flow (Script → System Logs)

Use these specific visual elements:

##### Connection Types
- Double lines: Data transfer paths

##### Specific labels
- Component names
- File paths for important configurations
- Key dependencies (M2Crypto, loggerglue)
- Service configuration details

##### Security Flow
- Encryption key hierarchy
- Private key usage flow
- Secure connections to Incapsula

##### Service Integration
- How the script integrates with init system
- Service configuration file placement
- Service control flow

##### Configuration Management
- Hierarchy of configuration files
- Default paths and override options
- Logging level configuration

Level of Detail:
- Callouts for important configuration details
- Notes about system requirements and dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Components"]
        LD[LogsDownloader Script]:::core
        CM[Configuration Management]:::core
        ES[Encryption System]:::security
        LS[Logging System]:::core
    end

    subgraph External["External Systems"]
        IS[Incapsula Service]:::external
        SM[System Service Manager]:::system
    end

    subgraph Storage["Storage Components"]
        CD["Config Directory<br>/etc/incapsula/logs/config"]:::storage
        SLD["System Logs Directory<br>/var/log/incapsula/logsDownloader"]:::storage
        KS["Keys Storage<br>/config/keys/{n}/Private.key"]:::security
    end

    %% Core Component Details
    subgraph CoreDetails["Core Component Details"]
        CP[Configuration Parser]:::core
        EH[Encryption Handler<br>M2Crypto]:::security
        LM[Logging Module<br>loggerglue]:::core
    end

    %% Connections
    LD --> |Reads| CM
    LD --> |Uses| ES
    LD --> |Writes| LS
    ES --> |Uses| KS
    LD <--> |API Calls| IS
    SM --> |Controls| LD
    CM --> |Reads| CD
    LS --> |Writes| SLD
    
    %% Core Details Connections
    LD --- CP
    LD --- EH
    LD --- LM

    %% Click Events
    click LD "https://github.com/norbinsh/logs-downloader/blob/master/script/LogsDownloader.py"
    click CM "https://github.com/norbinsh/logs-downloader/blob/master/config/Settings.Config"
    click SM "https://github.com/norbinsh/logs-downloader/blob/master/linux_service_configuration/incapsulaLogs.conf"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef system fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef storage fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        L1[Core Component]:::core
        L2[Security Component]:::security
        L3[External Service]:::external
        L4[System Integration]:::system
        L5[Storage Component]:::storage
    end
```
