# expediagroup/rapid-java-sdk architecture

> Architecture diagram of the GitHub repository expediagroup/rapid-java-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/expediagroup/rapid-java-sdk
- Repository: https://github.com/expediagroup/rapid-java-sdk

## Overview

##### Main Components
- SDK Core:
- Contains the fundamental layers including the client implementations (e.g., BaseRapidClient, BaseXapClient, ExpediaGroupClient), configuration and credential management, and domain models.
- Organized under code/src/main/kotlin/com/expediagroup/sdk/core, which houses sub-packages for client, configuration, constant definitions, contract abstractions, models (including exceptions and paging), and plugins.
- Plugin Subsystem:
- Provides modular capabilities for authentication, encoding, exception handling, HTTP timeouts, logging, request handling, serialization, etc.
- Located in code/src/main/kotlin/com/expediagroup/sdk/core/plugin and its various children.
- Domain & Operations Layer:
- Business operations such as booking, change room details, and availability checks. These are implemented in code/src/main/kotlin/com/expediagroup/sdk/rapid/operations.
- Domain models mapping properties, itineraries, payments, etc., are contained in code/src/main/kotlin/com/expediagroup/sdk/rapid/models.
- Code Generation / Customization Engine:
- This module (under customizations/generator/openapi) reads and processes OpenAPI specifications and post-processes via custom rules (see the extensive post-processor rules directory).
- This component is essential in keeping the SDK aligned with rapidly changing API definitions.
- Examples & Documentation:
- The examples directory provides real usage scenarios exemplifying how the SDK is consumed.
- The docs folder (and README) supplies guidance and usage details.
- Build/Deployment Tools:
- The presence of .github workflows, pom.xml files (for Maven builds), and other deployment/configuration files indicates continuous integration and publishing setups.

##### Relationships and Interactions
- The front-facing client (ExpediaGroupClient and its derivatives) acts as the entry point for integration. It uses underlying HTTP handlers (with OkHttp support) to communicate with external Rapid API endpoints.
- The Configuration components (e.g., ClientConfiguration, Credentials, and the various environment-specific configurations) initialize and supply necessary settings to the clients.
- The Plugin system allows for application-specific customizations and interception of calls. For example, authentication plugins ensure secure requests, and logging plugins capture request/response details.
- The Domain/Operations layer uses both the client and configuration settings and maps the raw API responses to domain models, enforcing business contracts as defined in the Contract packages.
- The Code Generation module takes API definitions (likely from the specs.yaml and transformedSpecs.yaml files) and—with templates and post-processors—generates domain classes and operation methods, which then integrate into the core SDK layers.
- Examples and tests (also found in the customizations and examples directories) illustrate how these components are wired together to build a full end-to-end integration.

##### Architectural Patterns & Design Principles
- Layered Architecture: Separation of concerns is apparent by dividing functionality into client, configuration, domain models, and plugins.
- Extensibility via Plugins: The design supports various plugins (authentication, logging, etc.) that allow easy augmentation or overriding of functionality without affecting core classes.
- Code Generation: Customizations through an OpenAPI-based generator facilitate automatic and consistent updates, suggesting an emphasis on maintainability and scalability.
- Clear API Contract interfaces ensuring that client calls, error handling, and responses adhere to a consistent design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        AC["API Consumer (SDK Users)"]
    end

    %% SDK Layer
    subgraph "SDK Layer"
        sdkCore["SDK Core"]
        plugin["Plugin Subsystem"]
        ops["Domain & Operations: Operations"]
        models["Domain & Operations: Models"]
    end

    %% External Integration
    subgraph "External Integration"
        rapid["Rapid API Endpoints"]
    end

    %% Supporting Components
    subgraph "Supporting Components"
        examples["Examples"]
        docs["Docs"]
        build["Build/Deployment Tools"]
    end

    %% Code Generation Engine (Bottom Layer)
    codeGen["Code Generation Engine"]

    %% Connections
    AC -->|"calls"| sdkCore
    sdkCore -->|"uses"| plugin
    sdkCore -->|"executes"| ops
    sdkCore -->|"maps"| models
    sdkCore -->|"calls"| rapid
    codeGen -->|"generates"| sdkCore
    AC -->|"refers_to"| examples
    AC -->|"refers_to"| docs
    build -->|"builds"| sdkCore
    build -->|"triggers"| codeGen

    %% Click Events
    click sdkCore "https://github.com/expediagroup/rapid-java-sdk/tree/main/code/src/main/kotlin/com/expediagroup/sdk/core"
    click plugin "https://github.com/expediagroup/rapid-java-sdk/tree/main/code/src/main/kotlin/com/expediagroup/sdk/core/plugin"
    click ops "https://github.com/expediagroup/rapid-java-sdk/tree/main/code/src/main/kotlin/com/expediagroup/sdk/rapid/operations"
    click models "https://github.com/expediagroup/rapid-java-sdk/tree/main/code/src/main/kotlin/com/expediagroup/sdk/rapid/models"
    click codeGen "https://github.com/expediagroup/rapid-java-sdk/tree/main/customizations/generator/openapi"
    click examples "https://github.com/expediagroup/rapid-java-sdk/tree/main/examples"
    click docs "https://github.com/expediagroup/rapid-java-sdk/tree/main/docs"
    click build "https://github.com/expediagroup/rapid-java-sdk/blob/main/code/pom.xml"

    %% Styles
    classDef user fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef sdk fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef plugin fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef domain fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef generator fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef support fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;

    class AC user;
    class sdkCore sdk;
    class plugin plugin;
    class ops domain;
    class models domain;
    class rapid external;
    class codeGen generator;
    class examples support;
    class docs support;
    class build support;
```
