How biostumpf/42_common_core works
1. This repository is a 42 Common Core monorepo, but it is not one integrated application. It contains several independent C projects, each with its own Makefile, entry point, and build artifacts. For architecture purposes, treat each top-level project directory as a separate executable or library boundary.
2. The shared foundation is libft (and in some projects, local copies of it). This is a custom utility library providing string, memory, list, and conversion helpers, plus some project-specific extras such as printf and get_next_line variants in certain subfolders. It is a supporting layer rather than a central runtime service.
3. get_next_line is a standalone file-reading module/library. Its core data flow is: file descriptor input → buffered chunk reads → line extraction → returned lines. It is used as an educational primitive for stream processing and appears both as its own project and as embedded source in other folders.
4. printf is another standalone library project that reimplements formatted output. Its architecture is split into parsing, string handling, and number formatting helpers feeding a printf-style dispatcher. It is primarily a library boundary, not an application with business logic.
5. pipex is a Unix process-pipeline executor. Its flow is: command-line arguments and environment parsing → path resolution → process creation (fork) → pipe wiring → command execution (exec). The bonus variant adds heredoc handling and additional pipeline behavior. This project is centered on IPC and process orchestration.
6. push_swap is a two-stack sorting engine. The main flow is: parse and validate integer arguments → build stack state → choose a sorting strategy → emit stack operations. The code is split into parsing, stack operations, small-sort logic, quicksort-like helpers, and operation-printing modules. Output is not a sorted array but a sequence of allowed commands.
7. philo is a concurrent simulation of the dining philosophers problem. Its architecture revolves around timing, worker threads, and shared simulation state: initialize philosophers → run eat/sleep/think cycles → detect starvation or completion. The split into eat.c, think_sleep.c, simulation.c, and time.c reflects the separation between behavior, orchestration, and timing control.
8. fdf is the graphical project and the most pipeline-like in terms of data transformation. The flow is: parse a .fdf map file → build a grid representation → apply scaling/rotation/projection transforms → draw line segments via MiniLibX → react to keyboard and mouse events. Supporting modules handle color interpolation, cleanup, parsing helpers, and rendering.
9. fdf also contains a clear boundary between data preparation and presentation. Parsing files and linked-list/grid utilities build the model, while rendering.c, draw_lines.c, rotations.c, scale_transform.c, and event handlers form the view/controller side. This makes it the best candidate for a diagram with separate input, transform, render, and interaction layers.
10. The repository includes multiple sample input sets and test assets, especially for fdf maps and push_swap scripts. These are not runtime dependencies but validation fixtures used to exercise the algorithms and visual output.
11. A recurring architectural pattern across the repo is “single-purpose CLI or library per folder.” Each project owns its own headers, helper modules, and build configuration, with little cross-project reuse beyond conceptually similar libft code copied into each project’s local workspace.
12. External/runtime dependencies matter only in a few places: MiniLibX for fdf graphics, POSIX process and pipe primitives for pipex, and pthread-based concurrency for philo. Everything else is mostly self-contained ANSI C plus local utility libraries.
Main entry points: libft libft · pipex Exec flow · fdf fdf · push_swap push_swap
Components 20
Shared foundation
Reusable utility and standalone library boundaries
Projects
Independent 42 Common Core executables and libraries
- fdf · Map renderer built on MiniLibX
fdf - Parse map · Reads .fdf data and builds the grid/model representation
fdf - Transform · Scaling, rotation, projection, and color interpolation
fdf - Render UI · Line drawing and event-driven presentation layer
fdf - pipex · Unix pipeline executor with command and pipe orchestration
pipex - Setup · Argument parsing and environment/path resolution
pipex - Exec flow · Forks, wires pipes, and launches commands
pipex - Heredoc · Bonus input handling and extended pipeline behavior
pipex - push_swap · Two-stack sorter that emits allowed operations
push_swap - Parse ints · Converts and validates command-line integers into stack state
push_swap - Strategy · Chooses small-sort or quicksort-like strategy
push_swap - Ops emit · Stack operations and printed move sequences
push_swap - philo · Dining philosophers simulation built around threads and timing
philo - State timing · Shared simulation state, timekeeping, and lifecycle control
philo - Worker cycle · Eat, sleep, and think transitions for each philosopher
philo
Connections 25
- fdf → Parse map: starts with · Loads map data before any rendering
- Parse map → Transform: feeds · Parsed grid becomes drawable geometry
- Transform → Render UI: draws into · Projection and coloring feed line rendering
- Render UI → libft: uses · Relies on local utility helpers
- Parse map → GNL: reads via · Uses buffered line input for map files
- fdf → Maps: validated by · Sample inputs exercise parsing and projection
- pipex → Setup: begins with · Parses argv and resolves execution paths
- Setup → Exec flow: drives · Prepared commands flow into process orchestration
- Exec flow → Heredoc: bonus path · Optional heredoc handling extends the pipeline
- Exec flow → libft: uses · Depends on local string and list helpers
- Exec flow → GNL: uses · Embedded reader support for input-related behavior
- push_swap → Parse ints: starts with · Validates and normalizes integer arguments
- Parse ints → Strategy: feeds · Parsed stack state selects a sorting plan
- Strategy → Ops emit: emits · Strategy is expressed as allowed stack commands
- Strategy → libft: uses · Reuses local utilities and list helpers
- push_swap → Scripts: validated by · Shell scripts and checker assets exercise behavior
- philo → State timing: orchestrates · Sets up global state and timing constraints
- State timing → Worker cycle: runs · Worker lifecycle loops execute simulation behavior
- Worker cycle → State timing: updates · Cycles consult shared state and starvation rules
- philo → libft: uses · Relies on local input and utility helpers
- printf → libft: builds on · Formatted output library depends on utility routines
- GNL → libft: builds on · Line reader uses basic memory and string helpers
- fdf → libft: embeds copy of · Project carries its own local utility workspace
- pipex → libft: embeds copy of · Project carries its own local utility workspace
- push_swap → libft: embeds copy of · Project carries its own local utility workspace