# apache/unomi architecture

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

- Interactive diagram: https://gitdiagram.com/apache/unomi
- Repository: https://github.com/apache/unomi

## Overview

##### Project type and purpose
- This is a modular, full-stack “Context Server” (a Customer Data Platform) implemented as an OSGi‐based Java back end.
- Purpose: collect events, build user profiles, run personalization/A-B tests, expose REST/GraphQL APIs, plug in connectors, and persist data (default: Elasticsearch).

##### High-level module structure
- Core API (api/) & Common utilities (common/)
- Core services implementing business logic (services/)
- Persistence layer: SPI (persistence-spi/) + Elasticsearch implementation (persistence-elasticsearch/)
- HTTP interfaces: REST endpoints (rest/) + GraphQL endpoints (graphql/cxs-impl + graphql/graphql-ui)
- Plugin mechanism: OSGi bundles for built-in plugins (plugins/*) and extensions (extensions/*)
- Command-line tools & shell commands (tools/shell-commands, tools/shell-dev-commands, lifecycle-watcher/)
- Packaging/Deployment: Karaf features (kar/, graphql/karaf-feature), Docker (docker/), assembly (package/), build scripts

##### README insights
- Implements OASIS Context Server spec
- Serves personalization and A/B tests
- Default persistence: Elasticsearch
- Many independently deployable bundles loaded into an OSGi container (Apache Karaf)

##### Essential details
- Modular build modules as deployable bundles in one container
- Switching point between pluggable SPI and concrete implementation
- Extension discovery & Blueprint wiring
- External service endpoints and data flows

## Diagram (Mermaid)

```mermaid
graph TD
    WebClients["Web Clients (SPA / SDK)"]:::external
    CLI["CLI Tools"]:::cli
    Elasticsearch["Elasticsearch Cluster"]:::db
    Geo["GeoNames REST Service"]:::external
    Salesforce["Salesforce REST Service"]:::external
    MessageRouter["Message Router (Apache Camel)"]:::external

    subgraph "OSGi Container (Apache Karaf)"
        API["Core API"]:::core
        Common["Common Utilities"]:::core
        Services["Core Services"]:::core
        PersistenceSPI["Persistence SPI"]:::persistence
        ESAdapter["Elasticsearch Persistence Adapter"]:::persistence
        REST["REST API Layer"]:::http
        GraphQLImpl["GraphQL API Implementation"]:::http
        GraphQLUI["GraphQL UI Frontend"]:::http
        Plugins["Built-in Plugin Bundles"]:::extensions
        Extensions["Extension Bundles"]:::extensions
        CLIBundles["Command-Line & Shell Bundles"]:::cli
        KarafFeatures["Karaf Features (OSGi descriptors)"]:::infra
        DockerDeploy["Docker Deployment Config"]:::infra
        Assembly["Assembly & Distribution Package"]:::infra
        IntegrationTests["Integration Tests Module"]:::infra
    end

    WebClients -->|"HTTP"| REST
    WebClients -->|"HTTP"| GraphQLImpl
    CLI -->|"HTTP"| REST
    REST -->|"Invokes"| Services
    GraphQLImpl -->|"Invokes"| Services
    Services -->|"SPI call"| PersistenceSPI
    PersistenceSPI -->|"Adapter SPI"| ESAdapter
    ESAdapter -->|"HTTP"| Elasticsearch
    Services -->|"OSGi Event / SPI call"| Extensions
    Extensions -->|"Integrates with"| Geo
    Extensions -->|"Integrates with"| Salesforce
    Extensions -->|"Routes via"| MessageRouter

    classDef core fill:#D6EAF8,stroke:#21618C,color:#1B4F72
    classDef persistence fill:#D5F5E3,stroke:#196F3D,color:#1D8348
    classDef http fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef extensions fill:#E8DAEF,stroke:#6C3483,color:#4A235A
    classDef cli fill:#F2F3F4,stroke:#616A6B,color:#17202A
    classDef infra fill:#FDEDEC,stroke:#C0392B,color:#641E16
    classDef external fill:#D5DBDB,stroke:#6E2C00,color:#4D0101
    classDef db fill:#A9DFBF,stroke:#196F3D,color:#145A32

    click API "https://github.com/apache/unomi/tree/master/api/src/main/java/org/apache/unomi/api"
    click Common "https://github.com/apache/unomi/tree/master/common/src/main/java/org/apache/unomi/common"
    click Services "https://github.com/apache/unomi/tree/master/services/src/main/java/org/apache/unomi/services/impl"
    click PersistenceSPI "https://github.com/apache/unomi/tree/master/persistence-spi/src/main/java/org/apache/unomi/persistence/spi"
    click ESAdapter "https://github.com/apache/unomi/tree/master/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch"
    click REST "https://github.com/apache/unomi/tree/master/rest/src/main/java/org/apache/unomi/rest/endpoints"
    click REST "https://github.com/apache/unomi/tree/master/rest/src/main/java/org/apache/unomi/rest/server"
    click GraphQLImpl "https://github.com/apache/unomi/tree/master/graphql/cxs-impl/src/main/java/org/apache/unomi/graphql"
    click GraphQLUI "https://github.com/apache/unomi/tree/master/graphql/graphql-ui/src/main/resources/assets"
    click GraphQLUI "https://github.com/apache/unomi/tree/master/graphql/graphql-ui/src/main/webapp"
    click Plugins "https://github.com/apache/unomi/tree/master/plugins"
    click Extensions "https://github.com/apache/unomi/tree/master/extensions"
    click CLIBundles "https://github.com/apache/unomi/tree/master/tools/shell-commands"
    click CLIBundles "https://github.com/apache/unomi/tree/master/tools/shell-dev-commands"
    click CLIBundles "https://github.com/apache/unomi/tree/master/lifecycle-watcher"
    click KarafFeatures "https://github.com/apache/unomi/blob/master/kar/src/main/feature/feature.xml"
    click KarafFeatures "https://github.com/apache/unomi/blob/master/graphql/karaf-feature/src/main/feature/feature.xml"
    click KarafFeatures "https://github.com/apache/unomi/tree/master/extensions/groovy-actions/karaf-kar"
    click KarafFeatures "https://github.com/apache/unomi/tree/master/plugins/salesforce-connector/karaf-kar"
    click DockerDeploy "https://github.com/apache/unomi/tree/master/docker/src/main/docker/Dockerfile"
    click DockerDeploy "https://github.com/apache/unomi/blob/master/docker/src/main/docker/docker-compose.yml"
    click Assembly "https://github.com/apache/unomi/blob/master/package/src/main/descriptors/src.xml"
    click Assembly "https://github.com/apache/unomi/tree/master/package/src/main/resources/bin"
    click IntegrationTests "https://github.com/apache/unomi/tree/master/itests/src/test/java/org/apache/unomi/itests"
```
