# nonods/ma-calculatrice architecture

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

- Interactive diagram: https://gitdiagram.com/nonods/ma-calculatrice
- Repository: https://github.com/nonods/ma-calculatrice

## Overview

##### Main Components

A. Core Calculator Engine (Calculateur)
- Mathematical Parser (AnalyseurMath.cs)
- Expression Elements (ElementCalcul* classes)
- Function Management (Fonction.cs, FonctionTrigo.cs)
- Variable Management (Variable.cs, Variables.cs)
- Tokenizer (Tokeniser.cs)

B. User Interfaces (Multiple Implementations)
- Three separate UI components:
1. Windows Forms UI (CalculatriceFR2)
2. WPF UI (WpfCalc)
3. Chaos UI Component

C. MVVM Architecture (specifically for WPF implementation)
- Include:
- ViewModels (CalcViewModel.cs, MainViewModel.cs)
- Models (CalculateurModel.cs)
- Commands (CalculCommand.cs)

##### Relationship Flows

- Data flow between UI layers and the calculator engine
- Command pattern implementation in WPF
- Variable and function management relationships
- Expression evaluation flow

##### Architectural Patterns to Highlight

a. Visitor Pattern Implementation
- IVisiteurIElement.cs and EvaluationVisitor.cs interaction
- To expression elements

b. Interface Segregation
- Interfaces (IFonction.cs, IVariable.cs, IVariables.cs)
- Their implementations

##### Business Logic Layer (Middle)
- Calculator Engine
- Expression Evaluation
- Mathematical Parser

##### Core Components (Bottom)
- Variable Management
- Function Management
- Tokenizer

##### The configuration and settings management

Keep the abstraction level focused on the architectural components while showing the key relationships between the calculator engine, UI implementations, and supporting services. This will provide a clear understanding of the system's structure while maintaining important implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI_Layer
        WPF["WPF UI"]:::ui
        WF["Windows Forms UI"]:::ui
        CH["Chaos UI Component"]:::ui
        
        subgraph WPF_MVVM
            VM["ViewModels"]:::mvvm
            CM["Commands"]:::mvvm
            MDL["Models"]:::mvvm
        end
    end

    subgraph Calculator_Engine
        CE["Core Calculator"]:::core
        MP["Mathematical Parser"]:::parser
        TK["Tokenizer"]:::core
        
        subgraph Expression_Handling
            EE["Expression Elements"]:::expr
            EV["Evaluation Visitor"]:::visitor
            VI["Visitor Interface"]:::interface
        end
        
        subgraph Management
            FM["Function Management"]:::mgmt
            VM["Variable Management"]:::mgmt
        end
    end

    subgraph Interfaces
        IF["IFonction"]:::interface
        IV["IVariable"]:::interface
        IVS["IVariables"]:::interface
    end

    %% Relationships
    WPF --> VM
    VM --> CM
    VM --> MDL
    MDL --> CE
    WF --> CE
    CH --> CE
    
    CE --> MP
    CE --> TK
    CE --> EE
    EE --> EV
    EV --> VI
    
    CE --> FM
    CE --> VM
    FM --> IF
    VM --> IV
    VM --> IVS

    %% Click Events
    click CE "https://github.com/NonoDS/Ma-Calculatrice/tree/master/Calculateur/"
    click MP "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/AnalyseurMath.cs"
    click TK "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/Tokeniser.cs"
    click FM "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/Fonction.cs"
    click WF "https://github.com/NonoDS/Ma-Calculatrice/tree/master/CalculatriceFR2/"
    click CH "https://github.com/NonoDS/Ma-Calculatrice/blob/master/CalculatriceFR2/Chaos.cs"
    click WPF "https://github.com/NonoDS/Ma-Calculatrice/tree/master/WpfCalc/"
    click VM "https://github.com/NonoDS/Ma-Calculatrice/blob/master/WpfCalc/ViewModel/MainViewModel.cs"
    click CM "https://github.com/NonoDS/Ma-Calculatrice/blob/master/WpfCalc/CalculCommand.cs"
    click MDL "https://github.com/NonoDS/Ma-Calculatrice/blob/master/WpfCalc/CalculateurModel.cs"
    click VI "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/IVisiteurIElement.cs"
    click EV "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/EvaluationVisitor.cs"
    click IF "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/IFonction.cs"
    click IV "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/IVariable.cs"
    click IVS "https://github.com/NonoDS/Ma-Calculatrice/blob/master/Calculateur/IVariables.cs"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef mvvm fill:#2ecc71,stroke:#27ae60,color:white
    classDef core fill:#e74c3c,stroke:#c0392b,color:white
    classDef parser fill:#f1c40f,stroke:#f39c12,color:black
    classDef expr fill:#9b59b6,stroke:#8e44ad,color:white
    classDef visitor fill:#1abc9c,stroke:#16a085,color:white
    classDef interface fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef mgmt fill:#e67e22,stroke:#d35400,color:white
```
