# wwalery/db2dto architecture

> Architecture diagram of the GitHub repository wwalery/db2dto, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wwalery/db2dto
- Repository: https://github.com/wwalery/db2dto

## Overview

##### Main Components

a) Input Components:
- Database Connection Layer
- Configuration System
- Command-line Interface
- Template System

b) Processing Components:
- Core Processor
- Plugin System
- Code Generation Engine

c) Output Components:
- Generated DTO Classes
- Compilation System
- JAR Packaging System

**┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐**
- Database      │    │  Configuration  │    │    Template     │
- Connection    │    │     System      │    │     System      │
- ┬────────┘    └────────┬────────┘    └────────┬────────┘

**┌─────────────────────────────────────────────────────────────┐**
- Core Processor                          │
- ┌───────────────┐  ┌───────────────┐  ┌───────────────┐   │
- Plugin Handler│  │ DB Metadata   │  │ Code Generator│   │
- ┘  └───────────────┘  └───────────────┘   │
- ┘

**┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐**
- Generated DTOs │    │   Compilation   │    │  JAR Packaging  │
- ┘    └─────────────────┘    └─────────────────┘

##### Key Relationships

- Database Connection → Core Processor (metadata extraction)
- Configuration System → Core Processor (settings input)
- Template System → Code Generator (template processing)
- Plugin Handler → Database Connection (database-specific implementations)
- Core Processor → Generated DTOs (output generation)
- Generated DTOs → Compilation System (optional compilation)
- Compilation System → JAR Packaging (optional packaging)

##### Important Details

a) Configuration Flow:
- How the config file (db2dto.conf) feeds into the system
- Command-line parameter override capabilities

b) Plugin Architecture:
- PostgreSQL plugin as the default implementation
- Extension points for other database types

c) Template Processing:
- Relationship between templates (class.tpl, column.tpl, interface.tpl)
- Template customization capabilities

##### Data Flow Markers

- Database metadata flow
- Configuration parameter flow
- Template processing flow
- Generated code output flow
- Compilation and packaging flow

Remember to maintain a balance between detail and clarity, focusing on the core functionality of database metadata extraction, DTO generation, and the flexible configuration system that makes this tool powerful.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        DB[(Database)]
        CLI["Command Line Interface"]
        CFG["Configuration System"]
        TPL["Template System"]
    end

    subgraph Core
        PROC["Core Processor"]
        PLG["Plugin System"]
        PLGH["Plugin Handler"]
        
        subgraph Metadata
            DBTBL["DB Table"]
            DBCOL["DB Column"]
        end
        
        subgraph Templates
            CTPL["Class Template"]
            COTPL["Column Template"]
            ITPL["Interface Template"]
        end
    end

    subgraph Output
        GEN["Generated DTOs"]
        COMP["Compilation"]
        JAR["JAR Package"]
    end

    DB --> PLG
    CLI --> PROC
    CFG --> PROC
    TPL --> PROC
    
    PLG <--> PLGH
    PLGH --> PROC
    
    PROC --> DBTBL
    PROC --> DBCOL
    
    DBTBL --> GEN
    DBCOL --> GEN
    
    CTPL --> GEN
    COTPL --> GEN
    ITPL --> GEN
    
    GEN --> COMP
    COMP --> JAR

    %% Click events for component mapping
    click CLI "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/Main.java"
    click CFG "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/config/Config.java"
    click PROC "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/Processor.java"
    click PLG "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/plugin/IPlugin.java"
    click PLGH "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/plugin/PluginHandler.java"
    click DBTBL "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/DBTable.java"
    click DBCOL "https://github.com/wwalery/db2dto/blob/master/src/main/java/dev/walgo/db2dto/DBColumn.java"
    click TPL "https://github.com/wwalery/db2dto/tree/master/src/main/resources/templates/"
    click CTPL "https://github.com/wwalery/db2dto/blob/master/src/main/resources/templates/class.tpl"
    click COTPL "https://github.com/wwalery/db2dto/blob/master/src/main/resources/templates/column.tpl"
    click ITPL "https://github.com/wwalery/db2dto/blob/master/src/main/resources/templates/interface.tpl"

    %% Styling
    classDef input fill:#a8d1f0
    classDef core fill:#b7e3b7
    classDef output fill:#f5c086
    classDef metadata fill:#e1e1e1
    classDef templates fill:#d4e4bc

    class DB,CLI,CFG,TPL input
    class PROC,PLG,PLGH core
    class GEN,COMP,JAR output
    class DBTBL,DBCOL metadata
    class CTPL,COTPL,ITPL templates
```
