# jiyan-0525/42core_pipex architecture

> Architecture diagram of the GitHub repository jiyan-0525/42core_pipex, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jiyan-0525/42core_pipex
- Repository: https://github.com/jiyan-0525/42core_pipex

## Overview

Pipex is a command-line program that reproduces a two-command shell pipeline: it takes an input file and two command strings, connects the commands through a Unix pipe, and directs the final output to a file. The main workflow validates arguments, launches two processes, configures their file descriptors, resolves and executes each command, and waits for completion. The repository also includes libft, a custom C utility library. The graph follows the sampled runtime sources and README; details beyond those excerpts are not inferred.

Main entry points: [`src/pipex.c`](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c) (Process orchestrator), [`src/pipex_util.c`](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex_util.c) (Command execution), [`include/pipex.h`](https://github.com/jiyan-0525/42core_pipex/blob/main/include/pipex.h) (Pipex declarations), [`libft`](https://github.com/jiyan-0525/42core_pipex/tree/main/libft) (Utility functions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Pipeline runtime"]
  node_entry["Argument entry<br/>[pipex.c]"]
  node_orchestrator["Process orchestrator<br/>[pipex.c]"]
  node_child["First command process<br/>[pipex.c]"]
  node_parent["Second command process<br/>[pipex.c]"]
  node_pipe["IPC pipe<br/>[pipex.c]"]
  node_input[("Input file")]
  node_output[("Output file")]
end

subgraph group_execution["Command execution"]
  node_executor["Command execution<br/>[pipex_util.c]"]
  node_resolver["PATH resolver<br/>[pipex_util.c]"]
end

subgraph group_support["C utility library"]
  node_libft["Utility functions"]
  node_api["Pipex declarations<br/>[pipex.h]"]
  node_libftapi["Libft declarations<br/>[libft.h]"]
end

node_user(("CLI user"))
node_environment["Process environment"]
node_programs["Unix commands"]

node_user -->|"supplies arguments"| node_entry
node_entry -->|"starts pipeline"| node_orchestrator
node_orchestrator -->|"forks child"| node_child
node_orchestrator -->|"forks parent"| node_parent
node_orchestrator -->|"creates pipe"| node_pipe
node_orchestrator -->|"waits for processes"| node_orchestrator
node_child -->|"reads"| node_input
node_child -->|"writes"| node_pipe
node_parent -->|"reads"| node_pipe
node_parent -->|"writes"| node_output
node_child -->|"executes command"| node_executor
node_parent -->|"executes command"| node_executor
node_executor -->|"resolves executable"| node_resolver
node_resolver -->|"searches PATH"| node_environment
node_executor -->|"execve replaces process"| node_programs
node_executor -->|"uses string helpers"| node_libft
node_api -->|"includes declarations"| node_libftapi

click node_entry "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c"
click node_orchestrator "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c"
click node_child "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c"
click node_parent "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c"
click node_pipe "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c"
click node_executor "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex_util.c"
click node_resolver "https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex_util.c"
click node_libft "https://github.com/jiyan-0525/42core_pipex/tree/main/libft"
click node_api "https://github.com/jiyan-0525/42core_pipex/blob/main/include/pipex.h"
click node_libftapi "https://github.com/jiyan-0525/42core_pipex/blob/main/libft/libft.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_orchestrator,node_child,node_parent,node_pipe,node_input,node_output,node_user toneBlue
class node_executor,node_resolver toneAmber
class node_libft,node_api,node_libftapi toneMint
class node_environment,node_programs toneIndigo
```

## Components

### Pipeline runtime

- [Argument entry](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c): `src/pipex.c`
- [Process orchestrator](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c): `src/pipex.c`
- [First command process](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c): `src/pipex.c`
- [Second command process](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c): `src/pipex.c`
- [IPC pipe](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex.c): `src/pipex.c`
- **Input file**
- **Output file**

### Command execution

- [Command execution](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex_util.c): `src/pipex_util.c`
- [PATH resolver](https://github.com/jiyan-0525/42core_pipex/blob/main/src/pipex_util.c): `src/pipex_util.c`

### C utility library

- [Utility functions](https://github.com/jiyan-0525/42core_pipex/tree/main/libft): `libft`
- [Pipex declarations](https://github.com/jiyan-0525/42core_pipex/blob/main/include/pipex.h): `include/pipex.h`
- [Libft declarations](https://github.com/jiyan-0525/42core_pipex/blob/main/libft/libft.h): `libft/libft.h`

### Other components

- **CLI user**
- **Process environment**
- **Unix commands**

## Connections

- CLI user → Argument entry: supplies arguments (evidence: `README.md`)
- Argument entry → Process orchestrator: starts pipeline (evidence: `src/pipex.c`)
- Process orchestrator → First command process: forks child (evidence: `src/pipex.c`)
- Process orchestrator → Second command process: forks parent (evidence: `src/pipex.c`)
- Process orchestrator → IPC pipe: creates pipe (evidence: `src/pipex.c`)
- Process orchestrator → Process orchestrator: waits for processes (evidence: `src/pipex.c`)
- First command process → Input file: reads (evidence: `src/pipex.c`)
- First command process → IPC pipe: writes (evidence: `src/pipex.c`)
- Second command process → IPC pipe: reads (evidence: `src/pipex.c`)
- Second command process → Output file: writes (evidence: `src/pipex.c`)
- First command process → Command execution: executes command (evidence: `src/pipex.c`)
- Second command process → Command execution: executes command (evidence: `src/pipex.c`)
- Command execution → PATH resolver: resolves executable (evidence: `src/pipex_util.c`)
- PATH resolver → Process environment: searches PATH (evidence: `src/pipex_util.c`)
- Command execution → Unix commands: execve replaces process (evidence: `src/pipex_util.c`)
- Command execution → Utility functions: uses string helpers (evidence: `src/pipex_util.c`)
- Pipex declarations → Libft declarations: includes declarations (evidence: `include/pipex.h`)
