# mo7ammadd/push_swap architecture

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

- Interactive diagram: https://gitdiagram.com/mo7ammadd/push_swap
- Repository: https://github.com/mo7ammadd/push_swap

## Overview

push_swap is a command-line stack-sorting project: it accepts numeric arguments and flags, validates them, builds stack A, and is intended to choose a sorting strategy that emits stack-operation commands. The sampled main currently stops after building and printing the stack; it does not call the strategy selector or executor. The algorithm and operation modules show the intended sorting behavior, but their integration is incomplete or inconsistent. Edges reflect only calls visible in excerpts; relationships among unsampled parsing modules are omitted.

Main entry points: [`main.c`](https://github.com/mo7ammadd/push_swap/blob/main/main.c) (Program entry), [`ft_Execution.c`](https://github.com/mo7ammadd/push_swap/blob/main/ft_Execution.c) (Algorithm dispatcher), [`Validity/checkers.c`](https://github.com/mo7ammadd/push_swap/blob/main/Validity/checkers.c) (Flag and number checks), [`algorithm/medium.c`](https://github.com/mo7ammadd/push_swap/blob/main/algorithm/medium.c) (Medium sort)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and validation"]
  node_split_input["Argument splitting<br/>[split_input.c]"]
  node_split_words["Word splitting<br/>[split_words.c]"]
  node_checkers["Flag and number checks<br/>[checkers.c]"]
  node_utils["Input utilities<br/>[utils.c]"]
  node_duplicates["Duplicate checks<br/>[duplicates.c]"]
end

subgraph group_stacks["Stack construction"]
  node_stack_build["Stack builder<br/>[Stack_building.c]"]
end

subgraph group_sorting["Sorting strategies"]
  node_strategy_select["Strategy selection"]
  node_executor["Algorithm dispatcher<br/>[ft_Execution.c]"]
  node_simple["Simple sort<br/>[simple.c]"]
  node_medium["Medium sort<br/>[medium.c]"]
  node_complex["Complex sort<br/>[complex.c]"]
  node_algorithm_helpers["Sort helpers<br/>[helper_algo.c]"]
end

subgraph group_operations["Stack operations"]
  node_movement_ops["Stack commands"]
  node_movement_helpers["Movement helpers<br/>[helper.c]"]
end

node_user(("CLI user"))
node_main["Program entry<br/>[main.c]"]

node_user -->|"provides arguments"| node_main
node_main -->|"checks arguments"| node_checkers
node_main -->|"splits arguments"| node_split_input
node_main -->|"builds stack"| node_stack_build
node_main -->|"prints stack"| node_user
node_checkers -->|"validates values"| node_utils
node_checkers -->|"checks duplicates"| node_duplicates
node_stack_build -->|"parses integers"| node_utils
node_executor -->|"dispatches to"| node_simple
node_executor -->|"dispatches to"| node_medium
node_executor -->|"dispatches to"| node_complex
node_simple -->|"issues commands"| node_movement_ops
node_medium -->|"issues commands"| node_movement_ops
node_medium -->|"uses helpers"| node_algorithm_helpers
node_movement_ops -->|"uses primitives"| node_movement_helpers

click node_main "https://github.com/mo7ammadd/push_swap/blob/main/main.c"
click node_split_input "https://github.com/mo7ammadd/push_swap/blob/main/Validity/split_input.c"
click node_split_words "https://github.com/mo7ammadd/push_swap/blob/main/Validity/split_words.c"
click node_checkers "https://github.com/mo7ammadd/push_swap/blob/main/Validity/checkers.c"
click node_utils "https://github.com/mo7ammadd/push_swap/blob/main/Validity/utils.c"
click node_duplicates "https://github.com/mo7ammadd/push_swap/blob/main/Validity/duplicates.c"
click node_strategy_select "https://github.com/mo7ammadd/push_swap/blob/main/Validity/determine_the_way.c"
click node_stack_build "https://github.com/mo7ammadd/push_swap/blob/main/Stack_building.c"
click node_executor "https://github.com/mo7ammadd/push_swap/blob/main/ft_Execution.c"
click node_simple "https://github.com/mo7ammadd/push_swap/blob/main/algorithm/simple.c"
click node_medium "https://github.com/mo7ammadd/push_swap/blob/main/algorithm/medium.c"
click node_complex "https://github.com/mo7ammadd/push_swap/blob/main/algorithm/complex.c"
click node_algorithm_helpers "https://github.com/mo7ammadd/push_swap/blob/main/algorithm/helper_algo.c"
click node_movement_ops "https://github.com/mo7ammadd/push_swap/blob/main/Move/Switching_movements.c"
click node_movement_helpers "https://github.com/mo7ammadd/push_swap/blob/main/Move/helper.c"

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_split_input,node_split_words,node_checkers,node_utils,node_duplicates,node_user toneBlue
class node_stack_build toneAmber
class node_strategy_select,node_executor,node_simple,node_medium,node_complex,node_algorithm_helpers toneMint
class node_movement_ops,node_movement_helpers toneRose
class node_main toneTeal
```

## Components

### Input and validation

- [Argument splitting](https://github.com/mo7ammadd/push_swap/blob/main/Validity/split_input.c): `Validity/split_input.c`
- [Word splitting](https://github.com/mo7ammadd/push_swap/blob/main/Validity/split_words.c): `Validity/split_words.c`
- [Flag and number checks](https://github.com/mo7ammadd/push_swap/blob/main/Validity/checkers.c): `Validity/checkers.c`
- [Input utilities](https://github.com/mo7ammadd/push_swap/blob/main/Validity/utils.c): `Validity/utils.c`
- [Duplicate checks](https://github.com/mo7ammadd/push_swap/blob/main/Validity/duplicates.c): `Validity/duplicates.c`

### Stack construction

- [Stack builder](https://github.com/mo7ammadd/push_swap/blob/main/Stack_building.c): `Stack_building.c`

### Sorting strategies

- [Strategy selection](https://github.com/mo7ammadd/push_swap/blob/main/Validity/determine_the_way.c): `Validity/determine_the_way.c`
- [Algorithm dispatcher](https://github.com/mo7ammadd/push_swap/blob/main/ft_Execution.c): `ft_Execution.c`
- [Simple sort](https://github.com/mo7ammadd/push_swap/blob/main/algorithm/simple.c): `algorithm/simple.c`
- [Medium sort](https://github.com/mo7ammadd/push_swap/blob/main/algorithm/medium.c): `algorithm/medium.c`
- [Complex sort](https://github.com/mo7ammadd/push_swap/blob/main/algorithm/complex.c): `algorithm/complex.c`
- [Sort helpers](https://github.com/mo7ammadd/push_swap/blob/main/algorithm/helper_algo.c): `algorithm/helper_algo.c`

### Stack operations

- [Stack commands](https://github.com/mo7ammadd/push_swap/blob/main/Move/Switching_movements.c): `Move/Switching_movements.c`
- [Movement helpers](https://github.com/mo7ammadd/push_swap/blob/main/Move/helper.c): `Move/helper.c`

### Other components

- **CLI user**
- [Program entry](https://github.com/mo7ammadd/push_swap/blob/main/main.c): `main.c`

## Connections

- CLI user → Program entry: provides arguments (evidence: `main.c`)
- Program entry → Flag and number checks: checks arguments (evidence: `main.c`)
- Program entry → Argument splitting: splits arguments (evidence: `main.c`)
- Program entry → Stack builder: builds stack (evidence: `main.c`)
- Program entry → CLI user: prints stack (evidence: `main.c`)
- Flag and number checks → Input utilities: validates values (evidence: `Validity/checkers.c`)
- Flag and number checks → Duplicate checks: checks duplicates (evidence: `Validity/checkers.c`)
- Stack builder → Input utilities: parses integers (evidence: `Stack_building.c`)
- Algorithm dispatcher → Simple sort: dispatches to (evidence: `ft_Execution.c`)
- Algorithm dispatcher → Medium sort: dispatches to (evidence: `ft_Execution.c`)
- Algorithm dispatcher → Complex sort: dispatches to (evidence: `ft_Execution.c`)
- Simple sort → Stack commands: issues commands (evidence: `algorithm/simple.c`)
- Medium sort → Stack commands: issues commands (evidence: `algorithm/medium.c`)
- Medium sort → Sort helpers: uses helpers (evidence: `algorithm/medium.c`)
- Stack commands → Movement helpers: uses primitives (evidence: `Move/Switching_movements.c`)
