# jve386/prova-tecnica-frontend_flutter architecture

> Architecture diagram of the GitHub repository jve386/prova-tecnica-frontend_flutter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jve386/prova-tecnica-frontend_flutter
- Repository: https://github.com/jve386/prova-tecnica-frontend_flutter

## Overview

- A multi-platform Flutter project (with folders for Android, iOS, Linux, macOS, Windows, and Web), intended to run across various devices.
- A clear separation of concerns following Clean Code and SOLID principles—dividing app functionality into layers (Presentation, Domain, and Data).
- The use of Provider for state management, ensuring that UI components (widgets and pages) remain decoupled from business logic.
- Integration with an external REST API to retrieve data, where HTTP calls are managed within a dedicated API Service.

##### Main Components
a. User Interface (UI) Layer:
- Widgets, pages, and other visual components located in the “lib/features/nonna_app/presentation” directory.
- Screens include Login, Product Catalog, Checkout, Profile pages, etc.
b. State Management Layer:
- The Provider-based modules (e.g., “lib/features/nonna_app/presentation/providers/product_providers.dart”) that handle dependency injection, global state, and updating the UI based on data changes.
c. Business Logic / Domain Layer:
- Domain entities and use-case logic found in “lib/features/nonna_app/domain/entities” which encapsulate core business rules.
d. Data Layer:
- Consists of models (in “lib/features/nonna_app/data/models”) for data representation and services (like “lib/features/nonna_app/data/services/api_service.dart”) that manage API interactions.
e. External Services:
- The REST API integration (HTTP calls) that provides external data combined with the Provider’s role in updating and distributing this state.
f. Platform-Specific Integration:
- Native code and assets provided in directories such as “android”, “ios”, “linux”, “macos”, “windows”, and “web” which support Flutter’s multi-platform capabilities.

##### Relationships and Data Flow
- These screens invoke actions on the Provider (state management) layer.
- The Provider acts as an intermediary: it handles business logic by interacting with the domain layer and fetches data via the API service in the data layer.
- The API Service makes network calls (HTTP GET) to the external REST API and returns JSON data.
- On data retrieval, the Provider updates the state, which in turn triggers UI updates.
- To note dependency injections (facilitated by Provider) that maintain low coupling between components.

##### Architectural Patterns and Design Principles
- Clean Code / SOLID architectural style and separation of concerns:
– UI for presentation,
– Provider handling state and dependency injection,
– Domain entities encapsulating business logic,
– Data models and services for API interactions.
- Optionally, use annotations or notes indicating how the Provider pattern ensures reactivity in Flutter.

##### Detail and Modularity

Overall, capture all layers, dependencies, and flows succinctly—making sure that even someone new to the project can quickly understand the system’s overall design and its interactions.

## Diagram (Mermaid)

```mermaid
graph TB
    %% UI Layer
    subgraph "UI Layer"
        UI["Flutter Widgets & Pages"]
    end

    %% State Management
    subgraph "State Management"
        Provider["Provider (State/DI)"]
    end

    %% Business Logic / Domain Layer
    subgraph "Business Logic"
        Domain["Domain Entities (Business Logic)"]
    end

    %% Data Layer
    subgraph "Data Layer"
        Models["Data Models"]
        API["API Service (http.get)"]
    end

    %% External Services
    External["External REST API"]

    %% Platform-Specific Implementations
    subgraph "Platform-Specific Implementations"
        Android["Android"]
        iOS["iOS"]
        Linux["Linux"]
        macOS["macOS"]
        Windows["Windows"]
        Web["Web"]
    end

    %% Data Flow Connections
    UI -->|"triggers"| Provider
    Provider -->|"calls_logic"| Domain
    Provider -->|"fetches_data"| API
    API -->|"http.get"| External
    API -->|"maps_data"| Models
    Provider -->|"updates_UI"| UI

    %% Platform Connections (UI runs on native platforms)
    UI -->|"runs_on"| Android
    UI -->|"runs_on"| iOS
    UI -->|"runs_on"| Linux
    UI -->|"runs_on"| macOS
    UI -->|"runs_on"| Windows
    UI -->|"runs_on"| Web

    %% Click Events
    click UI "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/lib/features/nonna_app/presentation"
    click Provider "https://github.com/jve386/prova-tecnica-frontend_flutter/blob/main/lib/features/nonna_app/presentation/providers/product_providers.dart"
    click Domain "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/lib/features/nonna_app/domain/entities"
    click Models "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/lib/features/nonna_app/data/models"
    click API "https://github.com/jve386/prova-tecnica-frontend_flutter/blob/main/lib/features/nonna_app/data/services/api_service.dart"
    click Android "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/android"
    click iOS "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/ios"
    click Linux "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/linux"
    click macOS "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/macos"
    click Windows "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/windows"
    click Web "https://github.com/jve386/prova-tecnica-frontend_flutter/tree/main/web"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef provider fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef domain fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef data fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef platform fill:#DDA0DD,stroke:#333,stroke-width:2px;

    class UI ui;
    class Provider provider;
    class Domain domain;
    class Models data;
    class API data;
    class External external;
    class Android platform;
    class iOS platform;
    class Linux platform;
    class macOS platform;
    class Windows platform;
    class Web platform;
```
