# ashurov-imomali/hamming_8_4 architecture

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

- Interactive diagram: https://gitdiagram.com/ashurov-imomali/hamming_8_4
- Repository: https://github.com/ashurov-imomali/hamming_8_4

## Overview

##### Project Type and Purpose
- Project Type: A single-purpose C++ command-line application.
- Purpose: To encode a 4-bit number into an 8-bit Hamming code (with parity bits) and then decode an 8-bit string with single-bit error correction. It provides an interactive menu for users to enter numbers or bit strings.

##### File Structure
- Top-Level Files:
- CMakeLists.txt: Provides build instructions using CMake.
- .gitignore: Lists files that shouldn’t be tracked by Git.
- Readme.md: Contains project description and build/run instructions.
- Source Code Files:
- main.cpp and main.h: Likely handle the interactive user menu and overall program flow (input, menu selection, displaying output).
- hamming.cpp and hamming.h: Contain the core functionality for encoding and decoding using the Hamming (8,4) algorithm.

##### Extract Key Information from the README
- The README describes the functionality (code and decode with error correction) and shows sample interactions.
- It gives build instructions with both direct compiler and CMake options.
- The project clearly has a modular design: one module for user interaction and control (main) and one core module for Hamming code operations.

a. Main Components:
- User Interface / Controller Module:
- Represented by main.cpp and main.h.
- Handles interactive menu, user input, and program flow.
- Hamming Code Engine:
- Represented by hamming.cpp and hamming.h.
- Encapsulates encoding (4-bit to 8-bit conversion with parity) and decoding (error correction).
- Build and Configuration:
- CMakeLists.txt and related build scripts.
- It’s not part of runtime architecture but drives how components are compiled together.

b. Relationships and Interactions:
- The main module acts as the entry point. It receives user input from the console and directs operations.
- When encoding/decoding is needed, main.cpp calls the functions in hamming.cpp/hamming.h.
- Outputs from the Hamming module are then displayed on the console.
- Build scripts ensure that all source files are compiled and linked together.

c. Architectural Design Patterns and Principles:
- Separation of Concerns: The project cleanly separates user interaction logic (main) from core business logic (Hamming code operations).
- Modular Design: Functional units are encapsulated in their own modules (files), making the program easy to test and extend.

d. Relevant Technologies, Frameworks, and Libraries:
- C++ programming language.
- CMake for managing build configuration.
- GNU Compiler (g++) as shown in the README build instructions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    BuildSystem["Build System (CMakeLists.txt)"]:::build
    MainModule["Main Module (main.cpp/main.h)"]:::ui
    HammingEngine["Hamming Code Engine (hamming.cpp/hamming.h)"]:::engine

    %% Edges
    BuildSystem -->|"build_dep"| MainModule
    BuildSystem -->|"build_dep"| HammingEngine
    MainModule -->|"Input_Data"| HammingEngine
    HammingEngine -->|"Process_Results"| MainModule

    %% Click Events
    click MainModule "https://github.com/ashurov-imomali/hamming_8_4/blob/main/main.cpp"
    click MainModule "https://github.com/ashurov-imomali/hamming_8_4/blob/main/main.h"
    click HammingEngine "https://github.com/ashurov-imomali/hamming_8_4/blob/main/hamming.cpp"
    click HammingEngine "https://github.com/ashurov-imomali/hamming_8_4/blob/main/hamming.h"
    click BuildSystem "https://github.com/ashurov-imomali/hamming_8_4/blob/main/CMakeLists.txt"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef engine fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef build fill:#FFFFE0,stroke:#000,stroke-width:2px;
```
