# mr-youbella/c_craft architecture

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

- Interactive diagram: https://gitdiagram.com/mr-youbella/c_craft
- Repository: https://github.com/mr-youbella/c_craft

## Overview

##### Project type and purpose
- This is an open-source, CLI-based “exercise and testing” tool (called C Craft) for learning and practicing C programming.
- It provides shells scripts as entrypoints, builds and runs C exercises, and executes test suites (functions, levels, exams).

##### File structure
- Top-level directories:
- Processing/       – Contains Makefile and core build scripts.
- Quizzes/          – Holds individual quiz scripts (e.g., quiz1.sh).
- Tests/            – Organized into Exams, Functions, Level subdirectories; contains test code for each exercise.
- Scripts under Processing/Scripts handle installation, aliases, ANSI formatting, status reporting, and bulk testing.
- README.md describes usage: user runs a single `ccraft` command.

##### README for additional insights
- Entrypoint: `bash -c "$(curl …)"` then `ccraft` CLI.
- Purpose: deliver C exercises, quizzes, exams; test user solutions.
- No external web or database; purely file-based, script-oriented, shell + C.

a. Main components
- User / Shell: The user’s terminal sending commands.
- CLI Entrypoint (`ccraft` script): Dispatches subcommands (exercises, tests, quizzes).
- Script Library (Processing/Scripts): install.sh, alias.sh, status.sh, test_all_exercises.sh, ansi.sh.
- Build Engine (Processing/Makefile): compiles C exercises into binaries.
- Exercise Modules (src in Processing?): each C file under Tests/… is compiled and/or tested.
- Test Harness (Tests/{Functions,Level,Exams}): test suites that validate exercise binaries.
- Quizzes (Quizzes/*.sh): stand-alone challenge scripts.
- System Tools: bash, gcc/cc, make.
b. Relationships and data flow
1. User types `ccraft` → CLI Entrypoint.
2. Entrypoint parses subcommand → invokes one of:
– Script Library for setup/status/tests
– Build Engine (Makefile) to compile exercises
– Quizzes module to run a quiz script
3. Build Engine uses gcc via Makefile → produces exercise binaries.
4. Test Harness runs these binaries with input and compares output.
c. Architectural patterns / design principles
- Modular separation: scripts separated from C code, tests separated by category.
- Conventions: one directory per concern (build, quiz, tests).
- Shell orchestration layer controlling build and test.
d. Key technologies
– Shell scripting (bash)
– GNU Make
– GCC (C compiler)
– File-based test definitions

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User layer
    User["User Shell"]:::system

    %% CLI Entrypoint
    subgraph "CLI Entrypoint"
        install["install.sh"]:::script
        alias["alias.sh"]:::script
    end

    %% Script Library
    subgraph "Script Library"
        ansi["ansi.sh"]:::script
        status["status.sh"]:::script
        testAll["test_all_exercises.sh"]:::script
        printCraft["print_cCraft.sh"]:::script
    end

    %% Build Engine
    subgraph "Build Engine"
        Makefile["Makefile"]:::build
        GCC["GCC (gcc/cc)"]:::tool
    end

    %% Quiz Modules
    subgraph "Quiz Modules"
        quiz1["quiz1.sh"]:::quiz
    end

    %% Exercise Modules
    subgraph "Exercise Modules"
        funcs["Tests/Functions/"]:::code
        levels["Tests/Level/"]:::code
    end

    %% Test Harness
    subgraph "Test Harness"
        subgraph "Functions & Level Tests"
            lvlScript["lvl.bash"]:::script
        end
        subgraph "Exams"
            examScript["exam00.sh"]:::script
            examTests["Tests_Exam00/"]:::code
        end
    end

    %% Binaries and Reporting
    binaries["Exercise Binaries"]:::artifact
    report["Report Output"]:::artifact

    %% Connections
    User -->|"runs ccraft"| install
    User --> alias
    install -->|"initializes CLI"| printCraft
    alias --> printCraft
    printCraft --> ansi
    printCraft --> status
    printCraft --> testAll
    printCraft --> Makefile
    printCraft --> quiz1

    testAll --> funcs
    testAll --> levels
    testAll --> lvlScript

    Makefile -->|"invokes"| GCC
    GCC -->|"compiles C files"| binaries

    funcs --> binaries
    levels --> binaries
    binaries --> lvlScript
    lvlScript --> report
    examScript --> report
    examTests --> report
    quiz1 --> report

    report --> User

    %% Click Events
    click install "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/install.sh"
    click alias "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/alias.sh"
    click ansi "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/ansi.sh"
    click status "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/status.sh"
    click testAll "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/test_all_exercises.sh"
    click printCraft "https://github.com/mr-youbella/c_craft/blob/main/Processing/Scripts/print_cCraft.sh"
    click Makefile "https://github.com/mr-youbella/c_craft/tree/main/Processing/Makefile"
    click quiz1 "https://github.com/mr-youbella/c_craft/blob/main/Quizzes/quiz1.sh"
    click funcs "https://github.com/mr-youbella/c_craft/tree/main/Tests/Functions/"
    click levels "https://github.com/mr-youbella/c_craft/tree/main/Tests/Level/"
    click lvlScript "https://github.com/mr-youbella/c_craft/blob/main/Tests/Level/lvl.bash"
    click examScript "https://github.com/mr-youbella/c_craft/blob/main/Tests/Exams/exam00/exam00.sh"
    click examTests "https://github.com/mr-youbella/c_craft/tree/main/Tests/Exams/exam00/Tests_Exam00/"

    %% Styles
    classDef script fill:#c6f1c6,stroke:#2d862d
    classDef build fill:#c6dfff,stroke:#1a4f8b
    classDef quiz fill:#f9e79f,stroke:#b7950b
    classDef code fill:#f5cba7,stroke:#af601a
    classDef tool fill:#e8daef,stroke:#6c3483,stroke-dasharray: 5 5
    classDef artifact fill:#d6eaf8,stroke:#2471a3
    classDef system fill:#f8f9f9,stroke:#515a5a,stroke-dasharray: 5 5
```
