# vkcom/vkid-android-sdk architecture

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

- Interactive diagram: https://gitdiagram.com/vkcom/vkid-android-sdk
- Repository: https://github.com/vkcom/vkid-android-sdk

## Overview

##### Project type and purpose
- This is a multi-module Android SDK monorepo (an “open‑source tool”/library) for VK ID OAuth 2.1 authorization and auxiliary UI features (OneTap, multibranding).
- It publishes a suite of AAR artifacts (core vk‑id client, network, logging, analytics, tracking, OneTap widgets, multibranding widgets, XML variants) and accompanying build plugins, code quality tools (Detekt, Dokka), metrics, and sample apps.

##### High‑level module structure
- build-logic (custom Gradle convention and quality plugins)
- sdk/ (the heart of the library)
– core modules:
- vkid (OAuth flows, token storage, IPC via AIDL, DI, concurrency)
- network (HTTP client, API contract, SSL pinning)
- logger (LogEngine abstractions)
- analytics (event/stat tracking)
- tracking-core/tracer/noop (crash & performance reporter)
- vk-sdk-support (exceptions, WithVKIDToken)
– feature modules (depend on core):
- onetap-common/compose/xml (OneTap UI in Compose or XML)
- multibranding‑common/compose/xml (OAuth list widget)
- baseline-profile (profile generator)
– ui‑tests (instrumented tests covering all UI variants)
- sample/ (apps demonstrating integration: Kotlin Compose app, XML app, metrics app, old‑SDK example)
- docs/ (Dokka‑generated API documentation)
- scripts/ (CI/CD, release, Allure reporting, backups, renovate)

##### Relationships & data flows
- Build pipeline:
build-logic plugins → configure module conventions → Gradle compiles each sdk subproject → produce AARs → Dokka generates docs → Detekt applies static checks → metrics plugin gathers CI metrics → artifacts published to Artifactory & Maven repo.
- Runtime flow (in a consuming Android app):
App calls VKID.init(context) → VKID.instance orchestrates:
– UI modules (OneTap/composables or XML layouts) present auth widgets
– On user action → network module calls VK OAuth endpoints → responses → core vkid token storage → callback to app via VKIDAuthCallback
– Later refreshToken(), fetchUser(), logout flows all go back through network + core storage
- IPC / AIDL flow:
If a silent auth provider is present, core vkid uses AIDL interfaces (ISilentAuthInfoProvider) to query providers in other apps.

##### Architectural patterns & principles
- Modular decomposition: core vs. feature vs. sample
- Convention‑over‑configuration via Gradle plugin modules in build-logic
- Clean separation of concerns: network, storage, UI, analytics, logging, tracking
- Dependency inversion: feature modules depend on core abstractions (api contracts) only
- Plugin‑based quality gates: Detekt, Dokka skip plugin, metrics, binary compatibility validator

- Build system (Gradle + build-logic plugins)
- SDK modules (grouped by layer—core, network, logging, tracking, feature)
- External services: VK ID OAuth backend, Firestore (metrics), GitLab (CI/MR comments), Artifactory (artifact repo)
- Consumer apps: sample/app, sample/xml, and third‑party Android apps integrating the SDK
- IPC/AIDL boundary for silent auth providers

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build Layer
    subgraph "Build Layer"
        BuildLogic["build-logic"]:::build
        Scripts["scripts"]:::build
    end

    %% Core SDK
    subgraph "Core SDK"
        VkidCore["vkid-core"]:::core
        Network["network"]:::core
        Logger["logger"]:::core
        Analytics["analytics"]:::core
        TrackingCore["tracking-core"]:::core
        TrackingTracer["tracking-tracer"]:::core
        TrackingNoop["tracking-noop"]:::core
        VkSupport["vk-sdk-support"]:::core
    end

    %% Feature Widgets
    subgraph "Feature Widgets"
        OneTapCommon["OneTap-Common"]:::feature
        OneTapCompose["OneTap-Compose"]:::feature
        OneTapXML["OneTap-XML"]:::feature
        MultiCommon["Multibranding-Common"]:::feature
        MultiCompose["Multibranding-Compose"]:::feature
        MultiXML["Multibranding-XML"]:::feature
        Baseline["Baseline-Profile"]:::feature
    end
    UItests["UI-Tests"]:::feature

    %% Samples & Docs
    subgraph "Samples & Docs"
        SampleCompose["Sample Compose App"]:::app
        SampleXML["Sample XML App"]:::app
        SampleMetrics["Sample Metrics App"]:::app
        SampleOld["Sample Old-SDK Example"]:::app
        Docs["API Docs"]:::app
    end

    %% Third-Party Consumer
    ThirdParty["3rd-Party Android App"]:::app

    %% External Services
    subgraph "External Services"
        VKBackend["VK OAuth Backend"]:::external
        Artifactory["Artifactory/Maven Repo"]:::external
        Firestore["Firestore Metrics"]:::external
        GitLab["GitLab CI/MR Comments"]:::external
    end

    %% Build Relationships
    BuildLogic --> VkidCore
    BuildLogic --> Network
    BuildLogic --> Logger
    BuildLogic --> Analytics
    BuildLogic --> TrackingCore
    BuildLogic --> TrackingTracer
    BuildLogic --> TrackingNoop
    BuildLogic --> VkSupport
    BuildLogic --> OneTapCommon
    BuildLogic --> OneTapCompose
    BuildLogic --> OneTapXML
    BuildLogic --> MultiCommon
    BuildLogic --> MultiCompose
    BuildLogic --> MultiXML
    BuildLogic --> Baseline
    BuildLogic --> UItests
    Scripts --> Firestore
    Scripts --> GitLab

    %% Publish Artifacts
    VkidCore --> Artifactory
    Network --> Artifactory
    Logger --> Artifactory
    Analytics --> Artifactory
    TrackingCore --> Artifactory
    TrackingTracer --> Artifactory
    TrackingNoop --> Artifactory
    VkSupport --> Artifactory
    OneTapCommon --> Artifactory
    OneTapCompose --> Artifactory
    OneTapXML --> Artifactory
    MultiCommon --> Artifactory
    MultiCompose --> Artifactory
    MultiXML --> Artifactory
    Baseline --> Artifactory

    %% App Dependency on AARs
    SampleCompose --> Artifactory
    SampleXML --> Artifactory
    SampleMetrics --> Artifactory
    SampleOld --> Artifactory
    ThirdParty --> Artifactory

    %% Runtime Flow
    SampleCompose -->|"init() & UI"| OneTapCompose
    SampleXML -->|"init() & UI"| OneTapXML
    ThirdParty -->|"uses SDK UI"| OneTapCommon
    OneTapCompose -->|"token request"| VkidCore
    OneTapXML -->|"token request"| VkidCore
    VkidCore -->|"HTTP call"| Network
    Network -.->|"OAuth API"| VKBackend
    VKBackend -.->|"response"| Network
    Network -->|"store token"| VkidCore
    VkidCore -->|"callback"| SampleCompose
    VkidCore -->|"callback"| SampleXML
    VkidCore -->|"callback"| ThirdParty

    %% IPC/AIDL Flow
    VkidCore -.->|"AIDL query"| VkSupport

    %% Click Events
    click BuildLogic "https://github.com/vkcom/vkid-android-sdk/tree/master/build-logic/"
    click VkidCore "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/vkid/"
    click Network "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/network/"
    click Logger "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/logger/"
    click Analytics "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/analytics/"
    click TrackingCore "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/tracking‑core/"
    click TrackingTracer "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/tracking‑tracer/"
    click TrackingNoop "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/tracking‑noop/"
    click VkSupport "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/core/vk‑sdk‑support/"
    click OneTapCommon "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/onetap/onetap‑common/"
    click OneTapCompose "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/onetap/onetap‑compose/"
    click OneTapXML "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/onetap/onetap‑xml/"
    click MultiCommon "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/multibranding/multibranding‑common/"
    click MultiCompose "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/multibranding/multibranding‑compose/"
    click MultiXML "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/multibranding/multibranding‑xml/"
    click Baseline "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/baseline‑profile/"
    click UItests "https://github.com/vkcom/vkid-android-sdk/tree/master/sdk/ui‑tests/"
    click SampleCompose "https://github.com/vkcom/vkid-android-sdk/tree/master/sample/app/"
    click SampleXML "https://github.com/vkcom/vkid-android-sdk/tree/master/sample/xml/"
    click SampleMetrics "https://github.com/vkcom/vkid-android-sdk/tree/master/sample/metrics‑app/"
    click SampleOld "https://github.com/vkcom/vkid-android-sdk/tree/master/sample/oldsdk/"
    click Docs "https://github.com/vkcom/vkid-android-sdk/tree/master/docs/"
    click Scripts "https://github.com/vkcom/vkid-android-sdk/tree/master/scripts/"

    %% Styles
    classDef build fill:#d3d3d3,stroke:#666,stroke-width:1px
    classDef core fill:#add8e6,stroke:#666,stroke-width:1px
    classDef feature fill:#90ee90,stroke:#666,stroke-width:1px
    classDef external fill:#ffa500,stroke:#666,stroke-width:1px
    classDef app fill:#dda0dd,stroke:#666,stroke-width:1px
```
