# manuelpacheco108/mercado-libree architecture

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

- Interactive diagram: https://gitdiagram.com/manuelpacheco108/mercado-libree
- Repository: https://github.com/manuelpacheco108/mercado-libree

## Overview

##### Project Type and Purpose
- This is a React Native cross-platform mobile client (iOS + Android).
- It provides browsing, searching, and purchasing features for a MercadoLibre-like marketplace.
- It uses React Navigation (Stack + Drawer), Context API for state, local data modules, and calls out to external REST APIs.

##### Main Components
a. Presentation Layer (JS)
– Screens (Home, Category, ProductDetail, Cart, Profile, Login, Register, etc.)
– Reusable Components (Cards, Buttons, NavBar, DrawerNavigation)
– Styles (globalStyles, per-component style modules)
b. Navigation Layer
– Stack Navigator
– Drawer Navigator
– gesture-handler and reanimated plugins
c. State/Business Logic Layer
– React Context Providers (AppDataContext, UserContext)
– Local “database” module (src/bd/Products.js) or AsyncStorage
d. Data Layer
– Remote REST API (MercadoLibre endpoints)
– Network module (fetch/axios calls from context or directly in screens)
e. Native Runtime & Build
– JavaScript bundle (Metro bundler)
– React Native bridge
– Android (Gradle project, MainActivity.kt, AndroidManifest.xml)
– iOS (Xcode project, AppDelegate.mm, Info.plist)

##### Relationships & Data Flows
- User interacts with a Screen → dispatches an action into Context → Context reads/writes local data or invokes network fetch → updates Context state → Screen re-renders → if it’s a purchase, Context triggers API call to payment endpoint.
- Navigation events flow from UI components to React Navigation stacks/drawers.
- JS code runs in Metro-served JS runtime, bridged to native modules (gesture-handler, SafeArea, reanimated).
- Native projects wrap the JS bundle and expose modules to JS via the React Native Bridge.

##### Architectural Patterns & Design Principles
- Component-based UI (React components + hooks)
- Context API for shared state (avoiding prop drilling)
- Modular folder structure (bd, components, context, navigation, screens, styles)
- Declarative navigation (Stack/Drawer)
- Separation of concerns: UI vs State vs Data vs Native runtime

##### Final Checklist
– Callouts for critical libraries and config files.
– Native platform boundaries clearly drawn around JS runtime.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App"
        subgraph "Presentation Layer"
            Screens["Screens"]:::jsmodule
            Components["Reusable Components"]:::jsmodule
            Styles["Styles"]:::jsmodule
        end
        subgraph "Navigation Layer"
            StackNav["Stack Navigator"]:::jsmodule
            DrawerNav["Drawer Navigator"]:::jsmodule
            GestureJS["gesture-handler.js"]:::jsmodule
            GestureNative["gesture-handler.native.js"]:::jsmodule
        end
        subgraph "State/Business Logic Layer"
            AppData["AppDataContext"]:::jsmodule
            UserCtx["UserContext"]:::jsmodule
            LocalDB["Local Data Module"]:::storage
        end
    end

    JSRuntime["JS Runtime / Metro Bundler"]:::jsmodule
    Babel["Babel Config (Reanimated)"]:::config
    DB["Products.js"]:::storage
    API["MercadoLibre REST API"]:::cloud

    subgraph "Android"
        MainAct["MainActivity.kt"]:::native
        MainApp["MainApplication.kt"]:::native
        BuildGradle["build.gradle"]:::config
        SettingsGradle["settings.gradle"]:::config
    end

    subgraph "iOS"
        AppDelMM["AppDelegate.mm"]:::native
        AppDelH["AppDelegate.h"]:::native
        XcodeProj["MercadoLibree.xcodeproj"]:::native
        InfoPlist["Info.plist"]:::config
        Podfile["Podfile"]:::config
    end

    %% Data Flows
    Screens -->|navigate| StackNav
    StackNav -->|opens| DrawerNav
    Components -->|used in| Screens
    Styles -->|applied to| Screens
    Screens -->|dispatch| AppData
    Screens -->|dispatch| UserCtx
    StackNav -->|dispatch| AppData
    DrawerNav -->|dispatch| AppData
    AppData -->|reads/writes| LocalDB
    AppData -->|calls| API
    JSRuntime -->|serves bundle to| GestureJS
    JSRuntime -->|serves bundle to| GestureNative
    Babel -->|plugins into| JSRuntime
    JSRuntime -->|bridges to| MainAct
    JSRuntime -->|bridges to| AppDelMM
    MainAct -->|part of| MainApp
    AppDelMM -->|part of| AppDelH

    %% Local Data Module mapping
    LocalDB -->|alias of| DB

    %% Click Events
    click Screens "https://github.com/manuelpacheco108/mercado-libree/tree/main/src/screens/"
    click Components "https://github.com/manuelpacheco108/mercado-libree/tree/main/src/components/"
    click Styles "https://github.com/manuelpacheco108/mercado-libree/tree/main/src/styles/"
    click StackNav "https://github.com/manuelpacheco108/mercado-libree/blob/main/src/navigation/MainStack.js"
    click DrawerNav "https://github.com/manuelpacheco108/mercado-libree/blob/main/src/navigation/HomeDrawer.js"
    click GestureJS "https://github.com/manuelpacheco108/mercado-libree/blob/main/gesture-handler.js"
    click GestureNative "https://github.com/manuelpacheco108/mercado-libree/blob/main/gesture-handler.native.js"
    click AppData "https://github.com/manuelpacheco108/mercado-libree/blob/main/src/context/AppDataContext.js"
    click UserCtx "https://github.com/manuelpacheco108/mercado-libree/blob/main/src/context/UserContext.js"
    click LocalDB "https://github.com/manuelpacheco108/mercado-libree/blob/main/src/bd/Products.js"
    click JSRuntime "https://github.com/manuelpacheco108/mercado-libree/blob/main/index.js"
    click Babel "https://github.com/manuelpacheco108/mercado-libree/blob/main/babel.config.js"
    click MainAct "https://github.com/manuelpacheco108/mercado-libree/blob/main/android/app/src/main/java/com/mercadolibree/MainActivity.kt"
    click MainApp "https://github.com/manuelpacheco108/mercado-libree/blob/main/android/app/src/main/java/com/mercadolibree/MainApplication.kt"
    click BuildGradle "https://github.com/manuelpacheco108/mercado-libree/blob/main/android/app/build.gradle"
    click SettingsGradle "https://github.com/manuelpacheco108/mercado-libree/blob/main/android/settings.gradle"
    click AppDelMM "https://github.com/manuelpacheco108/mercado-libree/blob/main/ios/MercadoLibree/AppDelegate.mm"
    click AppDelH "https://github.com/manuelpacheco108/mercado-libree/blob/main/ios/MercadoLibree/AppDelegate.h"
    click XcodeProj "https://github.com/manuelpacheco108/mercado-libree/tree/main/ios/MercadoLibree.xcodeproj/"
    click InfoPlist "https://github.com/manuelpacheco108/mercado-libree/blob/main/ios/MercadoLibree/Info.plist"
    click Podfile "https://github.com/manuelpacheco108/mercado-libree/tree/main/ios/Podfile"

    %% Styles
    classDef jsmodule fill:#BBDEFB,stroke:#1976D2,color:#0D47A1;
    classDef storage fill:#C8E6C9,stroke:#388E3C,color:#1B5E20;
    classDef cloud fill:#E0E0E0,stroke:#9E9E9E,color:#616161;
    classDef native fill:#FFE0B2,stroke:#F57C00,color:#E65100;
    classDef config fill:#FFF9C4,stroke:#FBC02D,color:#F57F17;
```
