# rex-82/migrate-tool architecture

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

- Interactive diagram: https://gitdiagram.com/rex-82/migrate-tool
- Repository: https://github.com/rex-82/migrate-tool

## Overview

Key Components to Include:

##### Core Components
- CLI Interface (main.go)
- Migration Manager (migrate.go)
- Form Handler (form.go)
- Database Dumper (dump.go)
- Models Layer (models/formData.go)
- Utilities Package (utils/*)

##### External Interactions
- File System (for reading/writing migration files)
- Database Connection (MySQL/MariaDB based on port 3306 default)
- User Input/Output

##### Component Relationships
- It to the Form Handler for user input processing
- Migration Manager as the central component
- Database Dumper to both the Migration Manager and the database
- Utilities as a side component providing support to all main components

##### Specific Elements

**┌─────────────────────────────────────────────────┐**
- CLI Interface                   │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- Form Handler                       │
- ┌───────────────┐        ┌──────────────────┐  │
- FormData    │        │  Input Validator  │  │
- ┘        └──────────────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────────────┐**
- Migration Manager                    │
- ┌───────────────┐        ┌──────────────────┐  │
- File Generator│        │  Database Dumper  │  │
- ┘        └──────────────────┘  │
- ┘
- ↙                         ↘
**┌─────────────┐               ┌──────────────┐**
- File System │               │   Database   │
- ┘               └──────────────┘

**┌─────────────────────────────────────────────────┐**
- Utility Services                 │
- Path Formatting                              │
- Directory Checking                           │
- File Listing                                 │
- Variable Management                          │
- ┘

##### Important Flows to Highlight
- User input flow: CLI → Form Handler → Migration Manager
- Database operations: Migration Manager → Database Dumper → Database
- File operations: Migration Manager → File System

##### Additional Details
- Notes about the file naming convention (YYYYMMDD_hhmmss_db_type.sql)
- Default configuration values
- Supported database types
- Cross-platform support (note the presence of vars_windows.go)

##### Technical Specifications
- Go version compatibility
- External dependencies (from go.mod)
- Build/release process (reference to .goreleaser.yaml)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Interface
        CLI["CLI Interface"]
    end

    subgraph Processing
        FH["Form Handler"]
        MM["Migration Manager"]
        DD["Database Dumper"]
        
        subgraph Models
            FD["FormData Model"]
        end
    end

    subgraph External
        FS[("File System")]
        DB[("Database<br>MySQL/MariaDB<br>Port: 3306")]
    end

    subgraph Utilities
        PF["Path Formatter"]
        DC["Directory Checker"]
        FL["File Lister"]
        VM["Variable Manager"]
    end

    %% Main Flow
    CLI --> FH
    FH --> FD
    FH --> MM
    MM --> DD
    DD --> DB
    MM --> FS

    %% Utility Connections
    PF -.-> MM
    DC -.-> MM
    FL -.-> MM
    VM -.-> MM
    PF -.-> FH
    DC -.-> FH
    FL -.-> FH
    VM -.-> FH

    %% Styling
    classDef interface fill:#a8d1ff
    classDef processing fill:#90EE90
    classDef external fill:#FFE5B4
    classDef utilities fill:#E6E6E6
    classDef models fill:#FFB6C1

    class CLI interface
    class FH,MM,DD processing
    class FS,DB external
    class PF,DC,FL,VM utilities
    class FD models

    %% Click Events
    click CLI "https://github.com/Rex-82/migrate-tool/blob/main/main.go"
    click MM "https://github.com/Rex-82/migrate-tool/blob/main/migrate.go"
    click FH "https://github.com/Rex-82/migrate-tool/blob/main/form.go"
    click DD "https://github.com/Rex-82/migrate-tool/blob/main/dump.go"
    click FD "https://github.com/Rex-82/migrate-tool/blob/main/models/formData.go"
    click PF "https://github.com/Rex-82/migrate-tool/blob/main/utils/pathFormat.go"
    click DC "https://github.com/Rex-82/migrate-tool/blob/main/utils/checkDir.go"
    click FL "https://github.com/Rex-82/migrate-tool/blob/main/utils/listFiles.go"
    click VM "https://github.com/Rex-82/migrate-tool/blob/main/utils/vars.go"
```
