# willpasco/meli-test architecture

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

- Interactive diagram: https://gitdiagram.com/willpasco/meli-test
- Repository: https://github.com/willpasco/meli-test

## Overview

##### Major Components
- App Module: This is the main Android application (located in the “app” folder) that contains the entry point (e.g., MainActivity) and references to global configurations (like the AndroidManifest.xml) along with resources.
- Core Modules: These provide shared functionalities such as:
– Logger (core/logger): Handles log collection and Crashlytics integration.
– Navigation (core/navigation): Divided into API and implementation, providing an abstraction over screen navigation.
– Network (core/network): Also split into API and implementation. Notable here is the native component (cpp code) responsible for managing the NetworkSecurity (access token) integration.
– Style (core/style): Defines design themes, UI components (buttons, headers, etc.) and consistency across the UI.
- Feature Modules: There are at least two major features:
– Details: Contains both an API and its implementation with clear separation between data (remote data sources, repositories), domain (use cases, models, exceptions), and presentation (composable components, viewmodels). It also manages its own navigation within the “details” package.
– Listing: Similar structure to “Details”, with API and implementation layers, managing data sources, repositories, mapping functions, pagination logic, and composable UI components for listing products.

##### Interactions and Relationships
- The App Module serves as the application shell and ties everything together:
– It initializes the application (via AppApplication and MainActivity) and sets up navigation using the core navigation components.
– It integrates with Google services (Crashlytics) using the google-services.json file.
- Core modules are independent libraries that are consumed by both the App Module and feature modules:
– The Core Logger collects and sends logs, which are used by all modules.
– The Core Network layer provides network communication and security (access token management via the C++/JNI native code). The README explains that the NetworkSecurity.cpp file is generated (or provided) via a shell script.
– The Core Navigation layer defines the common navigation contracts (APIs and their implementations) used by feature modules (like Details and Listing) to handle screen transitions.
– The Core Style module ensures UI consistency and component reusability.
- The Feature Modules (Details and Listing) implement their own functional flows while consuming the services of the core modules:
– They have dedicated packages for data, domain, and presentation (following a variant of Clean Architecture) and use dependency injection (“di”) to wire up internal components.
– Their navigation flows integrate with the app-level navigation infrastructure.
- External Services:
– The Firebase Crashlytics integration is used by the Logger.
– There is also an external API integration with Mercado Livre’s services, as indicated by the README, which involves the network access facilitated by the Core Network.

##### Architectural Patterns and Design Principles
- The project leverages modularization to enforce separation of concerns (each module has a clear responsibility).
- Clean architecture is apparent in the way that feature modules (Details and Listing) separate data, domain, and presentation layers.
- Dependency Injection is used for wiring dependencies (the “di” directories in several modules).
- Separation of platform-specific (Android) and cross-cutting infrastructure (core components) is maintained.
- Abstraction layers (APIs vs. Implementations) are used in Core Navigation and Core Network modules, which is beneficial for testing as well as swapping implementations if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% App Module
    subgraph "App Module"
        App["Android App (MainActivity, AppApplication)"]:::app
    end

    %% Core Modules
    subgraph "Core Modules"
        subgraph "Core Logger"
            Logger["Logger Module (CrashlyticsLogTree, LoggerSetup)"]:::core
        end
        subgraph "Core Navigation"
            NavAPI["Navigation API (NavigationController, Navigator)"]:::core
            NavImpl["Navigation Implementation (NavigationControllerImpl, NavigatorImpl)"]:::core
        end
        subgraph "Core Network"
            NetAPI["Network API (NetworkResponseExtensions, NetworkResponse)"]:::core
            NetImpl["Network Implementation (Native Code: NetworkSecurity)"]:::core
            Script["Native Code Config Script"]:::native
        end
        subgraph "Core Style"
            Style["Style Module (PrimaryButton, Header, Themes)"]:::core
        end
    end

    %% Feature Modules
    subgraph "Feature Modules"
        subgraph "Details Feature"
            DetailsAPI["Details API (DetailsDestination, DetailsRoute)"]:::feature
            DetailsImpl["Details Implementation (Data, Domain, Presentation\n(DetailsService, DetailsViewModel, UI composables))"]:::feature
        end
        subgraph "Listing Feature"
            ListingAPI["Listing API (ListingService, AndroidManifest)"]:::feature
            ListingImpl["Listing Implementation (Data, Domain, Presentation\n(ListingRemoteDataSource, ListingViewModel, UI components))"]:::feature
        end
    end

    %% External Services
    subgraph "External Services"
        Crashlytics["Crashlytics (Firebase)"]:::ext
        MercadoLivre["MercadoLivre API"]:::ext
    end

    %% Relationships from App Module to Core Modules
    App -->|"uses"| Logger
    App -->|"uses"| NavAPI
    App -->|"uses"| Style
    App -->|"uses"| NetAPI

    %% Core Navigation: API to Implementation
    NavAPI -->|"implements"| NavImpl

    %% Core Network: API to Implementation and script generation
    NetAPI -->|"implemented_by"| NetImpl
    Script -->|"generates"| NetImpl
    NetImpl -->|"calls"| MercadoLivre

    %% Logger reporting to Crashlytics
    Logger -->|"reports_to"| Crashlytics

    %% App Module integrates Feature Modules
    App -->|"integrates"| DetailsAPI
    App -->|"integrates"| ListingAPI

    %% Details Feature internal flows
    DetailsAPI -->|"used_by"| DetailsImpl
    DetailsImpl -->|"calls"| Logger
    DetailsImpl -->|"calls"| NavAPI
    DetailsImpl -->|"calls"| NetAPI

    %% Listing Feature internal flows
    ListingAPI -->|"used_by"| ListingImpl
    ListingImpl -->|"calls"| Logger
    ListingImpl -->|"calls"| NavAPI
    ListingImpl -->|"calls"| NetAPI

    %% Click Events
    click App "https://github.com/willpasco/meli-test/tree/main/app/src/main/kotlin/com/will/meli"
    click Logger "https://github.com/willpasco/meli-test/tree/main/core/logger"
    click NavAPI "https://github.com/willpasco/meli-test/tree/main/core/navigation/api"
    click NavImpl "https://github.com/willpasco/meli-test/tree/main/core/navigation/implementation"
    click NetAPI "https://github.com/willpasco/meli-test/tree/main/core/network/api"
    click NetImpl "https://github.com/willpasco/meli-test/tree/main/core/network/implementation"
    click Style "https://github.com/willpasco/meli-test/tree/main/core/style"
    click DetailsAPI "https://github.com/willpasco/meli-test/tree/main/details/api"
    click DetailsImpl "https://github.com/willpasco/meli-test/tree/main/details/implementation"
    click ListingAPI "https://github.com/willpasco/meli-test/tree/main/listing/api"
    click ListingImpl "https://github.com/willpasco/meli-test/tree/main/listing/implementation"
    click Script "https://github.com/willpasco/meli-test/blob/main/scripts/ConfigAccessToken.sh"

    %% Styles
    classDef app fill:#ffd700,stroke:#333,stroke-width:2px;
    classDef core fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef feature fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef native fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef ext fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
