# nguyenduchuy-ndh/quan-ly-nha-hang architecture

> Architecture diagram of the GitHub repository nguyenduchuy-ndh/quan-ly-nha-hang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nguyenduchuy-ndh/quan-ly-nha-hang
- Repository: https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang

## Overview

This project is a Flutter application—designed to run on multiple platforms including Android, iOS, web, and desktop (Linux, macOS, Windows). The key architectural layers are found in the lib folder, and there are clearly delineated platform-specific directories for native configurations and builds.

Step 1: Identify the main components
- Flutter Frontend/UI: The lib/screens directory indicates that the UI is split into several subcomponents (authentication screens, home screens, order screens, etc.). These represent the client-facing elements, responsible for rendering the user experience.
- Services / Business Logic: The lib/services directory contains key services such as auth_service, firestore_service, and order_service. These encapsulate business logic and audience interactions with external resources.
- External Dependencies: The presence of lib/firebase_options.dart and services for Firestore suggest integration with Firebase for authentication, database/storage, or other backend functionalities.

Step 2: Analyze platform-specific structure
- Each platform (android, ios, linux, macos, windows, and web) has its own configuration and build files. While these directories handle platform-specific builds and native layers (like Android’s MainActivity.kt or iOS’ AppDelegate.swift), the core application logic remains within the cross-platform Flutter codebase (lib folder).

Step 3: Architectural Patterns and Design Principles
- Layered/MVC-like Structure: The application follows a separation of concerns pattern. The UI (screens) consumes underlying business logic (services), which in turn uses data models to communicate with external systems (e.g., Firebase).
- Cross-Platform Abstraction: The project has been organized such that platform-specific integrations (iOS/Android, etc.) are kept separate from the main application logic, highlighting a clean architectural separation.

1. Presentation/UI Layer: Illustrate components such as LoginScreen, HomeScreen, OrderScreen, etc. Indicate navigation components like BottomNavigationScreen.
3. Data/Model Layer: Show data models (MenuCategory, MenuItem, Order, OrderItem, Table, UserModel) that represent the internal state. Connect these models to the business logic layer to highlight data flow.
- Additional Elements:
- Incorporate sample data (as seen in lib/data) if relevant to testing or bootstrapping.

- Use clear labels: Make sure each component (e.g., “UI – Home Screen”, “Auth Service”, “Firebase Backend”, “Android Native Layer”) is clearly labeled.
- Rectangles for UI components.
- Ovals for business logic/services.
- Detail Interactions: Capture both the high-level component interactions (UI ⇄ Business Logic ⇄ Data Model ⇄ External Service) as well as any notable design patterns (e.g., observable streams for state management, MVC architecture).

Final Tips:
– Optionally include notes on deployment pipelines if relevant build configurations (like gradle, CMake, and Xcode settings) need to be referenced.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter Application Core with Layers
    subgraph "Flutter Application"
        AppCore("Application Core"):::ui
        subgraph "Presentation/UI Layer"
            UI1("LoginScreen"):::ui
            UI2("HomeScreen"):::ui
            UI3("OrderScreen"):::ui
            UI4("NavigationBar"):::ui
        end
        subgraph "Business Logic/Services Layer"
            S1("AuthService"):::service
            S2("FirestoreService"):::service
            S3("OrderService"):::service
        end
        subgraph "Data/Model Layer"
            M1("MenuCategory"):::model
            M2("MenuItem"):::model
            M3("Order"):::model
            M4("OrderItem"):::model
            M5("Table"):::model
            M6("UserModel"):::model
        end
    end

    %% External System
    F("Firebase Backend"):::external

    %% Platform-specific Native Layers
    A("Android Native Layer"):::native
    I("iOS Native Layer"):::native
    W("Web Native/Configuration Layer"):::native
    L("Linux Desktop Layer"):::native
    M("macOS Desktop Layer"):::native
    Win("Windows Desktop Layer"):::native

    %% Connections within Flutter Application
    UI1 -->|"authentication"| S1
    UI3 -->|"orderPlacement"| S3
    S1 -->|"verify"| F
    S2 -->|"sync"| F
    S1 -->|"usesModel"| M6
    S3 -->|"usesModel"| M3

    %% Platform nodes loading the Flutter Application
    A -->|"loads"| AppCore
    I -->|"loads"| AppCore
    W -->|"loads"| AppCore
    L -->|"loads"| AppCore
    M -->|"loads"| AppCore
    Win -->|"loads"| AppCore

    %% Click Events for Component Mappings
    click UI1 "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/lib/screens"
    click M1 "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/lib/models"
    click S1 "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/lib/services"
    click F "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/blob/main/lib/firebase_options.dart"
    click A "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/android"
    click I "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/ios"
    click W "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/web"
    click L "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/linux"
    click M "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/macos"
    click Win "https://github.com/nguyenduchuy-ndh/quan-ly-nha-hang/tree/main/windows"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef service fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef model fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px,stroke-dasharray: 5,5;
    classDef native fill:#D3D3D3,stroke:#000,stroke-width:2px,stroke-dasharray: 5,5;
```
