# lumec/mercadolibrechallenge architecture

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

- Interactive diagram: https://gitdiagram.com/lumec/mercadolibrechallenge
- Repository: https://github.com/lumec/mercadolibrechallenge

## Overview

##### Project Type & Purpose
- It’s a modular Android application with a clean architecture implementation.
- The app provides a search view (with Jetpack Compose) for product listings and a detailed view for selected items.
- It incorporates MVVM, dependency injection (via Hilt), Retrofit for network calls, and remote logging (Timber + Firebase Crashlytics).

##### Main Components
a. UI/Presentation Layer:
- The “app” module, primarily handling UI views, navigation, and composable elements.
- Within “app”, distinguish components like MainActivity, view models, composable screens (for product list and product details) and navigation setups.
b. Domain Layer:
- The “domain” module, containing business entities (e.g., ProductDetails, ProductPreview) and error handling.
- This is the core part that remains independent of external frameworks.
c. Use Cases/Interactors:
- The “usecases” module which includes use cases like GetProductsUseCase and GetProductDetailsUseCase.
- Represents the application’s business logic, serving as the mediator between the presentation and data layers.
d. Data Layer:
- The “data” module, which handles network/API data sources (e.g., ProductRemoteDataSource) and repository implementations.
e. Supporting Components:
- buildSrc: Contains dependency management and build scripts.
- testShared: Provides shared testing utilities used across unit, integration, and UI tests.
- External services/libraries (Firebase Crashlytics, Timber for logging, and libraries for asynchronous processing like coroutines).

##### Relationships & Interactions
- The UI Layer (app module) communicates with the Use Cases layer. These interactions follow MVVM patterns using view models.
- The Use Cases layer interacts with the Domain layer (to manipulate business entities) and with the Data layer (via repositories) to fetch or update data.
- The Data layer acts as an interface to external services (remote API, image loading via Coil).
- Dependency injection (Hilt) underpins connections between modules, ensuring loose coupling.
- Testing modules (testShared, along with unit and UI tests present in each module’s test directories) are integrated across these layers.
- External libraries and services plug into appropriate components: Retrofit in data, Firebase Crashlytics and Timber in app initialization.

##### Architectural Patterns & Design Principles
- Clean Architecture: Emphasize separation of concerns (presentation, domain, data).
- MVVM: Highlight unidirectional data flow from view models to UI.
- Dependency Injection: Use Hilt to inject dependencies across modules.
- Unit & Instrumentation Testing: Tapping into testShared for shared test utilities across layers.

##### Additional Notes
- On test layers: an auxiliary note on how the testShared module supports end-to-end (unit, integration, UI) testing.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        a["UI Module (app)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        b["Use Cases (usecases)"]:::usecases
    end

    %% Domain Layer
    subgraph "Core Domain"
        c["Domain Module (domain)"]:::domain
    end

    %% Data Access Layer
    subgraph "Data Access"
        d["Data Module (data)"]:::data
    end

    %% Supporting Modules
    subgraph "Supporting Modules"
        e["Build & Dependency (buildSrc)"]:::support
        f["Test Shared Resources (testShared)"]:::support
    end

    %% External Services
    subgraph "External Services"
        g["Retrofit"]:::external
        h["Hilt"]:::external
        i["Coil"]:::external
        j["Firebase Crashlytics"]:::external
        k["Timber"]:::external
    end

    %% Interactions
    a -->|"calls"| b
    b -->|"appliesLogic"| c
    b -->|"requestsData"| d
    d -->|"fetchesDataWith"| g
    d -->|"loadsImagesWith"| i
    a -->|"injectsVia"| h
    b -->|"injectsVia"| h
    a -->|"logsWith"| k
    a -->|"crashReports"| j

    %% Supporting Modules influence (dotted lines for configuration/testing)
    e -.-> a
    e -.-> b
    e -.-> c
    e -.-> d
    f -.-> a
    f -.-> b
    f -.-> c
    f -.-> d

    %% Styles
    classDef presentation fill:#f4cccc,stroke:#d44,stroke-width:2px;
    classDef usecases fill:#c9daf8,stroke:#39f,stroke-width:2px;
    classDef domain fill:#d9ead3,stroke:#6a6,stroke-width:2px;
    classDef data fill:#fff2cc,stroke:#fc0,stroke-width:2px;
    classDef support fill:#ead1dc,stroke:#a64,stroke-width:2px;
    classDef external fill:#d0e0e3,stroke:#333,stroke-width:2px;

    %% Click Events
    click a "https://github.com/lumec/mercadolibrechallenge/tree/main/app/src/main/java/com/lumec/challenge/mercadolibre/ui"
    click c "https://github.com/lumec/mercadolibrechallenge/tree/main/domain/src/main/java/com/lumec/challenge/domain"
    click b "https://github.com/lumec/mercadolibrechallenge/tree/main/usecases/src/main/java/com/lumec/challenge/usecases"
    click d "https://github.com/lumec/mercadolibrechallenge/tree/main/data/src/main/java/com/lumec/challenge/data"
    click e "https://github.com/lumec/mercadolibrechallenge/tree/main/buildSrc/src/main/java/com/lumec/challenge/buildsrc"
    click f "https://github.com/lumec/mercadolibrechallenge/tree/main/testShared/src/main/java/com/lumec/challenge/testshared"
```
