# terasoluna-batch/v5-sample architecture

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

- Interactive diagram: https://gitdiagram.com/terasoluna-batch/v5-sample
- Repository: https://github.com/terasoluna-batch/v5-sample

## Overview

##### Project type and purpose
- This is a Maven‐based blank archetype for building batch applications on top of Spring Batch, Spring Framework, and MyBatis (via the TERASOLUNA Batch Framework for Java 5.x).
- It provides two parallel configurations: Java‐based (config/javaconfig) and XML‐based (config/xmlconfig) to bootstrap a batch job (job01) that reads, processes, and writes Employee data.

##### File structure
- Top‐level “config” directory holds:
- config/javaconfig: Java @Configuration classes (AsyncBatchDaemonConfig, JobBaseContextConfig, LaunchContextConfig, TerasolunaBatchConfiguration, plus job‐specific Job01Config).
- config/xmlconfig: spring XMLs for daemon, base context, launch context, and job definitions (job01.xml).
- The sample application skeleton under terasoluna-batch-blankproject includes:
- src/main/java/.../projectName/job01: domain (Employee), processor, repository interfaces.
- src/main/resources/META‑INF/spring or resources/…/job01: XML bean definitions or MyBatis mapper XML (EmployeeRepository.xml).
- batch-application.properties, logback.xml, i18n messages for externalizing config.
- Build and run scripts invoked via CommandLineJobRunner (org.springframework.batch.core.launch.support.CommandLineJobRunner).

##### Key points from README
- It’s purely a batch job template; users generate their own groupId/artifactId and pick Java or XML style.
- Run by packaging via Maven, then launching CommandLineJobRunner with either the Java config class or the XML job file.

##### Final checklist
- All major Spring Batch elements (JobLauncher, JobRepository, Step, Chunk)
- Job definition beans (JavaConfig class or XML job file)
- Processor and Repository roles
- DataSource/Transaction Manager/MyBatis integration
- External Relational Database
- Properties and i18n message sources
- CLI/runner entry point

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Entry Point
    subgraph "CLI"
        CLI["CommandLineJobRunner"]:::external
    end

    %% Bootstrapping Layer
    subgraph "Bootstrapping Layer"
        subgraph "JavaConfig" 
            A1["AsyncBatchDaemonConfig"]:::config
            A2["JobBaseContextConfig"]:::config
            A3["LaunchContextConfig"]:::config
            A4["TerasolunaBatchConfiguration"]:::config
            A5["Job01Config"]:::app
        end
        subgraph "XMLConfig"
            X1["async-batch-daemon.xml"]:::config
            X2["job-base-context.xml"]:::config
            X3["launch-context.xml"]:::config
            X4["job01.xml"]:::app
        end
    end

    %% Spring Batch Core Components
    subgraph "Spring Batch Core" 
        JL["JobLauncher"]:::core
        JR["JobRepository"]:::core
        JO["JobOperator"]:::core
        Step["Step"]:::core
        Chunk["Chunk"]:::core
    end

    %% Job01 Components
    subgraph "Job01 Domain & Processing"
        DR["Employee.java"]:::app
        PR["EmployeeProcessor"]:::app
        Repo["EmployeeRepository"]:::app
        Mapper["EmployeeRepository.xml"]:::app
    end

    %% Infrastructure Services
    subgraph "Infrastructure"
        DS["DataSource / Connection Pool"]:::infra
        TM["Transaction Manager"]:::infra
        SSF["SqlSessionFactory"]:::infra
        LOG["Logback"]:::infra
    end

    %% Externalized Configuration
    subgraph "Externalized Config"
        P["batch-application.properties"]:::config
        LB["logback.xml"]:::config
        VM["ValidationMessages.properties"]:::config
        IM["application-messages.properties"]:::config
    end

    %% External Systems
    subgraph "External Systems"
        DB["Relational Database"]:::external
    end

    %% Flow & Dependencies
    CLI -->|"launch(config)"| A5
    CLI -->|"launch(config)"| X4

    A5 -->|"defines beans"| JL
    X4 -->|"defines beans"| JL

    A1 --> JL
    A2 --> JR
    A3 --> JO
    A4 --> DS
    A4 --> TM
    A4 --> SSF

    JL -->|"launch job"| Step
    Step -->|"create chunk"| Chunk
    Chunk -->|"call read()"| DR
    DR -->|"maps SQL via MyBatis"| Mapper
    Mapper --> DB
    Chunk -->|"process()"| PR
    Chunk -->|"write()"| Repo
    Repo --> SSF
    Repo --> DB

    %% Dependencies injection
    DS --> DR
    DS --> Repo
    TM --> Step
    SSF --> Repo

    %% Config Beans
    P --> A4
    VM --> A5
    IM --> A5
    LB --> LOG

    %% External Build & Docs
    BOM["pom.xml"]:::config
    ARC["CreateArchetype.groovy"]:::config
    RMD["README.adoc"]:::config
    CND["CONTRIBUTING.adoc"]:::config

    BOM --> CLI
    ARC --> BOM
    RMD --> BOM
    CND --> BOM

    %% Legend
    classDef core fill:#C3DDF9,stroke:#0366D6,color:#0366D6
    classDef app fill:#D6F5D6,stroke:#28A745,color:#28A745
    classDef infra fill:#FFE5B4,stroke:#D97706,color:#D97706
    classDef config fill:#FFF2CC,stroke:#D9A700,color:#D9A700
    classDef external fill:#E0E0E0,stroke:#6C757D,color:#6C757D

    %% Click Events
    click A1 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/javaconfig/config/AsyncBatchDaemonConfig.java"
    click A2 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/javaconfig/config/JobBaseContextConfig.java"
    click A3 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/javaconfig/config/LaunchContextConfig.java"
    click A4 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/javaconfig/config/TerasolunaBatchConfiguration.java"
    click A5 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/javaconfig/jobs/Job01Config.java"
    click X1 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/xmlconfig/spring/async-batch-daemon.xml"
    click X2 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/xmlconfig/spring/job-base-context.xml"
    click X3 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/xmlconfig/spring/launch-context.xml"
    click X4 "https://github.com/terasoluna-batch/v5-sample/blob/master/config/xmlconfig/jobs/job01.xml"
    click DR "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/java/xxxxxx/yyyyyy/zzzzzz/projectName/job01/Employee.java"
    click PR "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/java/xxxxxx/yyyyyy/zzzzzz/projectName/job01/EmployeeProcessor.java"
    click Repo "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/java/xxxxxx/yyyyyy/zzzzzz/projectName/job01/EmployeeRepository.java"
    click Mapper "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/resources/xxxxxx/yyyyyy/zzzzzz/projectName/job01/EmployeeRepository.xml"
    click P "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/resources/batch-application.properties"
    click LB "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/resources/logback.xml"
    click VM "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/resources/ValidationMessages.properties"
    click IM "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/src/main/resources/i18n/application-messages.properties"
    click BOM "https://github.com/terasoluna-batch/v5-sample/blob/master/terasoluna-batch-blankproject/pom.xml"
    click ARC "https://github.com/terasoluna-batch/v5-sample/blob/master/CreateArchetype.groovy"
    click RMD "https://github.com/terasoluna-batch/v5-sample/blob/master/README.adoc"
    click CND "https://github.com/terasoluna-batch/v5-sample/blob/master/CONTRIBUTING.adoc"
```
