# sava-software/sava architecture

> Architecture diagram of the GitHub repository sava-software/sava, 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/sava-software/sava
- Repository: https://github.com/sava-software/sava

## Overview

##### Main Components
- Core Module – This is the heart of the project. It includes lower-level Solana cryptography, account management (including various account types, key pair signers, PDA handling), data serialization (using Borsh), encoding utilities, and common utilities like hashing.
- RPC Module – Contains the HTTP and WebSocket clients along with the JSON-based request/response handling. It is responsible for interacting with Solana network endpoints. It includes data structures for representing blocks, transactions, accounts, and error handling.
- Vanity Module – Implements functionality for generating vanity Solana addresses. This part involves specific algorithms and worker classes to search for addresses that satisfy certain patterns.
- Examples – Provides sample code showing how to use these libraries together, offering usage scenarios for the core features, RPC interactions, and perhaps vanity address generation.
- Build and Configuration – The Gradle build files and .github workflows indicate CI/CD integration, so include a reference to the build pipeline and configuration scripts if needed.

##### Relationships and Interactions
- The Core module underpins other components; for instance, the RPC module extensively uses the cryptography, encoding, and serialization utilities from core.
- The RPC clients are used to make network calls to the Solana blockchain. For clarity, show directional data flow from RPC clients to Solana servers (even if external) and back.
- The Vanity module leverages core components (for cryptography and address manipulation) and likely interfaces with the core’s account utilities.
- The Examples module demonstrates how the above modules collaborate, so its interactions should reflect calls to both core and rpc libraries (and possibly the vanity toolkit) in a sample application flow.
- Including testing components (shown in the file structure) to indicate unit tests and integration points, though these might be secondary details.

##### Architectural Patterns and Key Technologies
- Separation of Concerns – Core handles cryptography/serialization, RPC handles networking, and Vanity handles specialized address generation.
- Layered Design – You might show an outer layer (client facing API via examples) that interacts with two inner layers: one for core operations and another for RPC communications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
      Examples["Examples\n(Sample Code)"]:::examples
    end

    subgraph "Service Layer"
      RPC["RPC Module\n(HTTP/WebSocket Clients\nJSON Request/Response)"]:::rpc
      Vanity["Vanity Module\n(Vanity Address Generation)"]:::vanity
    end

    subgraph "Core Layer"
      Core["Core Module\n(Cryptography, Serialization,\nAccounts, Utilities)"]:::core
    end

    BuildConfig["Build & Config\n(Gradle, CI/CD Workflows)"]:::config
    Solana["Solana Blockchain"]:::external

    %% Relationships
    Examples -->|"calls"| RPC
    Examples -->|"calls"| Vanity
    Examples -->|"calls"| Core

    RPC -->|"uses"| Core
    Vanity -->|"uses"| Core

    RPC -->|"calls"| Solana

    BuildConfig -->|"builds"| Examples
    BuildConfig -->|"builds"| RPC
    BuildConfig -->|"builds"| Vanity
    BuildConfig -->|"builds"| Core

    %% Click Events
    click Core "https://github.com/sava-software/sava/tree/main/core/src/main/java/software/sava/core"
    click RPC "https://github.com/sava-software/sava/tree/main/rpc/src/main/java/software/sava/rpc"
    click Vanity "https://github.com/sava-software/sava/tree/main/vanity/src/main/java/software/sava/vanity"
    click Examples "https://github.com/sava-software/sava/tree/main/examples/src/main/java/software/sava/examples"
    click BuildConfig "https://github.com/sava-software/sava/blob/main/build.gradle"
    click BuildConfig "https://github.com/sava-software/sava/blob/main/.github/workflows/gradle.yml"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef rpc fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef vanity fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef examples fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef config fill:#D5F5E3,stroke:#117864,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#7D6608,stroke-width:2px;
```
