# avito-tech/avito-android architecture

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

- Interactive diagram: https://gitdiagram.com/avito-tech/avito-android
- Repository: https://github.com/avito-tech/avito-android

## Overview

##### Primary layers and components
- Build System Infrastructure – at the top-level you have the Gradle build scripts (settings.gradle.kts, build.gradle.kts, gradle folder, etc.). This layer coordinates the entire multi–project structure.
- Build Logic / Plugins – a large portion of the repository is dedicated to custom Gradle plugins and build logic (“build-logic” directories, “build-logic/android”, “build-logic/checks”, “build-logic/dependency-locking”, “build-logic/publication”, etc.). These components provide:
– Dependency resolution and locking
– Code checks (lint, detekt, build checks)
– Publication and version catalog management
- Subprojects – the “subprojects” directory contains multiple modules that are either Android libraries, test modules (e.g. “android-test”, “ui-testing-compose”, “android-lib”), or components related to running and reporting tests.
- CI & Runner Infrastructure – several modules under “ci” and “test-runner” (device-provider, instrumentation runner, report generators, etc.) are responsible for coordinating tests on devices/emulators in CI. They handle:
– Device provisioning and reservation (using local, Kubernetes, or other providers)
– Test execution via instrumented runners, parsing instrumentation outputs, and providing aggregated reports
- Reporting and Metrics – there are several components (report-processor, teamcity-metrics-collector, test-report modules) that collect data from tests and build metrics, as well as generate reports.

##### Relationships
- Gradle Build System (the build scripts and the multi–project structure) at the top that orchestrates the build.
– Device Provider Components: responsible for finding, reserving, and managing devices (e.g. local device provider, Kubernetes devices).
– Test Runner / Instrumentation Runner components that execute tests using these provided devices.
– Communication with external CI systems and metric collectors (TeamCity integration, reports upload).

##### Significant architectural patterns
- The project follows the multi-module Gradle project pattern. Each module is self-contained and built via custom plugins.
- Separation of concerns: Build logic modules encapsulate functionality such as dependency resolution and build checks, allowing subprojects to remain relatively simple.
- Data flow patterns: Test output is parsed (by instrumentation output parsers in the test-runner modules) then aggregated into reports, while device providers and test runners interact via defined APIs.
- Extensibility: The infrastructure is designed to be open and modular so that additional plugins or modules (for new testing frameworks or reporting mechanisms) can be added.
- Use of dependency injection patterns is apparent in some plugins where “factories” and “provider” classes abstract creation of components (e.g., for network clients, logger factories, etc.).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Build Orchestration Layer
    subgraph "Build Orchestration"
        BuildSystem["Gradle Build System Infrastructure"] 
        BuildLogic["Build Logic / Custom Plugins"]
    end

    %% Project Modules Layer
    subgraph "Project Modules"
        Subprojects["Subprojects (Android libraries, tests, runners, etc.)"]
    end

    %% CI & Reporting Layer
    subgraph "CI & Testing Infrastructure"
        CIInfra["CI & Runner Infrastructure"]
        Reporting["Reporting & Metrics Components"]
    end

    %% Relationships
    BuildSystem -->|"orchestrates"| BuildLogic
    BuildLogic -->|"applies_plugins_to"| Subprojects
    Subprojects -->|"executes_tests"| CIInfra
    CIInfra -->|"sends_test_results"| Reporting

    %% Click Events
    click BuildSystem "https://github.com/avito-tech/avito-android/tree/develop/settings.gradle.kts, build.gradle.kts, gradle/"
    click BuildLogic "https://github.com/avito-tech/avito-android/tree/develop/build-logic/"
    click Subprojects "https://github.com/avito-tech/avito-android/tree/develop/subprojects/"
    click CIInfra "https://github.com/avito-tech/avito-android/tree/develop/ci/ and test-runner/"
    click Reporting "https://github.com/avito-tech/avito-android/tree/develop/subprojects/teamcity-metrics-collector/ and assemble/build-metrics/"

    %% Styles
    classDef build fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef ci fill:#FFECB3,stroke:#FFA000,stroke-width:2px;
    classDef report fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;

    class BuildSystem,BuildLogic,Subprojects build;
    class CIInfra ci;
    class Reporting report;
```
