# Getting Started

Welcome to **Optage Mini Fixture**. If you just joined the team, this guide points you to the pages that matter first and shows you around the codebase.

## What This Project Does

Optage Mini Fixture is a lightweight Java application built on the **KOPT** platform. It provides batch processing and business-service capabilities — including a SOD (Service Order Dispatch) pipeline, contract processing, and ESC service control. The codebase is structured around distinct subsystem modules, each with its own responsibility.

## Recommended Reading Order

| Step | Page | Why |
|------|------|-----|
| 1 | **Project Overview** — the high-level architecture wiki page | Understand the system boundaries and subsystem layout |
| 2 | **Architecture** — module dependencies and data flow | See how `bp`, `batch`, `ekk`, and `esc` fit together |
| 3 | **Module Deep Dive** — the `com.optage.kopt.bp` module | The business-process package is the most interconnected; start here |

Read these in order before diving into source code. The architecture page will give you context so the class references below make sense.

## Key Entry Points

If you only understand a handful of classes, make it these:

- **[JKKHakkoSODCC](src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java)** — The main business-process dispatcher. Its `dispatch()` and `validate()` methods coordinate downstream batch and contract processing. This is the top-level entry point.
- **[JKKBpServiceBase](src/main/java/com/optage/kopt/bp/JKKBpServiceBase.java)** — The shared base class for business-process services. Extends it to inherit the common initialization logic.
- **[JKKSodRequestDTO](src/main/java/com/optage/kopt/dto/JKKSodRequestDTO.java)** / **[JKKSodResponseDTO](src/main/java/com/optage/kopt/dto/JKKSodResponseDTO.java)** — The request/response data structures for the SOD pipeline. These flow through the entire dispatch cycle.
- **[KKPRC14901](src/main/java/com/optage/kopt/batch/KKPRC14901.java)** — The primary batch processor. Invokes contract processing through `EKK0301A010`.
- **[EKK0301A010](src/main/java/com/optage/kopt/ekk/EKK0301A010.java)** — Contract processing logic. Chains to the KKW batch trigger for downstream events.

## Project Structure

```
src/main/java/com/optage/kopt/
├── batch/          Batch-processing jobs (KKPRC*)
├── bp/             Business-process core (SOD dispatch, helpers, senders)
├── dto/            Data-transfer objects (request / response)
├── ekk/            Contract processing services
├── esc/            ESC service control
├── kkw/            KKW batch trigger services
└── unrelated/      Isolated, self-contained classes
```

Test sources mirror the production layout under `src/test/java/com/optage/kopt/`.

### Subsystem overview

```mermaid
flowchart TD
  subgraph Core["Business Process Core"]
    SOCC["JKKHakkoSODCC"]
    SSS["JKKSodSendCC"]
    BSB["JKKBpServiceBase"]
    SH["JKKHakkoSODHelper"]
  end

  subgraph Batch["Batch Processing"]
    K14["KKPRC14901"]
    K24["KKPRC24901"]
    K34["KKPRC34901"]
  end

  subgraph Contract["Contract Processing"]
    E010["EKK0301A010"]
    E020["EKK0301A020"]
  end

  subgraph Services["Services"]
    ESC["ESC0101B001"]
    KKW["KKW0100B001"]
  end

  subgraph Data["Data"]
    RDTO["JKKSodRequestDTO"]
    SDTO["JKKSodResponseDTO"]
  end

  subgraph Test["Tests"]
    TC["JKKHakkoSODCCTest"]
  end

  SOCC --> SSS
  SOCC --> K14
  K14 --> E010
  E010 --> KKW
```

### Subsystem responsibilities

- **`batch`** — Scheduled and on-demand batch jobs. Each `KKPRC*` class handles a distinct batch routine (`KKPRC14901` is the primary entry; `KKPRC24901` and `KKPRC34901` handle secondary and tertiary routines).
- **`bp`** — Business-process core. Orchestrates the SOD (Service Order Dispatch) pipeline. Contains the main dispatcher (`JKKHakkoSODCC`), the base service class (`JKKBpServiceBase`), helper utilities, and the sender component (`JKKSodSendCC`).
- **`dto`** — Plain data-transfer objects shared across subsystems. Currently the SOD request and response DTOs.
- **`ekk`** — Contract processing. `EKK0301A010` handles the primary contract flow; `EKK0301A020` is a secondary contract processor.
- **`esc`** — ESC service control for managing downstream service lifecycle.
- **`kkw`** — KKW batch trigger services that fire events after contract processing.

## Configuration

This project is built with **Maven** and is minimal by design.

| File | Purpose |
|------|---------|
| [pom.xml](pom.xml) | Maven build descriptor — defines the GAV coordinates (`com.optage.kopt:optage-mini-fixture:1.0.0-SPEC-SCOPED-WIKI`), packaging type (`jar`), and project metadata |

There are no application properties, YAML configs, or database connection files in the repository. Build and run via standard Maven commands:

```
mvn compile        # Compile source
mvn test           # Run tests (uses JUnit)
mvn package        # Build the JAR
```

## Common Patterns

- **Fixture classes with code comments** — Every class carries a Javadoc comment indicating its role (`— auto-generated fixture class for SPEC-SCOPED-WIKI tests`). This naming convention makes it easy to identify auto-generated vs. hand-written code.
- **Package-by-subsystem** — Each subsystem lives in its own sub-package under `com.optage.kopt`. Follow this pattern when adding new code: pick the right subsystem and name the class according to its role (CC for command/controller, DTO for data, etc.).
- **Chained dispatching** — High-level methods delegate downstream. `JKKHakkoSODCC.dispatch()` calls `JKKSodSendCC.send()`, and `KKPRC14901.run()` calls `EKK0301A010.process()`. Follow the chain to understand end-to-end flows.
- **Base class inheritance** — Business-process classes extend `JKKBpServiceBase` to inherit common initialization. Check `baseInit()` for shared setup logic.
- **Test co-location** — Tests live in `src/test/java` mirroring the production package structure. For example, `JKKHakkoSODCCTest` sits directly alongside `JKKHakkoSODCC`. Use JUnit for unit tests.

## Building and Running

```bash
# Compile
mvn compile

# Run tests
mvn test

# Package
mvn package

# The resulting JAR is target/optage-mini-fixture-1.0.0-SPEC-SCOPED-WIKI.jar
```

## Next Steps

- Browse the **Architecture** wiki page for a deeper look at module dependencies.
- Read the **[JKKHakkoSODCC](src/main/java/com/optage/kopt/bp/JKKHakkoSODCC.java)** source to trace the main dispatch flow.
- Check out the **[JKKHakkoSODCCTest](src/test/java/com/optage/kopt/bp/JKKHakkoSODCCTest.java)** test to see how the codebase exercises the SOD pipeline.
