# gustavohennig/simpledatabasereplicator architecture

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

- Interactive diagram: https://gitdiagram.com/gustavohennig/simpledatabasereplicator
- Repository: https://github.com/gustavohennig/simpledatabasereplicator

## Overview

##### Main Components

A. User Interface Layer
- Windows Forms UI components
- Main forms (Main.cs, ReplicationTaskEdit.cs, ConnectionStringSetup.cs)
- Use a rectangle with "UI" label at the top layer

B. Core Replication Engine
- Central component (Replicator folder)
- MessageHandler, TableComparator, and ReplicationTaskInfo
- Use a hexagon or circle to represent the core engine

C. Database Abstraction Layer
- Database type implementations (SQL/Databases folder)
- Supported databases: SQL Server, Firebird, SQLite, MySQL, PostgreSQL

D. Data Access Layer
- DB folder components
- DbSchemaLoader, DbTableDataLoader, DbSyncRunner
- Use rectangles with rounded corners

E. Data Objects
- Data model (DataObjects folder)
- Table, TableColumn, TableRow classes
- Use UML-style class representation

##### Component Relationships

**UI Layer → Core Replication Engine (User actions)**
**Core Replication Engine → Database Abstraction Layer (Database operations)**
**Database Abstraction Layer → Data Access Layer (Concrete implementations)**
**Data Access Layer ↔ External Databases (Data flow)**
**Data Objects ← → All Layers (Used throughout the system)**

##### Important Architectural Patterns to Highlight

A. Abstraction Layers
- Clear separation between UI, business logic, and data access
- Database abstraction layer that enables multi-database support

B. Plugin Architecture
- How different database types are pluggable
- BaseDbType class and its implementations

##### Key Technical Details

- .NET 8 Platform (framework information)
- One-way synchronization flow
- Database agnostic architecture
- Simple query-based approach

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Title
    title[Simple Database Replicator - System Architecture]:::title

    %% UI Layer
    subgraph UI[User Interface Layer]
        MainForm["Main Form"]
        TaskEdit["Task Editor"]
        ConnSetup["Connection Setup"]
        BaseForm["Base Form"]
    end

    %% Core Engine
    subgraph Core[Core Replication Engine]
        Replicator["Replicator"]
        MsgHandler["Message Handler"]
        TblComparator["Table Comparator"]
        TaskInfo["Task Info"]
    end

    %% Database Abstraction
    subgraph DbAbstraction[Database Abstraction Layer]
        BaseDb["Base DB Type"]
        SqlServer["SQL Server"]
        Firebird["Firebird"]
        SQLite["SQLite"]
        MySQL["MySQL"]
        Postgres["PostgreSQL"]
    end

    %% Data Access Layer
    subgraph DataAccess[Data Access Layer]
        SchemaLoader["Schema Loader"]
        DataLoader["Table Data Loader"]
        SyncRunner["Sync Runner"]
        TaskRunner["Task Runner"]
        ConnInfo["Connection Info"]
    end

    %% Data Objects
    subgraph DataObj[Data Objects]
        Table["Table"]
        Column["Table Column"]
        Row["Table Row"]
        TableInfo["Table Info"]
    end

    %% External Databases
    subgraph ExtDB[External Databases]
        SourceDB[(Source DB)]
        DestDB[(Destination DB)]
    end

    %% Relationships
    UI --> Core
    Core --> DbAbstraction
    DbAbstraction --> DataAccess
    DataAccess <--> ExtDB
    DataObj <--> Core
    DataObj <--> DataAccess
    DataObj <--> DbAbstraction

    %% Click Events
    click MainForm "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/UI/Main.cs"
    click TaskEdit "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/UI/ReplicationTaskEdit.cs"
    click ConnSetup "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/UI/ConnectionStringSetup.cs"
    click BaseForm "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/UI/Base/BaseForm.cs"
    
    click Replicator "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/Replicator/Replicator.cs"
    click MsgHandler "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/Replicator/MessageHandler.cs"
    click TblComparator "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/Replicator/TableComparator.cs"
    click TaskInfo "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/Replicator/ReplicationTaskInfo.cs"
    
    click BaseDb "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/BaseDbType.cs"
    click SqlServer "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/SqlServerDbType.cs"
    click Firebird "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/FirebirdDbType.cs"
    click SQLite "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/SqLiteDbType.cs"
    click MySQL "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/MysqlDbType.cs"
    click Postgres "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/SQL/Databases/PostgresDbType.cs"
    
    click SchemaLoader "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DB/DbSchemaLoader.cs"
    click DataLoader "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DB/DbTableDataLoader.cs"
    click SyncRunner "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DB/DbSyncRunner.cs"
    click TaskRunner "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DB/DbTaskRunner.cs"
    click ConnInfo "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DB/DbConnectionInfo.cs"
    
    click Table "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DataObjects/Table.cs"
    click Column "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DataObjects/TableColumn.cs"
    click Row "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DataObjects/TableRow.cs"
    click TableInfo "https://github.com/GustavoHennig/SimpleDatabaseReplicator/blob/master/DataObjects/TableInfo.cs"

    %% Styles
    classDef title fill:#f9f,stroke:#333,stroke-width:4px
    classDef default fill:#fff,stroke:#333,stroke-width:2px
    classDef ui fill:#lightblue,stroke:#333
    classDef core fill:#orange,stroke:#333
    classDef dbabs fill:#lightgreen,stroke:#333
    classDef dataaccess fill:#lightyellow,stroke:#333
    classDef dataobj fill:#lightgray,stroke:#333
    classDef extdb fill:#darkblue,stroke:#333,color:#fff

    class UI ui
    class Core core
    class DbAbstraction dbabs
    class DataAccess dataaccess
    class DataObj dataobj
    class ExtDB extdb
```
