# zelhajou/ft_unix_minishell architecture

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

- Interactive diagram: https://gitdiagram.com/zelhajou/ft_unix_minishell
- Repository: https://github.com/zelhajou/ft_unix_minishell

## Overview

##### Main Components

a) Input Processing Layer:
- Input Reader (using readline)
- Syntax Checker
- Tokenizer
- Parser/AST Builder

b) Execution Layer:
- Command Executor
- Built-in Commands Handler
- External Commands Handler
- Pipeline Manager
- Redirection Handler

c) Environment Management Layer:
- Environment Variables Manager
- Variable Expansion Handler

d) Signal Handling Layer:
- Signal Controllers (SIGINT, SIGQUIT, EOF)

##### Specific Implementation Details

Create distinct sections for:

a) Input Processing Pipeline:
**User Input → Syntax Checker → Tokenizer → Parser → AST Builder**

b) Command Execution Flow:
**AST → Command Type Check → Built-in/External Execution → Output Handling**

##### Detailed Component Specifications

For each major component, include:
- Input/Output specifications
- Key functions
- Dependencies on other components

##### Technical Details

For each component, specify:
- Key data structures used
- Important function calls
- Error handling mechanisms
- Inter-process communication methods

**[Input Layer]**
- ↓
**[Processing Layer]**
- ↓
**[Execution Layer]**
- ↓
**[Output Layer]**

##### Additional Elements

Include:
- Version information
- Key dependencies (readline, libft)
- Error handling flows
- Memory management considerations

##### Implementation Notes

- Clear separation of concerns
- Data flow between components
- Error handling paths
- Process creation and management
- File descriptor management

##### Specific Project Elements

Highlight:
- AST structure and traversal
- Pipeline implementation
- Built-in command handling
- Environment variable management
- Signal handling mechanisms

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Components]:::core
        L2[Execution Components]:::execution
        L3[Environment Components]:::environment
        L4[Signal Components]:::signal
        L5[Utility Components]:::utility
    end

    subgraph "Input Processing Layer"
        Input[User Input]:::core
        SyntaxChecker[Syntax Checker]:::core
        Tokenizer[Tokenizer]:::core
        Parser[Parser/AST Builder]:::core
    end

    subgraph "Execution Layer"
        CmdExec[Command Executor]:::execution
        BuiltIn[Built-in Commands Handler]:::execution
        External[External Commands Handler]:::execution
        Pipeline[Pipeline Manager]:::execution
        Heredoc[Heredoc Handler]:::execution
        CmdControl[Command Execution Controller]:::execution
        PathUtils[Path Utilities]:::execution
    end

    subgraph "Environment Layer"
        EnvManager[Environment Variables Manager]:::environment
        VarExpand[Variable Expansion Handler]:::environment
        EnvInit[Environment Initialization]:::environment
    end

    subgraph "Control Layer"
        SignalCtrl[Signal Controllers]:::signal
        ShellUtils[Shell Utilities]:::utility
    end

    Input --> SyntaxChecker
    SyntaxChecker --> Tokenizer
    Tokenizer --> Parser

    Parser --> CmdExec
    CmdExec --> |Built-in| BuiltIn
    CmdExec --> |External| External
    CmdExec --> Pipeline
    Pipeline --> Heredoc
    CmdControl --> CmdExec
    PathUtils --> External

    EnvManager --> VarExpand
    EnvInit --> EnvManager
    VarExpand --> CmdExec

    SignalCtrl -.-> CmdExec
    ShellUtils -.-> CmdExec

    click SyntaxChecker "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/01_input_validation/syntax_checker.c"
    click Tokenizer "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/02_tokenization/tokenizer.c"
    click Parser "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/03_parsing/parser.c"
    click CmdExec "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/executor.c"
    click BuiltIn "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/05_builtin/builtin_commands.c"
    click Pipeline "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/process_pipeline_management.c"
    click Heredoc "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/heredoc_handling.c"
    click EnvManager "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/07_env_var_expansion/env_managment.c"
    click VarExpand "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/07_env_var_expansion/variable_expansion.c"
    click SignalCtrl "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/06_signals/signal_handlers.c"
    click CmdControl "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/command_execution_control.c"
    click EnvInit "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/initialization/environment_init.c"
    click PathUtils "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/04_execution/path_utilities.c"
    click ShellUtils "https://github.com/zelhajou/ft_unix_minishell/blob/main/minishell/src/utils/shell_utilities.c"

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef execution fill:#2ecc71,stroke:#27ae60,color:white
    classDef environment fill:#f1c40f,stroke:#f39c12,color:black
    classDef signal fill:#e74c3c,stroke:#c0392b,color:white
    classDef utility fill:#9b59b6,stroke:#8e44ad,color:white
```
