# demicuz/s21_matrix_plus architecture

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

- Interactive diagram: https://gitdiagram.com/demicuz/s21_matrix_plus
- Repository: https://github.com/demicuz/s21_matrix_plus

## Overview

##### Project type and purpose
- This is a small C++ library (“s21matrix+”) that implements a Matrix class and basic matrix operations.
- It includes a sample `main.cpp`, a test harness (`test.cpp` using GoogleTest), and build configurations (CMakeLists.txt, Makefile).

##### File structure
- Top level:
- `.clang-format`, `.gitignore` – code/style tooling
- `CMakeLists.txt`, `Makefile` – build and configuration
- `README.md` – project overview
- `src/` folder:
- `s21_matrix_oop.hpp` – class declaration
- `s21_matrix_oop.cpp` – class implementation
- `main.cpp` – demo / sample usage entry point
- `test.cpp` – GoogleTest test suite

##### Key README insights
- Core focus on C++ class design, move/copy semantics, exception safety
- Testing via GoogleTest

a. Matrix Class Module
- Header (`s21_matrix_oop.hpp`)
- Implementation (`s21_matrix_oop.cpp`)
- Public methods: constructor, destructor, copy/move, arithmetic ops, exceptions
b. Application entry point
- `main.cpp` demonstrating usage of the Matrix class
c. Test Harness
- `test.cpp` using GoogleTest
- Depends on Matrix class interfaces
d. Build System
- CMake / Makefile orchestrating compilation, linking, test execution
e. Tooling
- `.clang-format` for styling
- GoogleTest external dependency

##### Relationships and interactions
- The Build System pulls in source files and external GoogleTest libraries.
- The Matrix Class Module is compiled into an object/library.
- `main.cpp` and `test.cpp` both “use” or “link against” the Matrix library.
- Tests validate class behavior; main demonstrates runtime usage.

##### Architectural patterns & design principles
- Single-responsibility: one class for all matrix operations
- OOP essentials: encapsulation, RAII, copy/move semantics
- Layer separation: library core vs. application vs. tests

##### Essential elements
- Clear component names (e.g., “s21::Matrix Class”)
- Interfaces exposed (public API)
- External dependency (GoogleTest)
- Build orchestration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Subgraph: Library Core
    subgraph "Library Core"
        direction TB
        MatrixHeader["s21::Matrix Class<br/>(Header)"]:::library
        MatrixImpl["s21::Matrix Class<br/>(Implementation)"]:::library
    end

    %% Subgraph: Application
    subgraph "Application"
        direction TB
        MainApp["Main App<br/>(main.cpp)"]:::application
    end

    %% Subgraph: Test Suite
    subgraph "Test Suite"
        direction TB
        TestSuite["GoogleTest Suite<br/>(test.cpp)"]:::application
        GoogleTest["GoogleTest<br/>(External)"]:::external
    end

    %% Subgraph: Build & Tooling
    subgraph "Build & Tooling"
        direction TB
        BuildSystem1["CMakeLists.txt"]:::build
        BuildSystem2["Makefile"]:::build
        Tool1[".clang-format"]:::tooling
        Tool2[".gitignore"]:::tooling
    end

    %% Relationships
    BuildSystem1 -->|"compiles"| MatrixHeader
    BuildSystem1 -->|"compiles"| MatrixImpl
    BuildSystem1 -->|"compiles"| MainApp
    BuildSystem1 -->|"compiles"| TestSuite
    BuildSystem2 -->|"compiles"| MatrixHeader
    BuildSystem2 -->|"compiles"| MatrixImpl
    BuildSystem2 -->|"compiles"| MainApp
    BuildSystem2 -->|"compiles"| TestSuite

    MainApp -->|"uses API"| MatrixHeader
    TestSuite -->|"tests API"| MatrixHeader
    TestSuite -->|"links to"| GoogleTest

    %% Click Events
    click MatrixHeader "https://github.com/demicuz/s21_matrix_plus/blob/develop/src/s21_matrix_oop.hpp"
    click MatrixImpl "https://github.com/demicuz/s21_matrix_plus/blob/develop/src/s21_matrix_oop.cpp"
    click MainApp "https://github.com/demicuz/s21_matrix_plus/blob/develop/src/main.cpp"
    click TestSuite "https://github.com/demicuz/s21_matrix_plus/blob/develop/src/test.cpp"
    click BuildSystem1 "https://github.com/demicuz/s21_matrix_plus/blob/develop/CMakeLists.txt"
    click BuildSystem2 "https://github.com/demicuz/s21_matrix_plus/tree/develop/Makefile"
    click Tool1 "https://github.com/demicuz/s21_matrix_plus/blob/develop/.clang-format"
    click Tool2 "https://github.com/demicuz/s21_matrix_plus/blob/develop/.gitignore"

    %% Styles
    classDef library fill:#CCDDFF,stroke:#000,stroke-width:1px
    classDef application fill:#CCFFCC,stroke:#000,stroke-width:1px
    classDef build fill:#EEEEEE,stroke:#000,stroke-width:1px
    classDef tooling fill:#DDDDDD,stroke:#000,stroke-width:1px
    classDef external fill:#FFDDCC,stroke:#000,stroke-width:1px
```
