# zidouzi/reverse-image-search architecture

> Architecture diagram of the GitHub repository zidouzi/reverse-image-search, 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/zidouzi/reverse-image-search
- Repository: https://github.com/zidouzi/reverse-image-search

## Overview

##### Main Components
- User Interface Layer: The UI is primarily composed of multiple Activities (Ascii2dActivity, GoogleLensActivity, IQDBActivity, SauceNaoActivity, TraceMoeActivity, YandexActivity). This layer is responsible for receiving the shared image or URL and displaying the results to the user.
- Business/Controller Layer: Although there might not be an explicit separate business layer, note that the Activities along with utility classes (e.g., files in zdz/revimg/utils) implement the logic for handling the shared input, selecting the target server, composing the HTTP requests, and processing responses.
- Networking/Integration Components: These components are implicit in how the application connects with external reverse image search services. Even if the network logic is embedded within Activity methods or utility helpers, it is important to represent the interaction with external APIs (SauceNao, Ascii2d, etc.).
- Android System / Platform Layer: Represent the role of system components (like the Android OS, permissions declared in AndroidManifest.xml, and the intent framework used for receiving shared content).
- Build and Deployment Pipeline: Not part of the runtime architecture, but include a note about the CI/CD workflows found in the .github/workflows directory (for Android Release) as well as the Gradle build configuration that compiles and packages the app.

##### Relationships and Data Flow
- Start at the user level – where a user shares an image or URL to the app.
- The shared data enters through an Android intent and is received by one of the entry point Activities.
- The Activity then routes the image/URL to the relevant business logic or utility methods for processing.
- The response from the external server flows back into the app and is rendered on the UI.

##### Important Architectural Patterns and Design Principles
- Modularization: Each reverse search service is encapsulated in its own Activity (and possibly corresponding helper classes), showing a modular design.
- Separation of Concerns: There is a clear division between UI handling (activities and resources), business logic (routing and processing utilities), and external service integration (network calls to external APIs).
- Utilization of Android’s Intent system to integrate with the broader Android ecosystem.
- Standard Android idioms (Gradle build configuration, resource management) are used to support the mobile app design.

##### Relevant Technologies and Frameworks
- Android SDK: The primary framework for building the app.
- Kotlin (as indicated by the *.gradle.kts build scripts and Kotlin source files).
- Gradle: For building and dependency management.
- GitHub Actions: For CI/CD workflows (android-release.yml).
- External REST APIs corresponding to each reverse image search server.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User Shared Image/URL"]:::user
    AOS["Android Platform (Intent Receiving)"]:::platform
    U -->|"intent"| AOS

    subgraph "User Interface (Activities)"
        A1["Ascii2dActivity"]:::ui
        A2["GoogleLensActivity"]:::ui
        A3["IqdbActivity"]:::ui
        A4["SauceNaoActivity"]:::ui
        A5["TraceMoeActivity"]:::ui
        A6["YandexActivity"]:::ui
    end

    AOS -->|"launches"| A1
    AOS -->|"launches"| A2
    AOS -->|"launches"| A3
    AOS -->|"launches"| A4
    AOS -->|"launches"| A5
    AOS -->|"launches"| A6

    Bi["Business Logic / Utils"]:::bl
    A1 -->|"processes"| Bi
    A2 -->|"processes"| Bi
    A3 -->|"processes"| Bi
    A4 -->|"processes"| Bi
    A5 -->|"processes"| Bi
    A6 -->|"processes"| Bi

    subgraph "External Reverse Image Search Services"
        S1["SauceNao"]:::external
        S2["Ascii2d"]:::external
        S3["GoogleLens"]:::external
        S4["TraceMoe"]:::external
        S5["IQDB"]:::external
        S6["Yandex"]:::external
    end

    Bi -->|"API-request"| S1
    Bi -->|"API-request"| S2
    Bi -->|"API-request"| S3
    Bi -->|"API-request"| S4
    Bi -->|"API-request"| S5
    Bi -->|"API-request"| S6

    S1 -->|"API-response"| Bi
    S2 -->|"API-response"| Bi
    S3 -->|"API-response"| Bi
    S4 -->|"API-response"| Bi
    S5 -->|"API-response"| Bi
    S6 -->|"API-response"| Bi

    Bi -->|"renders_result"| A1
    Bi -->|"renders_result"| A2
    Bi -->|"renders_result"| A3
    Bi -->|"renders_result"| A4
    Bi -->|"renders_result"| A5
    Bi -->|"renders_result"| A6

    BP["Build & Deployment Pipeline\n(Gradle & GitHub Actions)"]:::build
    BP -->|"builds"| AOS

    click A1 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/Ascii2dActivity.kt"
    click A2 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/GoogleLensActivity.kt"
    click A3 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/IqdbActivity.kt"
    click A4 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/SauceNaoActivity.kt"
    click A5 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/TraceMoeActivity.kt"
    click A6 "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/java/zdz/revimg/YandexActivity.kt"
    click Bi "https://github.com/zidouzi/reverse-image-search/tree/master/app/src/main/java/zdz/revimg/utils"
    click AOS "https://github.com/zidouzi/reverse-image-search/blob/master/app/src/main/AndroidManifest.xml"
    click BP "https://github.com/zidouzi/reverse-image-search/blob/master/app/build.gradle.kts"
    click BP "https://github.com/zidouzi/reverse-image-search/blob/master/settings.gradle.kts"
    click BP "https://github.com/zidouzi/reverse-image-search/blob/master/.github/workflows/android-release.yml"

    classDef user fill:#cfc,stroke:#333,stroke-width:2px;
    classDef platform fill:#fcc,stroke:#333,stroke-width:2px;
    classDef ui fill:#bbf,stroke:#333,stroke-width:2px;
    classDef bl fill:#afa,stroke:#333,stroke-width:2px;
    classDef external fill:#ffd,stroke:#333,stroke-width:2px;
    classDef build fill:#cdf,stroke:#333,stroke-width:2px;
```
