# atarasin/oatpp-mysql architecture

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

- Interactive diagram: https://gitdiagram.com/atarasin/oatpp-mysql
- Repository: https://github.com/atarasin/oatpp-mysql

## Overview

##### Main Components
a. Oatpp-MySQL Core Library
- This includes the primary source code under the src/oatpp-mysql directory.
- Main classes such as Connection, ConnectionProvider, Executor, and QueryResult which handle establishing connections, executing queries, and processing results.
b. Mapping Module
- Located in src/oatpp-mysql/mapping, these files (Serializer, Deserializer, ResultMapper) handle the conversion between C++ objects and SQL result sets.
c. Query Template Module
- Found in src/oatpp-mysql/ql_template, this set of files (Parser, TemplateValueProvider) is responsible for handling dynamic SQL construction or template-based queries.
d. Testing and Validation
- The test directory contains various tests for each subcomponent (migrations, ql_template tests, types tests) ensuring that every module works as expected.
e. Build and Utility Scripts
- CMakeLists.txt files, cmake configuration scripts, and utility scripts for installing dependencies (e.g. utility/install-deps/install-my-dependency.sh and module-uninstall.sh) which are pivotal for automated builds and CI/CD.
f. Continuous Integration
- azure-pipelines.yml indicates that there is an Azure Pipelines setup for automated integration and testing.

##### Relationships and Interactions
a. The core library classes (Connection, ConnectionProvider) interact directly with the MySQL database and form the base of the integration.
b. The Executor class acts as a mediator between raw SQL execution and higher-level mapping operations.
c. The Mapping Module, which consists of serializer/deserializer utilities, sits on top of the raw database interactions to transform query results into usable objects.
d. The QL Template Module provides an abstraction layer for dynamically constructing SQL queries and integrates with both the core and mapping functionalities.
e. Testing components in the test directory mirror and validate these relationships.

##### Important Architectural Patterns and Design Principles
- Modularity: Distinct directories (oatpp-mysql, mapping, ql_template) emphasize separation of concerns.
- Abstraction: Usage of classes to abstract raw database operations (like ConnectionProvider and Executor).
- Reusability and Extensibility: The design allows for clear integration points (custom QL templates or mapping configurations) making the library adaptable.
- CI/CD integration: With Azure Pipelines and CMake configuration, the design is oriented towards maintainability and continuous development.

- Out the internal library components in layered sections (e.g., bottom layer handling raw DB connections, middle layer handling query execution, upper layer managing object mapping).
- That you capture build and deployment components if relevant, such as the role of CMake and the Azure Pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% External Entities
    client("Client Application"):::external
    db("MySQL Database"):::database
    ci("Azure Pipelines"):::ci

    %% Oatpp-MySQL Core Library
    subgraph "Oatpp-MySQL Core Library"
        core1("Connection Provider"):::core
        core2("Connection"):::core
        core3("Executor"):::core
        core4("Query Result"):::core
    end

    %% Mapping Module
    subgraph "Mapping Module"
        map1("Serializer"):::mapping
        map2("Deserializer"):::mapping
        map3("Result Mapper"):::mapping
    end

    %% Query Template Module
    subgraph "Query Template Module"
        ql1("Parser"):::ql
        ql2("Template Value Provider"):::ql
    end

    %% Testing and Validation
    subgraph "Testing and Validation"
        test1("Test Suite (Migrations, QL_Template, Types)"):::test
    end

    %% Build and Utility Scripts
    subgraph "Build & Utility Scripts"
        build1("CMakeLists.txt & CMake Scripts"):::build
        build2("Utility Scripts"):::build
    end

    %% Relationships
    client -->|"initiates"| core1
    core1 -->|"creates"| core2
    core2 -->|"enables"| core3
    core3 -->|"produces"| core4
    core3 -->|"queries"| db
    db -->|"returnsData"| core3
    core4 -->|"mappedBy"| map3
    ql1 -->|"templates"| ql2
    ql2 -->|"providesQuery"| core3

    test1 -->|"validates"| core1
    test1 -->|"validates"| map3
    test1 -->|"validates"| ql1
    test1 -->|"validates"| ql2

    build1 -.->|"builds"| core1
    build2 -.->|"supports"| core1

    ci -->|"triggersBuild"| build1
    ci -->|"triggersTests"| test1

    %% Click Events for Oatpp-MySQL Core Library
    click core1 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql"
    click core2 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql"
    click core3 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql"
    click core4 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql"

    %% Click Events for Mapping Module
    click map1 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql/mapping"
    click map2 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql/mapping"
    click map3 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql/mapping"

    %% Click Events for Query Template Module
    click ql1 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql/ql_template"
    click ql2 "https://github.com/atarasin/oatpp-mysql/tree/master/src/oatpp-mysql/ql_template"

    %% Click Events for Testing and Validation
    click test1 "https://github.com/atarasin/oatpp-mysql/tree/master/test"

    %% Click Events for Build and Utility Scripts
    click build1 "https://github.com/atarasin/oatpp-mysql/blob/master/CMakeLists.txt"
    click build2 "https://github.com/atarasin/oatpp-mysql/blob/master/utility/install-deps/install-my-dependency.sh"

    %% Click Event for Continuous Integration
    click ci "https://github.com/atarasin/oatpp-mysql/blob/master/azure-pipelines.yml"

    %% Styles
    classDef core fill:#FFCC99,stroke:#D35400,stroke-width:2px;
    classDef mapping fill:#C0E2C2,stroke:#27AE60,stroke-width:2px;
    classDef ql fill:#E6CCFF,stroke:#8E44AD,stroke-width:2px;
    classDef test fill:#F8C471,stroke:#D35400,stroke-width:2px;
    classDef build fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
    classDef database fill:#C39BD3,stroke:#8E44AD,stroke-width:2px;
    classDef ci fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
```
