# kou1okada/lesser-parallel architecture

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

- Interactive diagram: https://gitdiagram.com/kou1okada/lesser-parallel
- Repository: https://github.com/kou1okada/lesser-parallel

## Overview

##### Project Type Analysis
- Command processing flow
- Job management
- Input/Output handling
- Embedding functionality

##### Main Components

a) Input Processing Layer:
- STDIN input handler
- Command-line arguments parser
- Options processor (-j, -e, -h)

b) Core Processing Components:
- Job Queue Manager
- Parallel Execution Controller
- Placeholder Processor
- Job Counter/Sequencer

c) Embedding System:
- Script Embedding Handler
- Marker Management (Lesser Parallel for Embedding markers)

**┌─────────────────────────────────────────┐**
- Input Sources              │
- (STDIN, Command Line, Environment Vars)│
- ┬───────────────────────┘
- ↓
**┌─────────────────────────────────────────┐**
- Command Line Parser             │
- (-j, -e, -h options handling)      │
- ┬───────────────────────┘
- ↓
**┌─────────────────────────────────────────┐**
- Parallel Execution Core          │
- ┬───────────────────────┤
- Job Queue     │  Placeholder          │
- Manager       │  Processor            │
- ┼───────────────────────┤
- Job Counter   │  Parallel             │
- ({#})        │  Controller           │
- ┴───────────────────────┘
- ↓
**┌─────────────────────────────────────────┐**
- Output Handler                │
- ┘

##### Important Elements to Highlight

- How input flows from STDIN to the parallel execution core
- How jobs are distributed and managed
- Flow of placeholder substitution

b) Control Points:
- LESSER_PARALLEL_MAX_JOBS environment variable influence
- Job count limitation (-j option)
- Embedding functionality trigger points

c) Placeholder Processing:
- Input String → Placeholder Detector → Substitution Rules
- {} → Full line
- {.} → No extension
- {/} → Basename
- {//} → Dirname
- {/.} → Basename without suffix
- {#} → Job sequence number

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IS[Input Sources]
        STDIN[STDIN]
        CMD[Command Line Args]
        ENV[Environment Variables]
        IS --> STDIN
        IS --> CMD
        IS --> ENV
    end

    subgraph Parser
        CLP[Command Line Parser]
        OH[Options Handler]
        STDIN --> CLP
        CMD --> CLP
        CLP --> OH
    end

    subgraph "Parallel Execution Core"
        JQM[Job Queue Manager]
        PP[Placeholder Processor]
        JC[Job Counter]
        PC[Parallel Controller]
        OH --> JQM
        JQM --> PP
        PP --> PC
        JC --> PC
    end

    subgraph "Placeholder Rules"
        PR[Rules Engine]
        PF["{} - Full Line"]
        PE["'{.}' - No Extension"]
        PB["'{/}' - Basename"]
        PD["'{//}' - Dirname"]
        PBS["'{/.}' - Basename No Suffix"]
        PSN["'{#}' - Sequence Number"]
        PR --> PF
        PR --> PE
        PR --> PB
        PR --> PD
        PR --> PBS
        PR --> PSN
    end

    PP --> PR
    PC --> OUT[Output Handler]

    subgraph "Embedding System"
        EH[Embedding Handler]
        MM[Marker Management]
        OH --> EH
        EH --> MM
    end

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef input fill:#d0e1f9,stroke:#333
    classDef process fill:#d4edda,stroke:#333
    classDef control fill:#fff3cd,stroke:#333
    classDef output fill:#f8d7da,stroke:#333

    class IS,STDIN,CMD,ENV input
    class CLP,OH,JQM,PP,PC process
    class JC control
    class OUT output
    class PR,PF,PE,PB,PD,PBS,PSN process
    class EH,MM control

    click CLP "https://github.com/kou1okada/lesser-parallel/tree/master/lesser-parallel"
    click IS "https://github.com/kou1okada/lesser-parallel/tree/master/lesser-parallel"
    click OUT "https://github.com/kou1okada/lesser-parallel/tree/master/lesser-parallel"
    click EH "https://github.com/kou1okada/lesser-parallel/tree/master/lesser-parallel"
    click JQM "https://github.com/kou1okada/lesser-parallel/tree/master/lesser-parallel"
```
