# ahmedlsayed9/deliverzler architecture

> Architecture diagram of the GitHub repository ahmedlsayed9/deliverzler, 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/ahmedlsayed9/deliverzler
- Repository: https://github.com/ahmedlsayed9/deliverzler

## Overview

Based on our analysis of the provided file tree and README, Deliverzler is an open‐source Flutter-based delivery application that is built using Domain-Driven Design and a layered architecture. It incorporates a rich set of features such as Firebase authentication, real-time Firestore data, cloud functions, Google Maps with live tracking, notifications (both local and FCM), and fully cross-platform support (Android, iOS, and macOS). The project further employs the Riverpod framework with code-generation, Flutter Hooks, and functional programming constructs.

##### Main Components
- User Interface / Presentation Layer (Flutter UI):
- Screens (login, home, map view, profile, settings)
- Widgets / Components (custom buttons, dialogs, and responsive widgets)
- Providers managing state (authentication providers, order providers, map providers, etc.)
- Navigation using GoRouter (Navigation 2.0 with nested routing)
- Domain Layer (Business Logic):
- Entities, aggregates, and value objects (e.g., User, Order, Profile Details)
- Domain services (order management, profile service)
- Business rules and validations housed in this layer (as seen in the lib/features/*/domain directories)
- Infrastructure Layer:
- Data sources (remote data sources for Firebase, Google Maps APIs, local storage, etc.)
- Repositories and DTOs (handling data transformation and integration with external services)
- Implementation details (Firebase Auth, Firestore, Firebase Storage, Cloud Functions, and APIs for Google Maps)
- Error handling and shared services (cache, network info, location, notification services)
- External Services:
- Firebase ecosystem (Auth, Firestore, Storage, FCM, Cloud Functions)
- Google Maps Platform (Maps SDK, Directions, Places)
- Other integrated libraries (RxDart, FpDart)

##### Relationships and Interactions
- Presentation components (Flutter Widgets and Providers) interact with the Domain layer to perform business logic.
- The Domain layer calls into the Infrastructure layer for data operations (e.g., fetching orders, updating user profiles).
- External services (Firebase, Google APIs) are connected to the Infrastructure layer.
- Notification services and live location tracking feed data into the UI layer.
- Directional flows:
- From user interactions in the UI to state providers.
- From state providers to domain-level services.
- From domain services to data sources in the infrastructure for persistence or retrieval.

##### Important Architectural Patterns and Technologies
- Domain-Driven Design: Emphasize separation of concerns by clearly delineating Domain, Presentation, and Infrastructure.
- Layered Architecture: Each layer has specific responsibilities and dependencies flow inward (UI → Domain → Infra).
- Riverpod and Flutter Hooks: Show that state management and reactive programming are central to the UI layer.
- Use of Code Generation: Indicate providers and DTOs are largely generated (denoted by *.g.dart and *.freezed.dart) which is part of the technical stack.
- Integration with Firebase and Google Maps: Clearly mark external integrations such as Cloud Functions, FCM, and Google Maps API as part of the system’s ecosystem.

- UI components and state providers.
- Providers and business logic in the domain layer.
- Domain logic and infrastructure repositories/data sources.
- Infrastructure to external services like Firebase and Google Maps.
- Labels and annotations that explain:
- “Authentication Module” connecting Firebase Auth (in Infra) to UI via Domain.
- “Delivery Orders Module” showing real-time order updates using Firestore streams.
- “Map Module” integrating Google Maps APIs with UI widgets for live tracking.
- Non-Flutter native parts (Android, iOS, macos folders) in a side note if necessary—they handle platform-specific setups but follow the same cross-platform business logic.

##### Final Advice to the Principal Software Engineer
- Be methodical: Start by sketching the three layers (Presentation, Domain, Infrastructure) and then add details of each module within these layers.
- Integrations with external services and emphasize reactive state management that ties the whole system together.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Screens"
            UI1["Login Screen"]
            UI2["Splash Screen"]
            UI3["No Internet Screen"]
            UI4["Home Screen"]
            UI5["Map Screen"]
            UI6["Profile Screen"]
            UI7["Settings Screen"]
        end
        subgraph "Providers"
            P1["Auth Providers"]
            P2["Core Providers"]
            P3["Home Providers"]
            P4["Map Providers"]
            P5["Profile Providers"]
        end
        Nav["Navigation (GoRouter)"]
    end

    %% Domain Layer
    subgraph "Domain Layer"
        D1["Auth Domain (User & Email SignIn)"]
        D2["Core Domain (Utilities & Validators)"]
        D3["Home Domain (Orders & Services)"]
        D4["Map Domain (Places & Details)"]
        D5["Profile Domain (Profile Details & Service)"]
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        I1["Auth Infra (Data Sources, Repos, DTOs)"]
        I2["Core Infra (Error Handling, Local Storage, Network, Notifications)"]
        I3["Home Infra (Data Sources, Repos, DTOs)"]
        I4["Map Infra (Data Sources, Repos, DTOs)"]
        I5["Profile Infra (Data Sources, Repos, DTOs)"]
    end

    %% External Services
    subgraph "External Services"
        FES1["Firebase Ecosystem"]
        FES2["Cloud Functions"]
        FES3["Google Maps API"]
        subgraph "Native Platforms"
            NP1["Android"]
            NP2["iOS"]
            NP3["macOS"]
        end
    end

    %% Relationships from Presentation to Domain
    P1 -->|"calls"| D1
    P2 -->|"calls"| D2
    P3 -->|"calls"| D3
    P4 -->|"calls"| D4
    P5 -->|"calls"| D5
    Nav -->|"navigates_to"| UI1
    Nav -->|"navigates_to"| UI2
    Nav -->|"navigates_to"| UI3
    Nav -->|"navigates_to"| UI4
    Nav -->|"navigates_to"| UI5
    Nav -->|"navigates_to"| UI6
    Nav -->|"navigates_to"| UI7

    %% Relationships from Domain to Infrastructure
    D1 -->|"fetches"| I1
    D2 -->|"fetches"| I2
    D3 -->|"fetches"| I3
    D4 -->|"fetches"| I4
    D5 -->|"fetches"| I5

    %% Relationships from Infrastructure to External Services
    I1 -->|"integrates"| FES1
    I2 -->|"integrates"| FES1
    I2 -->|"triggers"| FES2
    I3 -->|"integrates"| FES1
    I4 -->|"integrates"| FES3
    I5 -->|"integrates"| FES1

    %% Click Events for Presentation Layer Screens
    click UI1 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/auth/presentation/screens"
    click UI2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/presentation/screens"
    click UI3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/presentation/screens"
    click UI4 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/home/presentation/screens/home_screen"
    click UI5 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/map/presentation/screens/map_screen"
    click UI6 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/profile/presentation/screens/profile_screen"
    click UI7 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/settings/presentation/screens/settings_screen"

    %% Click Events for Providers
    click P1 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/auth/presentation/providers"
    click P2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/presentation/providers"
    click P3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/home/presentation/providers"
    click P4 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/map/presentation/providers"
    click P5 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/profile/presentation/providers"

    %% Click Event for Navigation (GoRouter)
    click Nav "https://github.com/ahmedlsayed9/deliverzler/blob/master/lib/core/presentation/routing/app_router.dart"

    %% Click Events for Domain Layer
    click D1 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/auth/domain"
    click D2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/domain"
    click D3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/home/domain"
    click D4 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/map/domain"
    click D5 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/profile/domain"

    %% Click Events for Infrastructure Layer
    click I1 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/auth/infrastructure"
    click I2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/infrastructure"
    click I3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/home/infrastructure"
    click I4 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/map/infrastructure"
    click I5 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/features/profile/infrastructure"

    %% Click Events for External Services
    click FES1 "https://github.com/ahmedlsayed9/deliverzler/blob/master/.firebaserc"
    click FES2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/functions/"
    click FES3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/lib/core/infrastructure/network/google_map_api"
    click NP1 "https://github.com/ahmedlsayed9/deliverzler/tree/master/android/"
    click NP2 "https://github.com/ahmedlsayed9/deliverzler/tree/master/ios/"
    click NP3 "https://github.com/ahmedlsayed9/deliverzler/tree/master/macos/"

    %% Styles
    classDef presentation fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef domain fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef infrastructure fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef external fill:#FFCDD2,stroke:#B71C1C,stroke-width:2px;
    classDef native fill:#D1C4E9,stroke:#4A148C,stroke-width:2px;

    %% Assign classes to nodes
    class UI1,UI2,UI3,UI4,UI5,UI6,UI7,Nav,P1,P2,P3,P4,P5 presentation;
    class D1,D2,D3,D4,D5 domain;
    class I1,I2,I3,I4,I5 infrastructure;
    class FES1,FES2,FES3 external;
    class NP1,NP2,NP3 native;
```
