# grookage/leia architecture

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

- Interactive diagram: https://gitdiagram.com/grookage/leia
- Repository: https://github.com/grookage/leia

## Overview

##### Main Components
- Client-side Components:
- leia-client and leia-client-dropwizard: These modules provide client libraries and bundles to help with schema serialization/deserialization, HTTP communication, and integration into Dropwizard-based applications.
- Server-side Components:
- leia-dropwizard and leia-dropwizard-es: These include Dropwizard bundles that help build the schema server. They expose RESTful APIs (via resources, health checks, exception mappers) to manage and ingest schemas.
- leia-aerospike and leia-aerospike-dw: Specifically targeted at Aerospike integration with health checks and bundle support.
- leia-elastic: Manages the integration with Elasticsearch including configuration, health checks (through ElasticHealthCheck), repository access, and storage.
- leia-http-processor: Handles incoming HTTP requests for processing messages, transforming them if required, and invoking the appropriate pipelines.
- Core Schema Handling and Validation:
- leia-core: Contains the ingestion engine and processing logic for schema registration. It includes processors (Approve, Create, Reject, Update) and a central hub (SchemaProcessorHub) that ties them together.
- leia-schema-validator: Provides a validation layer, supporting both static and dynamic validation of schemas based on their structure.
- Common Libraries and Data Models:
- leia-common and leia-models: These handle shared utilities, exception codes, annotations, attribute definitions, qualifiers, and common data structures that ensure consistency across the modules.
- Infrastructure and Repository Components:
- leia-repository: Offers mechanisms to interface with a persistent store for schemas (including optional in-memory caching as suggested by the CacheConfig).
- Build Management:
- leia-bom and leia-parent: They centralize dependency management and provide a parent configuration for other modules.

##### Relationships and Interactions
- The client modules will interact with the Dropwizard bundles on the server side via RESTful APIs for schema management.
- The ingestion process, housed within leia-core, interacts with the validator (leia-schema-validator) and repository (leia-repository) layers to maintain the versioned schema registry.
- Modules like leia-elastic, leia-aerospike, and leia-http-processor act as connectors with external data stores or communication protocols, interfacing directly with the ingestion engine and client bundles.
- Common modules (leia-common and leia-models) are used by almost every other module to ensure standard definitions of schemas, attributes, qualifiers, and error handling.
- There is a clear maker–checker process built into the schema ingestion pipeline (from the README example) that demands custom RBAC through a SchemaUpdater that users need to implement.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project is divided into distinct modules, each responsible for a single area (e.g., ingestion, validation, client interface, repository), which reflects a layered architecture.
- Extensibility & Modularization: The use of Maven multi-modules (with clearly separated domains) and Dropwizard bundles indicates that new integrations and customizations (such as custom version generators or RBAC implementations) can be added with minimal changes.
- Microservice-Like Structure inside a Monorepo: Although it is organized as a single multi-module project, each module acts as an independent component that can be built, tested, and understood separately.
- Emphasis on Common Data Contracts: The heavy reliance on common models and shared libraries enforces consistency in data schema and error handling across the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        client1["Client: leia-client"]:::client
        client2["Client: leia-client-dropwizard"]:::client
    end

    subgraph "Server Layer"
        server1["Server: leia-dropwizard"]:::server
        server2["Server: leia-dropwizard-es"]:::server
        core["Ingestion Core: leia-core"]:::core
        validator["Schema Validator: leia-schema-validator"]:::server
        repo["Repository: leia-repository"]:::server
    end

    subgraph "External Integrations"
        aero["Aerospike: leia-aerospike"]:::external
        aeroDW["Aerospike DW: leia-aerospike-dw"]:::external
        elastic["Elasticsearch: leia-elastic"]:::external
        httpProc["HTTP Processor: leia-http-processor"]:::external
    end

    subgraph "Shared Models & Utilities"
        common["Common: leia-common"]:::shared
        models["Models: leia-models"]:::shared
    end

    subgraph "Build Management"
        bom["BOM: leia-bom"]:::build
        parent["Parent: leia-parent"]:::build
    end

    %% Connections between layers
    client1 -->|"HTTPRequest"| server1
    client2 -->|"HTTPRequest"| server2

    server1 -->|"SchemaIngest"| core
    server2 -->|"SchemaIngest"| core

    core -->|"Validate"| validator
    core -->|"StoreSchema"| repo

    aero -->|"HealthCheck"| core
    aeroDW -->|"HealthCheck"| core
    elastic -->|"IndexSchema"| core
    httpProc -->|"ProcessMessage"| core

    common -.->|"Supports"| core
    models -.->|"Supports"| core

    %% Style definitions
    classDef client fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef server fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef external fill:#ffe5b4,stroke:#333,stroke-width:2px;
    classDef shared fill:#ccffff,stroke:#333,stroke-width:2px;
    classDef build fill:#e6e6fa,stroke:#333,stroke-width:2px;

    %% Click Events for Client Layer
    click client1 "https://github.com/grookage/leia/blob/master/leia-client/pom.xml"
    click client1 "https://github.com/grookage/leia/tree/master/leia-client/src/main/java/com/grookage/leia/client"
    click client2 "https://github.com/grookage/leia/blob/master/leia-client-dropwizard/pom.xml"
    click client2 "https://github.com/grookage/leia/tree/master/leia-client-dropwizard/src/main/java/com/grookage/leia/dw"

    %% Click Events for Server Layer
    click server1 "https://github.com/grookage/leia/blob/master/leia-dropwizard/pom.xml"
    click server1 "https://github.com/grookage/leia/tree/master/leia-dropwizard/src/main/java/com/grookage/leia/dropwizard"
    click server2 "https://github.com/grookage/leia/blob/master/leia-dropwizard-es/pom.xml"
    click server2 "https://github.com/grookage/leia/tree/master/leia-dropwizard-es/src/main/java/com/grookage/leia/es/dropwizard"
    click core "https://github.com/grookage/leia/blob/master/leia-core/pom.xml"
    click core "https://github.com/grookage/leia/tree/master/leia-core/src/main/java/com/grookage/leia/core/ingestion"
    click core "https://github.com/grookage/leia/tree/master/leia-core/src/main/java/com/grookage/leia/hub/processors"
    click validator "https://github.com/grookage/leia/blob/master/leia-schema-validator/pom.xml"
    click validator "https://github.com/grookage/leia/tree/master/leia-schema-validator/src/main/java/com/grookage/leia/validator"
    click repo "https://github.com/grookage/leia/blob/master/leia-repository/pom.xml"
    click repo "https://github.com/grookage/leia/tree/master/leia-repository/src/main/java/com/grookage/leia/repository"

    %% Click Events for External Integrations
    click aero "https://github.com/grookage/leia/blob/master/leia-aerospike/pom.xml"
    click aero "https://github.com/grookage/leia/tree/master/leia-aerospike/src/main/java/com/grookage/leia/aerospike"
    click aeroDW "https://github.com/grookage/leia/blob/master/leia-aerospike-dw/pom.xml"
    click aeroDW "https://github.com/grookage/leia/tree/master/leia-aerospike-dw/src/main/java/com/grookage/leia/aerospikedw"
    click elastic "https://github.com/grookage/leia/blob/master/leia-elastic/pom.xml"
    click elastic "https://github.com/grookage/leia/tree/master/leia-elastic/src/main/java/com/grookage/leia/elastic"
    click httpProc "https://github.com/grookage/leia/blob/master/leia-http-processor/pom.xml"
    click httpProc "https://github.com/grookage/leia/tree/master/leia-http-processor/src/main/java/com/grookage/leia/http/processor"

    %% Click Events for Shared Models & Utilities
    click common "https://github.com/grookage/leia/blob/master/leia-common/pom.xml"
    click common "https://github.com/grookage/leia/tree/master/leia-common/src/main/java/com/grookage/leia/common"
    click models "https://github.com/grookage/leia/blob/master/leia-models/pom.xml"
    click models "https://github.com/grookage/leia/tree/master/leia-models/src/main/java/com/grookage/leia/models"

    %% Click Events for Build Management
    click bom "https://github.com/grookage/leia/blob/master/leia-bom/pom.xml"
    click parent "https://github.com/grookage/leia/blob/master/leia-parent/pom.xml"
```
