# cneuralnetwork/from-scratch-in-c architecture

> Architecture diagram of the GitHub repository cneuralnetwork/from-scratch-in-c, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cneuralnetwork/from-scratch-in-c
- Repository: https://github.com/cneuralnetwork/from-scratch-in-c

## Overview

##### Project Type and Purpose
- This is a monolithic, educational “scratch‐pad” C project—a library of small demos and implementations of algorithms and data structures you build from scratch.
- It is neither a client–server nor a web app, but a collection of standalone modules (Random utilities, Data Structures, Ciphers, OpenGL demos).

##### High‑Level Component Breakdown
- Four main modules (each lives in its own top‑level folder):
- Random – image/video utilities and small command‑line tools
- Data Structures – stacks, queues, linked lists, sorting routines
- Ciphers – implementations of classical substitution and transposition ciphers
- OpenGL – simple graphics algorithms using the OpenGL API
- External dependencies:
- stb_image.h / stb_image_write.h (in Random)
- OpenGL headers/libs (for the OpenGL module)

##### Relationships and Interactions
- All modules compile into separate executables or libraries; there are no direct runtime dependencies between modules.
- Random tools may link against stb_image; OpenGL demos link against the OpenGL runtime.
- The Data Structures folder can be treated as a reusable library that other modules (future ciphers, algorithms) could link against if needed.

##### Key Architectural Patterns and Principles
- Modularity: each folder is a self‑contained component
- Single responsibility: each C file implements one algorithm/concept
- Flat build process: no nested microservices, just a set of gcc commands or a simple Makefile to drive compilation

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "C Learning Suite"
        direction TB

        subgraph "Random" 
            direction TB
            Random_Elevator["elevator.c"]:::random
            Random_Extract["extract_vid.c"]:::random
            Random_Myls["myls.c"]:::random
            Random_Gray["rgb2gray.c"]:::random
        end

        subgraph "Data Structures"
            direction TB
            DS_SLL["singlelinkedlist.h"]:::data
            DS_DLL["doublelinkedlist.h"]:::data
            DS_CLL["circularlinkedlist.h"]:::data
            DS_Queue["queue.h"]:::data
            DS_Stack["stack.h"]:::data
            DS_Sort["sorting.c"]:::data
        end

        subgraph "Ciphers"
            direction TB
            Cipher_Caesar["caesar.c"]:::ciphers
            Cipher_Mono["monoalphabetic.c"]:::ciphers
            Cipher_Homo["homophonic.c"]:::ciphers
            Cipher_Playfair["playfair.c"]:::ciphers
        end

        subgraph "OpenGL"
            direction TB
            GL_Bresenham["bresenham.c"]:::opengl
            GL_MidCircle["midpoint_circle.c"]:::opengl
            GL_Transform["Matrix Transformation.c"]:::opengl
        end
    end

    stb["stb_image.h / stb_image_write.h"]:::external
    oglRuntime["OpenGL Runtime"]:::external

    stb -->|links to| Random
    oglRuntime -->|links to| OpenGL
    Data_Structures_Lib["Data Structures"]:::data -->|potential link| Ciphers

    class Random_Elevator,Random_Extract,Random_Myls,Random_Gray random
    class DS_SLL,DS_DLL,DS_CLL,DS_Queue,DS_Stack,DS_Sort data
    class Cipher_Caesar,Cipher_Mono,Cipher_Homo,Cipher_Playfair ciphers
    class GL_Bresenham,GL_MidCircle,GL_Transform opengl
    class stb,oglRuntime external

    %% Click Events
    click Random "https://github.com/cneuralnetwork/from-scratch-in-c/tree/main/Random/"
    click Random_Elevator "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Random/elevator.c"
    click Random_Extract "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Random/extract_vid.c"
    click Random_Myls "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Random/myls.c"
    click Random_Gray "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Random/rgb2gray.c"
    click DS_SLL "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/singlelinkedlist.h"
    click DS_DLL "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/doublelinkedlist.h"
    click DS_CLL "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/circularlinkedlist.h"
    click DS_Queue "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/queue.h"
    click DS_Stack "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/stack.h"
    click DS_Sort "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Data Structures/sorting.c"
    click Cipher_Caesar "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Ciphers/caesar.c"
    click Cipher_Mono "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Ciphers/monoalphabetic.c"
    click Cipher_Homo "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Ciphers/homophonic.c"
    click Cipher_Playfair "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/Ciphers/playfair.c"
    click OpenGL "https://github.com/cneuralnetwork/from-scratch-in-c/tree/main/OpenGL/"
    click GL_Bresenham "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/OpenGL/bresenham.c"
    click GL_MidCircle "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/OpenGL/midpoint_circle.c"
    click GL_Transform "https://github.com/cneuralnetwork/from-scratch-in-c/blob/main/OpenGL/Matrix Transformation.c"

    classDef random fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ciphers fill:#FFA500,stroke:#000,stroke-width:1px
    classDef opengl fill:#D8BFD8,stroke:#000,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:1px
```
