# peff/mfm architecture

> Architecture diagram of the GitHub repository peff/mfm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/peff/mfm
- Repository: https://github.com/peff/mfm

## Overview

##### Main Components Identification
The system should be represented with these key components:

a) Core Engine:
- Central Perl Script (mfm.pl)
- Core Libraries (lib/MFM/*.pm)

b) Rule System:
- Rule Templates Directory Structure
- Base Rules
- Language-Specific Rules (C, Perl, Shell, LaTeX)
- Documentation Rules

c) Bootstrap System
- Bootstrap Script
- Configuration System

##### Component Relationships and Flow

a) Primary Processing Flow:
**Input Files → MFM Core Engine → Rule Processing → Makefile Generation**

b) Rule Template Hierarchy:
**Base Rules → Language-Specific Rules → Custom Rules**

##### Detailed Component Breakdown

a) Core Engine Components:
- MFM.pm (Main library)
- File.pm (File handling)
- Path.pm (Path management)
- Target.pm (Target processing)

b) Rule Categories (Show as grouped components):
- Base Rules (rules/base/*)
- Language Rules (C, Perl, Shell, LaTeX)
- Documentation Rules (AsciiDoc, HTML, PDF)
- Installation Rules

c) Configuration System:
- conf-* files
- Bootstrap mechanism

##### The configuration and bootstrap mechanism

Remember to show how the system achieves its main goals:
- Portable Makefile generation
- Minimal user effort
- Extensibility through rule templates

This system design should clearly illustrate how MFM transforms high-level build specifications into portable Makefiles through its rule-based processing system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Engine"]
        MFM["MFM Core Script"]:::core
        MFMLib["MFM Main Library"]:::core
        File["File Handler"]:::core
        Path["Path Manager"]:::core
        Target["Target Processor"]:::core
    end

    subgraph Rules["Rule System"]
        BaseRules["Base Rules"]:::rules
        LangRules["Language Rules"]:::rules
        DocRules["Documentation Rules"]:::rules

        subgraph LangSpecific["Language-Specific Rules"]
            CRules["C Rules"]:::rules
            PerlRules["Perl Rules"]:::rules
            ShellRules["Shell Rules"]:::rules
            LaTeXRules["LaTeX Rules"]:::rules
        end

        subgraph DocSpecific["Documentation-Specific Rules"]
            AsciiDoc["AsciiDoc Rules"]:::rules
            HTMLPS["HTML/PS Rules"]:::rules
            PDF["PDF Rules"]:::rules
        end
    end

    subgraph Config["Configuration System"]
        Bootstrap["Bootstrap System"]:::config
        CConf["C Config"]:::config
        PerlConf["Perl Config"]:::config
        LaTeXConf["LaTeX Config"]:::config
        AsciiDocConf["AsciiDoc Config"]:::config
    end

    subgraph Install["Installation System"]
        InstallRules["Install Rules"]:::install
        InstallScript["Install Script"]:::install
        InstallConf["Install Config"]:::install
    end

    Input["Project Specifications"]:::input --> MFM
    MFM --> MFMLib
    MFMLib --> |Uses| File
    MFMLib --> |Uses| Path
    MFMLib --> |Uses| Target

    MFMLib --> |Processes| BaseRules
    BaseRules --> |Extends| LangRules
    BaseRules --> |Extends| DocRules

    LangRules --> LangSpecific
    DocRules --> DocSpecific

    Bootstrap --> |Configures| Config
    Config --> |Applies to| Rules

    MFMLib --> |Generates| Output["Makefile Output"]:::output

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef rules fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#e67e22,stroke:#d35400,color:white
    classDef install fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef input fill:#9b59b6,stroke:#8e44ad,color:white
    classDef output fill:#e74c3c,stroke:#c0392b,color:white

    click MFM "https://github.com/peff/mfm/blob/master/mfm.pl"
    click MFMLib "https://github.com/peff/mfm/blob/master/lib/MFM.pm"
    click File "https://github.com/peff/mfm/blob/master/lib/MFM/File.pm"
    click Path "https://github.com/peff/mfm/blob/master/lib/MFM/Path.pm"
    click Target "https://github.com/peff/mfm/blob/master/lib/MFM/Target.pm"
    click BaseRules "https://github.com/peff/mfm/tree/master/rules/base/"
    click CRules "https://github.com/peff/mfm/tree/master/rules/c/"
    click PerlRules "https://github.com/peff/mfm/tree/master/rules/perl/"
    click ShellRules "https://github.com/peff/mfm/tree/master/rules/shell/"
    click LaTeXRules "https://github.com/peff/mfm/tree/master/rules/latex/"
    click DocRules "https://github.com/peff/mfm/tree/master/rules/doc/"
    click AsciiDoc "https://github.com/peff/mfm/tree/master/rules/doc/asciidoc/"
    click HTMLPS "https://github.com/peff/mfm/tree/master/rules/doc/htmlps/"
    click PDF "https://github.com/peff/mfm/tree/master/rules/doc/pspdf/"
    click Bootstrap "https://github.com/peff/mfm/tree/master/bootstrap"
    click CConf "https://github.com/peff/mfm/tree/master/rules/c/base/conf-cc"
    click PerlConf "https://github.com/peff/mfm/tree/master/rules/perl/base/conf-perl"
    click LaTeXConf "https://github.com/peff/mfm/tree/master/rules/latex/base/conf-latex"
    click AsciiDocConf "https://github.com/peff/mfm/tree/master/rules/doc/asciidoc/base/conf-asciidoc"
    click InstallRules "https://github.com/peff/mfm/tree/master/rules/shell/install/"
    click InstallScript "https://github.com/peff/mfm/blob/master/rules/shell/install/do_install.sh"
    click InstallConf "https://github.com/peff/mfm/tree/master/rules/shell/install/conf-home"
```
