# Repository Overview

Welcome to the **Kopt** codebase — the core processing system developed by **Optage**. This Java project provides batch job orchestration, data dispatch/send workflows (SOD operations), and supporting contract processing modules. If you're picking up this repository for the first time, this overview will orient you to the big picture before you dive into individual files.

Kopt is organized under the `com.optage.kopt` Java package and follows a thin-facade pattern where batch entry points delegate to sibling handler classes. Most classes in this repo are currently scaffolding (auto-generated fixture stubs), designed as extension points for future business logic.

## Overview

The **Kopt** system is a Java-based batch processing and dispatch platform. At its core, it runs scheduled batch jobs, validates data, and transmits SOD (dispatch/send) payloads to downstream systems. The codebase is structured around a small set of modular packages, each responsible for a distinct concern — from orchestration and send handling to data transfer objects and service control. Given the Japanese-style naming conventions (e.g., `JKK`, `Hakko`, `KKPRC`), this system appears to serve a Japanese business domain.

## Technology Stack

| Technology | Details |
|---|---|
| Language | Java |
| Test Framework | JUnit 4 |
| Build / Dependencies | Not detected from imports (stub classes) |

No well-known external frameworks were detected from import analysis. This is likely because the classes are currently scaffolding. You may find build configuration (Maven `pom.xml` or Gradle `build.gradle`) at the repository root if dependencies are defined there.

## Architecture

The system follows a layered, delegation-based architecture. Each module sits at a single level under `com.optage.kopt` and is responsible for a specific concern. Here is a high-level map of how the modules relate:

```mermaid
flowchart TD
    subgraph batch["com.optage.kopt.batch"]
        KKPRC14901["KKPRC14901
Primary batch job"]
        KKPRC24901["KKPRC24901
Secondary batch job"]
        KKPRC34901["KKPRC34901
Tertiary batch job"]
    end

    subgraph bp["com.optage.kopt.bp"]
        SODCC["JKKHakkoSODCC
SOD dispatcher"]
        SODSEND["JKKSodSendCC
SOD send handler"]
        SODHELPER["JKKHakkoSODHelper
String utility"]
        SODBASE["JKKBpServiceBase
Service base"]
    end

    subgraph ekk["com.optage.kopt.ekk"]
        EKK010["EKK0301A010
Contract processing"]
        EKK020["EKK0301A020
Secondary contract"]
    end

    subgraph dto["com.optage.kopt.dto"]
        SODREQ["JKKSodRequestDTO
Request data"]
        SODRES["JKKSodResponseDTO
Response data"]
    end

    subgraph kkw["com.optage.kopt.kkw"]
        KKW001["KKW0100B001
Batch trigger"]
    end

    subgraph esc["com.optage.kopt.esc"]
        ESC001["ESC0101B001
Service control"]
    end

    KKPRC14901 --> EKK010
    EKK010 --> KKW001
    SODCC --> SODSEND
    SODCC --> SODHELPER
    SODCC -.-> KKPRC14901
    SODBASE -.-> SODCC
```

**Flow highlights:**

- **Batch jobs** (`batch`) are the entry points — an external scheduler invokes `run()` on a `KKPRC` class, which delegates to a handler in `ekk`.
- **EKK** (`ekk`) contains contract processing logic. `EKK0301A010.process()` performs the main work and, in turn, can trigger downstream batch logic via `KKW0100B001`.
- **BP** (`bp`) handles SOD (dispatch/send) operations. `JKKHakkoSODCC` orchestrates send and validation by delegating to `JKKSodSendCC` and `KKPRC14901`.
- **DTO** (`dto`) defines data structures that flow through the SOD pipeline (`JKKSodRequestDTO`, `JKKSodResponseDTO`).
- **KKW** and **ESC** (`kkw`, `esc`) are auxiliary modules for batch triggers and service control, respectively.

## Module Guide

### `com.optage.kopt.batch` — Batch Job Entry Points

This package defines three batch job classes (`KKPRC14901`, `KKPRC24901`, `KKPRC34901`) that serve as the execution boundary for scheduled batch operations. The primary class, `KKPRC14901`, exposes `check()` (a no-op stub) and `run()`, which instantiates `EKK0301A010` from the `ekk` package and calls its `process()` method. `KKPRC24901` and `KKPRC34901` are currently unimplemented stubs. All classes follow a `KKPRC` prefix convention, suggesting they belong to a larger family of batch processors. The batch classes act as thin facades — the real work lives in sibling handler classes.

**Key classes:**

| Class | Role |
|---|---|
| `KKPRC14901` | Primary batch — delegates to `EKK0301A010` |
| `KKPRC24901` | Secondary batch — stub |
| `KKPRC34901` | Tertiary batch — stub |

See the [batch module reference](com/optage/kopt/batch.md) for details.

### `com.optage.kopt.bp` — SOD Dispatch and Send Operations

This package provides the batch processing layer for SOD (dispatch/send) operations. It coordinates dispatch, validation, and transmission through a small set of focused classes:

- **`JKKHakkoSODCC`** — The central controller. `dispatch()` creates a `JKKSodSendCC` and calls `send()` to transmit data. `validate()` delegates to `KKPRC14901.check()` for pre-flight validation.
- **`JKKSodSendCC`** — The actual send handler, invoked by the controller.
- **`JKKHakkoSODHelper`** — A lightweight string utility that trims whitespace.
- **`JKKBpServiceBase`** — A base class with a `baseInit()` stub intended as a shared initialization extension point.

Classes in this module are designed to be stateless — each operation creates new instances on demand rather than relying on singletons or dependency injection.

See the [bp module reference](com/optage/kopt/bp.md) for details.

### `com.optage.kopt.ekk` — Contract Processing

The `ekk` module contains classes responsible for contract-related processing logic. `EKK0301A010` is the primary handler, exposing `process()` (contract processing) and `notify()` (which triggers `KKW0100B001`). `EKK0301A020` is a secondary contract class. These are the classes that the batch jobs in the `batch` module delegate to.

### `com.optage.kopt.dto` — Data Transfer Objects

This package defines simple DTOs for SOD data flow:

- **`JKKSodRequestDTO`** — Holds `tenantId` and `serviceId`.
- **`JKKSodResponseDTO`** — Holds `status` and `message`.

### `com.optage.kopt.kkw` — Batch Triggers

Contains `KKW0100B001`, which provides a `trigger()` method for initiating batch operations. It is called by `EKK0301A010.notify()`.

### `com.optage.kopt.esc` — Service Control

Contains `ESC0101B001`, which exposes a `control()` method. This appears to be a service-level control point, though the implementation is currently a stub.

## Getting Started

If you are new to this codebase, here is a recommended reading order:

1. **This overview** — You are here. Use the architecture diagram to understand how modules fit together.
2. **`batch` module** (`com.optage/kopt/batch.md`) — Start here to understand the entry points. `KKPRC14901` is the primary batch class and the most fleshed-out fixture.
3. **`ekk` module** (`EKK0301A010.java`) — Follow the delegation from the batch job to see where contract processing happens.
4. **`bp` module** (`com/optage/kopt/bp.md`) — Understand how SOD dispatch and send operations are coordinated.
5. **`dto` classes** (`JKKSodRequestDTO.java`, `JKKSodResponseDTO.java`) — Review the data structures that flow through the pipeline.
6. **Auxiliary modules** (`kkw`, `esc`, `unrelated`) — Explore these last for supporting functionality.

**Recommended file-by-file path for your first read:**

```
src/main/java/com/optage/kopt/batch/KKPRC14901.java   ← batch entry point
src/main/java/com/optage/kopt/ekk/EKK0301A010.java    ← processing logic
src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java   ← SOD dispatcher
src/main/java/com/optage/kopt/bp/JKKSodSendCC.java    ← send handler
src/main/java/com/optage/kopt/dto/JKKSodRequestDTO.java
src/main/java/com/optage/kopt/dto/JKKSodResponseDTO.java
```

### Tips for Working with This Codebase

- **Most classes are scaffolding.** You will see comments like `/* auto-generated fixture class for SPEC-SCOPED-WIKI tests */` and stub method bodies. The structure is intentional — it defines the interfaces and delegation patterns that will be filled in as business logic is added.
- **Follow the delegation.** The architecture is built around thin entry points that delegate to sibling classes. When you trace a call chain (e.g., `KKPRC14901.run()` → `EKK0301A010.process()` → `KKW0100B001.trigger()`), you will see the intended flow.
- **Test classes are stubs.** `JKKHakkoSODCCTest` exists but uses `assertTrue(true)` as a placeholder. Add real tests as you implement logic.
- **Naming conventions matter.** Class prefixes encode module context: `KKPRC` for batch, `JKK` for SOD dispatch, `EKK` for contract processing, `KKW` for batch trigger, `ESC` for service control. This naming style suggests a Japanese enterprise application domain.
