# Repository Overview

Welcome aboard! This repository is a Java-based batch-processing framework for the **KOPT** (key optimization) system, which appears to support Japanese insurance and financial operations — specifically handling stock order dispatch, contract processing, and related batch workflows. If you're looking to understand how batch jobs are triggered, validated, and dispatched, you're in the right place. This codebase is built as a clean, modular project and is a great example of focused service-oriented design.

## Overview

The **KOPT** project is a Java library organized under the `com.optage.kopt` package namespace. It provides infrastructure for batch-processing workflows, including:

- **Stock Order Dispatch (SOD)** — Dispatching and validating stock order data through the `bp` (batch process) subsystem.
- **Contract Processing** — Handling contract-level operations via the `ekk` package, with notification capabilities.
- **Service Control** — Managing ESC-based service operations.
- **Batch Triggers** — KKW-style batch job initiation.

The project uses standard Java conventions, JUnit for testing, and follows a layered architecture where high-level coordination classes delegate to specialized components. Most classes are currently auto-generated fixtures (marked as `SPEC-SCOPED-WIKI` test scaffolding), meaning the core interfaces and delegation patterns are established and ready for production logic to be added.

## Technology Stack

| Technology | Purpose |
|---|---|
| **Java** | Primary language (no specific framework detected) |
| **JUnit 4** | Testing framework (used in `JKKHakkoSODCCTest`) |
| **Maven / Gradle** | Build tool (project uses standard `src/main/java` layout) |

No well-known application frameworks (Spring, Quarkus, Micronaut) were detected from import analysis. This appears to be a lightweight, framework-agnostic Java library.

## Architecture

Below is a high-level diagram of the main modules and their dependencies:

```mermaid
flowchart TD
    subgraph Batch["com.optage.kopt.batch"]
        direction TB
        KKPRC14901["KKPRC14901"]
        KKPRC24901["KKPRC24901"]
        KKPRC34901["KKPRC34901"]
    end
    subgraph Bp["com.optage.kopt.bp"]
        direction TB
        JKKBpServiceBase["JKKBpServiceBase"]
        JKKHakkoSODCC["JKKHakkoSODCC"]
        JKKHakkoSODHelper["JKKHakkoSODHelper"]
        JKKSodSendCC["JKKSodSendCC"]
    end
    subgraph Dto["com.optage.kopt.dto"]
        direction TB
        JKKSodRequestDTO["JKKSodRequestDTO"]
        JKKSodResponseDTO["JKKSodResponseDTO"]
    end
    subgraph Ekk["com.optage.kopt.ekk"]
        direction TB
        EKK0301A010["EKK0301A010"]
        EKK0301A020["EKK0301A020"]
    end
    subgraph Kkw["com.optage.kopt.kkw"]
        direction TB
        KKW0100B001["KKW0100B001"]
    end
    subgraph Esc["com.optage.kopt.esc"]
        direction TB
        ESC0101B001["ESC0101B001"]
    end
    subgraph Unrelated["com.optage.kopt.unrelated"]
        direction TB
        XYZ99999Unrelated["XYZ99999Unrelated"]
    end
    KKPRC14901 --> EKK0301A010
    JKKHakkoSODCC --> JKKSodSendCC
    JKKHakkoSODCC --> KKPRC14901
    JKKHakkoSODCC --> JKKHakkoSODHelper
    JKKHakkoSODCC --> JKKBpServiceBase
    EKK0301A010 --> KKW0100B001
```

### Dependency Summary

- The **`batch`** package contains entry-point fixture classes. Only `KKPRC14901` performs work — it delegates to the `ekk` package.
- The **`bp`** package is the heart of the SOD dispatch flow. `JKKHakkoSODCC` acts as a facade, coordinating dispatch, validation, and helper operations.
- The **`ekk`** package handles contract processing. `EKK0301A010` also notifies the `kkw` package via its `notify()` method.
- The **`dto`** package holds data transfer objects for SOD request/response payloads.
- The **`esc`** and **`kkw`** packages are standalone modules with single public classes each.
- The **`unrelated`** package contains an isolated class with no dependencies on the rest of the system.

## Module Guide

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

This package provides the top-level entry points for batch operations. It contains three auto-generated fixture classes:

- **`KKPRC14901`** — The primary batch entry point. Its `run()` method instantiates `EKK0301A010` and calls `process()`, effectively routing batch work into the contract processing subsystem. The `check()` method is a placeholder for pre-flight validation.
- **`KKPRC24901`** — A secondary batch fixture with a no-op `run()` method. Serves as scaffolding.
- **`KKPRC34901`** — A tertiary batch fixture, also no-op. Mirrors `KKPRC24901` structurally.

All three classes are auto-generated fixtures for SPEC-SCOPED-WIKI testing. They follow a simple delegation pattern with no shared base class or interfaces.

### `com.optage.kopt.bp` — SOD Dispatch Subsystem

This is the most feature-rich package and the one you'll likely interact with most. It implements the **JKK Hakko SOD** (Stock Order Dispatch) subsystem:

- **`JKKHakkoSODCC`** — The central coordination class (a Facade). Its `dispatch()` method creates a `JKKSodSendCC` and calls `send()`. Its `validate()` method delegates to `KKPRC14901.check()` for pre-dispatch integrity checks. New dispatch flows should be added as methods on this class.
- **`JKKSodSendCC`** — The workhorse of the dispatch flow. The `send()` method contains the logic for formatting and transmitting SOD data.
- **`JKKBpServiceBase`** — A base class for shared initialization following the Template Method pattern. Subclasses extend this and call `baseInit()` during their own init sequence.
- **`JKKHakkoSODHelper`** — A utility class with a `format()` method that trims whitespace from strings. Used for normalizing SOD-related identifiers before processing.

The dispatch flow is simple: a caller invokes `JKKHakkoSODCC.dispatch()`, which creates `JKKSodSendCC` and delegates to `send()`. If needed, `validate()` can be called first.

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

This package holds two simple DTO classes:

- **`JKKSodRequestDTO`** — Carries request data for SOD dispatch, including `tenantId` and `serviceId`.
- **`JKKSodResponseDTO`** — Caries response data, including `status` and `message`.

These are plain data carriers with no behavior.

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

- **`EKK0301A010`** — The primary contract processor. Its `process()` method handles contract operations, and `notify()` triggers downstream batch jobs in the `kkw` package. This is the class that `KKPRC14901.run()` delegates to.
- **`EKK0301A020`** — A secondary contract processor with a no-op `process()` method.

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

- **`KKW0100B001`** — A batch trigger component. Its `trigger()` method is called by `EKK0301A010.notify()`. This appears to initiate downstream batch jobs in response to contract processing.

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

- **`ESC0101B001`** — A service control class with a `control()` method. Currently no-op but appears to be a placeholder for ESC-related service management.

### `com.optage.kopt.unrelated` — Isolated Utility

- **`XYZ99999Unrelated`** — A completely isolated class with no dependencies on or from the rest of the system. Likely a placeholder or test artifact.

## Getting Started

Here's a recommended reading order for a new developer exploring this codebase:

1. **Start with this overview** — you're reading it right now.
2. **Read the batch module documentation** (`.codewiki/com/optage/kopt/batch.md`) to understand the entry points.
3. **Read the bp module documentation** (`.codewiki/com/optage/kopt/bp.md`) to understand the core dispatch flow — this is where the most business-relevant architecture lives.
4. **Open `src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java`** — this class is the main facade. Understanding `dispatch()` and `validate()` gives you the full picture of how the system orchestrates work.
5. **Follow the chain**: `KKPRC14901.run()` → `EKK0301A010.process()` → `KKW0100B001.trigger()` to see the full end-to-end batch flow.
6. **Check the test** (`src/test/java/com/optage/kopt/bp/JKKHakkoSODCCTest.java`) for usage examples — currently a placeholder (`assertTrue(true)`), but it shows the intended testing pattern.

### Key Entry Points

| Class | Method | Purpose |
|---|---|---|
| `KKPRC14901` | `run()` | Top-level batch entry point |
| `JKKHakkoSODCC` | `dispatch()` | Trigger SOD dispatch flow |
| `JKKHakkoSODCC` | `validate()` | Pre-dispatch validation |
| `EKK0301A010` | `process()` | Contract processing |
| `EKK0301A010` | `notify()` | Notify downstream batch |
| `JKKSodSendCC` | `send()` | Execute SOD dispatch |

### Quick Usage Example

```java
// Initialize and validate
JKKHakkoSODCC cc = new JKKHakkoSODCC();
cc.validate();        // delegates to KKPRC14901.check()

// Dispatch
cc.dispatch();        // delegates to JKKSodSendCC.send()
```

### Things to Keep in Mind

- All classes are currently **auto-generated fixtures**. They contain minimal stub implementations (mostly empty or single-line method bodies). The interfaces and delegation patterns are established; production logic is expected to be added on top.
- The naming convention (`KKPRC`, `JKK`, `EKK`, `ESC`, `KKW`) appears to be code-generated and likely maps to specific business operation codes.
- There are no frameworks, dependency injection containers, or external service integrations detected. The project is intentionally lightweight.
- The `JKKBpServiceBase` template method pattern is the primary inheritance hierarchy — use it as a base when creating new services in the `bp` package.
- Tests use JUnit 4. The existing test (`JKKHakkoSODCCTest`) is a placeholder and should be expanded with real assertions.
