# phanthanhbach/food-ordering-app architecture

> Architecture diagram of the GitHub repository phanthanhbach/food-ordering-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phanthanhbach/food-ordering-app
- Repository: https://github.com/phanthanhbach/food-ordering-app

## Overview

##### Project type and purpose
- This is a React Native mobile application (“Food-Ordering-App”) for ordering food.
- It targets iOS and Android (app.json, babel.config.js) and leverages Firebase (firebase.js) for backend services (authentication, database, storage).

##### File structure
- Top level files:
- App.js – root component
- navigation.js – app navigation configuration
- firebase.js – Firebase SDK initialization & wrappers
- src/components/ – reusable UI components (Header, BottomTab, HomeScreen subcomponents)
- src/screens/ – feature screens (SignIn, SignUp, Home, Menu, FoodDetail, Profile, Voucher, etc.)
- No custom backend code; Firebase acts as BaaS.

##### Key insights from README
- Course project for “Mobile Application Development.”

##### Main components
a. Mobile Client (React Native App)
- Presentation layer
– Screens (SignIn, SignUp, Home, Menu, FoodDetail, Profile, etc.)
– Reusable Components (Header, BottomTab, AboutUs, Offers, Slider, etc.)
- Navigation layer
– Stack & Tab navigators (defined in navigation.js)
- Service layer
– Firebase SDK wrapper (firebase.js)
b. Backend services (Firebase)
- Firebase Authentication
- Cloud Firestore (or Realtime Database) for menu items, orders, vouchers
- (Optional) Firebase Cloud Functions for order processing
c. External Dependencies

##### Relationships & interactions
- UI Screens ←→ Navigation
- UI Screens → firebase.js service calls → Firebase Auth / Firestore / Storage
- Asynchronous data flow: fetch menu data → render Menu screen; submit order → write to Firestore
- Real-time updates (if used) flow from Firestore → client listeners → UI

##### Architectural patterns & design principles
- Layered architecture (Presentation / Navigation / Services / Data)
- Component-based UI (React Native best practice)
- BaaS integration for rapid backend setup
- Separation of concerns: UI logic in screens & components, data logic in firebase.js

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% React Native App Container
    subgraph "React Native App"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer" 
            direction TB

            %% Screens
            subgraph "Screens" 
                direction TB
                subgraph "Authentication"
                    direction TB
                    Splash["Splash Screen"]:::ui
                    SignIn["SignIn Screen"]:::ui
                    SignUp["SignUp Screen"]:::ui
                    ForgotPW["Forgot Password Screen"]:::ui
                    ChangePW["Change Password Screen"]:::ui
                end
                subgraph "Main Features"
                    direction TB
                    Home["Home Screen"]:::ui
                    Menu["Menu Screen"]:::ui
                    FoodDetail["Food Detail Screen"]:::ui
                    Profile["Profile Screen"]:::ui
                    Voucher["Voucher Screen"]:::ui
                    Information["Information Screen"]:::ui
                end
            end

            %% Reusable Components
            subgraph "Reusable UI Components"
                direction TB
                Header["Header Component"]:::ui
                BottomTab["BottomTab Navigator UI"]:::ui
                subgraph "Home Subcomponents"
                    direction TB
                    AboutUs["AboutUs Component"]:::ui
                    Founder["Founder Component"]:::ui
                    Offers["Offers Slider Component"]:::ui
                    Slider["Image Slider Component"]:::ui
                end
            end
        end

        %% Navigation Layer
        subgraph "Navigation Layer"
            direction TB
            Navigation["Stack & Tab Navigators"]:::nav
        end

        %% Service Layer
        subgraph "Service Layer"
            direction TB
            FirebaseJS["Firebase Service Wrapper (firebase.js)"]:::service
        end
    end

    %% Firebase Cloud Services
    subgraph "Firebase Services" 
        direction TB
        Auth["Authentication"]:::external
        Firestore["Cloud Firestore"]:::external
        Storage["Cloud Storage"]:::external
        Functions["Cloud Functions"]:::external
    end

    %% Navigation Flow
    Splash -->|navigates to| SignIn
    SignIn -->|on success| Home
    Home -->|select item| Menu
    Menu -->|view details| FoodDetail

    %% UI to Service Calls
    SignIn -->|calls| FirebaseJS
    Home -->|fetch data| FirebaseJS
    Menu -->|fetch menu| FirebaseJS
    FoodDetail -->|load details| FirebaseJS

    %% Service to Firebase
    FirebaseJS -->|auth ops| Auth
    FirebaseJS -->|read/write| Firestore
    FirebaseJS -->|upload/download| Storage
    FirebaseJS -->|cloud functions| Functions

    %% Firebase responses
    Auth -->|response| FirebaseJS
    Firestore -->|data| FirebaseJS
    Storage -->|data| FirebaseJS
    Functions -->|result| FirebaseJS

    %% Click Events for component mapping
    click App.js "https://github.com/phanthanhbach/food-ordering-app/blob/master/App.js"
    click Navigation "https://github.com/phanthanhbach/food-ordering-app/blob/master/navigation.js"
    click FirebaseJS "https://github.com/phanthanhbach/food-ordering-app/blob/master/firebase.js"
    click Splash "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Splash.js"
    click SignIn "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/SignIn.js"
    click SignUp "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/SignUp.js"
    click ForgotPW "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/ForgotPassword.js"
    click ChangePW "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/ChangePW.js"
    click Home "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Home.js"
    click Menu "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Menu.js"
    click FoodDetail "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/FoodDetail.js"
    click Profile "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Profile.js"
    click Voucher "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Voucher.js"
    click Information "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/screens/Information.js"
    click Header "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/Header.js"
    click BottomTab "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/BottomTab.js"
    click AboutUs "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/HomeScreen/AboutUs.js"
    click Founder "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/HomeScreen/Founder.js"
    click Offers "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/HomeScreen/Offers.js"
    click Slider "https://github.com/phanthanhbach/food-ordering-app/blob/master/src/components/HomeScreen/Slider.js"
    click assets "https://github.com/phanthanhbach/food-ordering-app/tree/master/assets/"
    click app.json "https://github.com/phanthanhbach/food-ordering-app/blob/master/app.json"
    click babel.config.js "https://github.com/phanthanhbach/food-ordering-app/blob/master/babel.config.js"
    click package.json "https://github.com/phanthanhbach/food-ordering-app/blob/master/package.json"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#004080,stroke-width:1px
    classDef nav fill:#E8D0FF,stroke:#800080,stroke-width:1px
    classDef service fill:#D0FFD0,stroke:#008000,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#E65100,stroke-width:1px
```
