# eng-muhamad-hasan/fruit_shop architecture

> Architecture diagram of the GitHub repository eng-muhamad-hasan/fruit_shop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eng-muhamad-hasan/fruit_shop
- Repository: https://github.com/eng-muhamad-hasan/fruit_shop

## Overview

Fruit Shop is a Flutter fruit-shopping app. Its main user journey is sign-in, product discovery, cart management, then address/shipping/payment checkout and order handling. Separate branches provide an AI shopping assistant and profile preferences; Firebase-backed authentication and data services support app features. The README also describes admin management, favorites, and Supabase Storage, but the tree provides no dedicated admin or storage implementation, so those capabilities are not expanded into speculative flows. Dart feature implementations were not sampled, so arrows reflect documented responsibilities and named boundaries rather than verified method calls.

Main entry points: [`lib/feature/home/presentation`](https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/home/presentation) (Home and profile), [`lib/feature/checkout/presentation/cubit/order/order_cubit.dart`](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/checkout/presentation/cubit/order/order_cubit.dart) (Checkout flow), [`lib/core/services/firebase/firebase_firestore_service.dart`](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_firestore_service.dart) (Firestore service), [`lib/main.dart`](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/main.dart) (Flutter app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App entry"]
  node_entry["Flutter app<br/>[main.dart]"]
  node_routes["Route selection"]
end

subgraph group_shopping["Shopping"]
  node_home_ui["Home and profile"]
  node_products["Product discovery"]
  node_cart["Cart management<br/>[cart_cubit.dart]"]
  node_checkout["Checkout flow<br/>[order_cubit.dart]"]
end

subgraph group_account["Account"]
  node_auth_ui["Sign in / sign up"]
  node_auth_repo["Authentication data"]
  node_preferences["Language and theme"]
end

subgraph group_assistant["Smart assistant"]
  node_assistant_ui["AI chat"]
  node_assistant_state["Chat state<br/>[ai_chat_cubit.dart]"]
end

subgraph group_platform["Services"]
  node_auth_service["Firebase auth"]
  node_product_repo["Product repository"]
  node_database["Firestore service"]
  node_orders["Order repository"]
  node_paypal["PayPal integration"]
  node_generative_ai{{"Google Generative AI"}}
  node_notifications["Cloud messaging"]
end

node_shopper(("Shopper"))
node_firebase{{"Firebase"}}
node_catalog_store[("Product data")]
node_payment_provider{{"Payment provider"}}

node_shopper -->|"opens app"| node_entry
node_entry -->|"selects routes"| node_routes
node_shopper -->|"signs in"| node_auth_ui
node_auth_ui -->|"requests auth"| node_auth_repo
node_auth_repo -->|"uses auth"| node_auth_service
node_auth_service -->|"authenticates"| node_firebase
node_shopper -->|"browses"| node_home_ui
node_home_ui -->|"opens catalog"| node_products
node_products -->|"loads products"| node_product_repo
node_product_repo -->|"accesses data"| node_database
node_database -->|"reads catalog"| node_catalog_store
node_shopper -->|"manages cart"| node_cart
node_shopper -->|"starts checkout"| node_checkout
node_checkout -.->|"initiates payment"| node_paypal
node_paypal -.->|"processes payment"| node_payment_provider
node_checkout -->|"submits order"| node_orders
node_orders -->|"persists orders"| node_database
node_shopper -->|"asks assistant"| node_assistant_ui
node_assistant_ui -->|"sends messages"| node_assistant_state
node_assistant_state -.->|"requests suggestions"| node_generative_ai
node_home_ui -->|"changes settings"| node_preferences
node_notifications -->|"uses messaging"| node_firebase

click node_entry "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/main.dart"
click node_routes "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/functions/on_generate_routes.dart"
click node_auth_ui "https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/auth/presentation"
click node_auth_repo "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/auth/data/repos/auth_repo_impl.dart"
click node_auth_service "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_auth_service.dart"
click node_home_ui "https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/home/presentation"
click node_products "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/home/presentation/cubit/products_cubit/products_cubit.dart"
click node_product_repo "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/repos/products_repo/products_repo_impl.dart"
click node_database "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_firestore_service.dart"
click node_cart "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/home/presentation/cubit/cart/cart_cubit.dart"
click node_checkout "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/checkout/presentation/cubit/order/order_cubit.dart"
click node_orders "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/repos/orders_repo/orders_repo_impl.dart"
click node_paypal "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/paypal_service.dart"
click node_assistant_ui "https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/ai_chat/presentation"
click node_assistant_state "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/ai_chat/presentation/cubit/ai_chat/ai_chat_cubit.dart"
click node_notifications "https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_cloud_messaging_service.dart"
click node_preferences "https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/home/presentation/cubit/profile-cubit"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_routes toneBlue
class node_home_ui,node_products,node_cart,node_checkout,node_catalog_store toneAmber
class node_auth_ui,node_auth_repo,node_preferences toneMint
class node_assistant_ui,node_assistant_state toneRose
class node_auth_service,node_product_repo,node_database,node_orders,node_paypal,node_generative_ai,node_notifications,node_shopper,node_firebase,node_payment_provider toneIndigo
```

## Components

### App entry

- [Flutter app](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/main.dart): `lib/main.dart`
- [Route selection](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/functions/on_generate_routes.dart): `lib/core/functions/on_generate_routes.dart`

### Shopping

- [Home and profile](https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/home/presentation): `lib/feature/home/presentation`
- [Product discovery](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/home/presentation/cubit/products_cubit/products_cubit.dart): `lib/feature/home/presentation/cubit/products_cubit/products_cubit.dart`
- [Cart management](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/home/presentation/cubit/cart/cart_cubit.dart): `lib/feature/home/presentation/cubit/cart/cart_cubit.dart`
- [Checkout flow](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/checkout/presentation/cubit/order/order_cubit.dart): `lib/feature/checkout/presentation/cubit/order/order_cubit.dart`

### Account

- [Sign in / sign up](https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/auth/presentation): `lib/feature/auth/presentation`
- [Authentication data](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/auth/data/repos/auth_repo_impl.dart): `lib/feature/auth/data/repos/auth_repo_impl.dart`
- [Language and theme](https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/home/presentation/cubit/profile-cubit): `lib/feature/home/presentation/cubit/profile-cubit`

### Smart assistant

- [AI chat](https://github.com/eng-muhamad-hasan/fruit_shop/tree/main/lib/feature/ai_chat/presentation): `lib/feature/ai_chat/presentation`
- [Chat state](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/feature/ai_chat/presentation/cubit/ai_chat/ai_chat_cubit.dart): `lib/feature/ai_chat/presentation/cubit/ai_chat/ai_chat_cubit.dart`

### Services

- [Firebase auth](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_auth_service.dart): `lib/core/services/firebase/firebase_auth_service.dart`
- [Product repository](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/repos/products_repo/products_repo_impl.dart): `lib/core/repos/products_repo/products_repo_impl.dart`
- [Firestore service](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_firestore_service.dart): `lib/core/services/firebase/firebase_firestore_service.dart`
- [Order repository](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/repos/orders_repo/orders_repo_impl.dart): `lib/core/repos/orders_repo/orders_repo_impl.dart`
- [PayPal integration](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/paypal_service.dart): `lib/core/services/paypal_service.dart`
- **Google Generative AI**
- [Cloud messaging](https://github.com/eng-muhamad-hasan/fruit_shop/blob/main/lib/core/services/firebase/firebase_cloud_messaging_service.dart): `lib/core/services/firebase/firebase_cloud_messaging_service.dart`

### Other components

- **Shopper**
- **Firebase**
- **Product data**
- **Payment provider**

## Connections

- Shopper → Flutter app: opens app
- Flutter app → Route selection: selects routes
- Shopper → Sign in / sign up: signs in
- Sign in / sign up → Authentication data: requests auth
- Authentication data → Firebase auth: uses auth
- Firebase auth → Firebase: authenticates
- Shopper → Home and profile: browses
- Home and profile → Product discovery: opens catalog
- Product discovery → Product repository: loads products
- Product repository → Firestore service: accesses data
- Firestore service → Product data: reads catalog
- Shopper → Cart management: manages cart
- Shopper → Checkout flow: starts checkout
- Checkout flow → PayPal integration: initiates payment
- PayPal integration → Payment provider: processes payment
- Checkout flow → Order repository: submits order
- Order repository → Firestore service: persists orders
- Shopper → AI chat: asks assistant
- AI chat → Chat state: sends messages
- Chat state → Google Generative AI: requests suggestions
- Home and profile → Language and theme: changes settings
- Cloud messaging → Firebase: uses messaging
