# horaceg/bch-codes architecture

> Architecture diagram of the GitHub repository horaceg/bch-codes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/horaceg/bch-codes
- Repository: https://github.com/horaceg/bch-codes

## Overview

Key Components to Include:

##### Core Mathematical Components (Bottom Layer)
- PrimeField (primeField.ml)
- Polynomials (polynome.ml)
- Finite Fields (represented by notebooks/finite_fields_basics.ipynb)
- Cantor-Zassenhaus Algorithm (cantorzass.ml)

##### Encoding/Decoding Layer (Middle Layer)
- BCH Codes (bch.ml)
- Reed-Solomon Codes (reedsolomon.ml)
- Cyclic Codes (cyclo.ml)

##### Image Processing Layer (Upper Layer)
- Components for image handling:
- BMP Handler (bmp.ml)
- Image Processing (img.ml)
- Noise Introduction (bruitage.ml)
- Error Correction (correction.ml)

##### Workflow Components
a. Image Input → BMP Processing
b. Encoding Process
c. Noise Introduction
d. Error Correction
e. Image Output

Specific Design Guidelines:

##### Component Relationships
- Use double lines for main processing pipeline

##### Processing Stages
- Input Stage (BMP reading)
- Encoding Stage (BCH/Reed-Solomon)
- Noise Introduction Stage
- Correction Stage
- Output Stage

- Top: Image I/O and user interface
- Middle: Encoding/Decoding logic
- Bottom: Mathematical foundations

##### Related Components
- Mathematical utilities together
- Image processing components
- Cluster encoding/decoding components

##### Pipeline Flow
- Clear indication of data transformation stages
- Error handling paths
- Correction feedback loops

Additional Considerations:

##### Entry points (main.ml)

Remember to maintain a balance between showing the mathematical complexity and the practical application, as this is both a theoretical and applied project.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef math fill:#d4e6f1,stroke:#2874a6
    classDef encoding fill:#d4efdf,stroke:#27ae60
    classDef image fill:#fcf3cf,stroke:#f1c40f
    classDef utility fill:#e5e7e9,stroke:#95a5a6

    %% Legend
    subgraph Legend
        Math[Mathematical Components]:::math
        Encode[Encoding/Decoding]:::encoding
        Img[Image Processing]:::image
        Util[Utilities]:::utility
    end

    %% Image Processing Layer
    subgraph Image_Layer
        BMP[BMP Handler]:::image
        ImgProc[Image Processing]:::image
        Noise[Noise Introduction]:::image
        Correct[Error Correction]:::image
        ImgIn[Image Input]:::image
        ImgOut[Image Output]:::image
        Results[Results Storage]:::image
    end

    %% Encoding/Decoding Layer
    subgraph Encoding_Layer
        BCH[BCH Codes]:::encoding
        RS[Reed-Solomon Codes]:::encoding
        Cyclic[Cyclic Codes]:::encoding
    end

    %% Mathematical Foundation Layer
    subgraph Math_Layer
        Prime[Prime Field]:::math
        Poly[Polynomials]:::math
        FF[Finite Fields]:::math
        CZ[Cantor-Zassenhaus]:::math
    end

    %% Utility Components
    subgraph Utility_Layer
        Extensions[Extensions]:::utility
        Graph[Graph Utilities]:::utility
        Main[Main Program]:::utility
    end

    %% Relationships
    ImgIn --> BMP
    BMP --> ImgProc
    ImgProc --> Noise
    Noise --> Correct
    Correct --> ImgOut
    ImgOut --> Results

    BCH --> Correct
    RS --> Correct
    Cyclic --> BCH
    Cyclic --> RS

    Prime --> Poly
    Poly --> FF
    FF --> CZ
    CZ --> BCH
    FF --> RS

    Main --> ImgProc
    Main --> BCH
    Main --> RS
    Extensions --> ImgProc
    Graph --> ImgProc

    %% Click Events
    click Prime "https://github.com/horaceg/bch-codes/blob/master/src/primeField.ml"
    click Poly "https://github.com/horaceg/bch-codes/blob/master/src/polynome.ml"
    click FF "https://github.com/horaceg/bch-codes/blob/master/notebooks/finite_fields_basics.ipynb"
    click CZ "https://github.com/horaceg/bch-codes/blob/master/src/cantorzass.ml"
    click BCH "https://github.com/horaceg/bch-codes/blob/master/src/bch.ml"
    click RS "https://github.com/horaceg/bch-codes/blob/master/src/reedsolomon.ml"
    click Cyclic "https://github.com/horaceg/bch-codes/blob/master/src/cyclo.ml"
    click BMP "https://github.com/horaceg/bch-codes/blob/master/src/bmp.ml"
    click ImgProc "https://github.com/horaceg/bch-codes/blob/master/src/img.ml"
    click Noise "https://github.com/horaceg/bch-codes/blob/master/src/bruitage.ml"
    click Correct "https://github.com/horaceg/bch-codes/blob/master/src/correction.ml"
    click Main "https://github.com/horaceg/bch-codes/blob/master/src/main.ml"
    click Extensions "https://github.com/horaceg/bch-codes/blob/master/src/extensions.ml"
    click Graph "https://github.com/horaceg/bch-codes/blob/master/src/graph.ml"
    click Results "https://github.com/horaceg/bch-codes/tree/master/images/resultat/"
    click ImgIn "https://github.com/horaceg/bch-codes/tree/master/images/"
```
