# arsany-osama/spotta-flutterapp architecture

> Architecture diagram of the GitHub repository arsany-osama/spotta-flutterapp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arsany-osama/spotta-flutterapp
- Repository: https://github.com/arsany-osama/spotta-flutterapp

## Overview

##### Project Type & Purpose
- Mobile full-stack application (Flutter/Dart)
- Purpose: Venue booking + real-time chat between clients and venue owners
- Backend is serverless, using Firebase (Auth + Database) and Open Route Service API

##### File Structure & Layers
- Platform folders:
- android/ and ios/ — native wrappers, Gradle and Xcode projects, platform resources
- Dart code (lib/):
- lib/Frontend — UI pages for clients, owners, shared widgets
- lib/Backend — controllers, models, services
­– controllers: handle UI events, orchestrate services
­– services: interface with Firebase (Auth, Database) and Open Route Service API
­– models: User, Reservation, Venue, ChatMessage, etc.
- lib/main.dart — app entry point, dependency injection, routing
- lib/firebase_options.dart — Firebase configuration

##### README Insights
- Authentication via Firebase Phone Auth & OTP
- Real-time chat (Firebase Realtime DB or Firestore)
- Venue data and reservations in Firebase Database
- Location selection through Open Route Service REST API
- Pure Flutter UI, no custom server

##### Main Components
a. Mobile App (Flutter)
­– UI Layer (Pages/Widgets in lib/Frontend)
­– Controller Layer (lib/Backend/controllers)
­– Service Layer (lib/Backend/services)
­– Data Models (lib/Backend/models)
b. External Services
­– Firebase Authentication
­– Firebase Database (Firestore or Realtime)
­– Open Route Service API
c. Native Platforms
­– Android (Gradle modules, MainActivity.kt)
­– iOS (AppDelegate.swift, Info.plist)

##### Relationships & Data Flows
- UI → Controller: user taps “chat,” controller handles event
- Controller → Service: invokes chat_service or venue_service
- Service ↔ Firebase Auth/DB: authentication, read/write venue data, chat messages
- Service ↔ Open Route Service API: GET/POST for geolocation data
- Platform channels aren’t used here (pure Dart), but show native wrappers as “shells.”

##### Architectural Patterns & Principles
- Layered (Presentation → Controller → Service → External)
- MVC-like separation inside the app
- Serverless/Backend-as-a-Service
- Dependency injection via main.dart

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% App Initialization
    subgraph "App Initialization"
        Main["main.dart"]:::init
        Config["firebase_options.dart"]:::init
        FirebaseJson["firebase.json"]:::init
    end

    %% Mobile Presentation Layer
    subgraph "Mobile Presentation"
        SignIn["SignInPage"]:::frontend
        ClientDash["Client Dashboard"]:::frontend
        VenueDetails["Venue Details Page"]:::frontend
        ViewLocation["View Location Page"]:::frontend
        OwnerDash["Owner Dashboard"]:::frontend
        AddVenue["Add Venue Page"]:::frontend
        OwnerLocation["Owner Location Page"]:::frontend
        ChatScreen["Chat Screen"]:::frontend
        MessageStream["Message Stream Builder"]:::frontend
        Settings["Settings Screen"]:::frontend
    end

    %% App Logic Layer
    subgraph "App Logic"
        AuthCtrl["AuthController"]:::controller
        ChatCtrl["ChatController"]:::controller
        VenueCtrl["VenueController"]:::controller
        ReservationCtrl["ReservationController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        AuthSvc["AuthService"]:::service
        ChatSvc["ChatService"]:::service
        VenueSvc["VenueService"]:::service
    end

    %% Data Models
    subgraph "Data Models"
        UserModel["User Model"]:::model
    end

    %% Backend-as-a-Service
    subgraph "Backend-as-a-Service"
        FirebaseAuth[(Firebase Authentication)]:::datastore
        FirebaseDB[(Firebase Database)]:::datastore
        OpenRoute["Open Route Service API"]:::external
    end

    %% Native Shells
    subgraph "Native Shells"
        Android["Android Shell"]:::native
        iOS["iOS Shell"]:::native
    end

    %% Initialization flows
    Main --> Config
    Main --> AuthCtrl
    Main --> ChatCtrl
    Main --> VenueCtrl
    Main --> ReservationCtrl

    %% UI to Controllers
    SignIn -->|"login(phone,otp)"| AuthCtrl
    ClientDash -->|"fetchVenues()"| VenueCtrl
    VenueDetails -->|"viewVenueDetails()"| VenueCtrl
    ViewLocation -->|"getRoute()"| VenueCtrl
    ChatScreen -->|"openChat()"| ChatCtrl
    MessageStream -->|"streamMessages()"| ChatCtrl
    Settings -.-> AuthCtrl
    OwnerDash -->|"manageVenues()"| VenueCtrl
    AddVenue -->|"createVenue()"| VenueCtrl
    OwnerLocation -->|"setVenueLocation()"| VenueCtrl

    %% Controllers to Services
    AuthCtrl -->|"authenticate()"| AuthSvc
    ChatCtrl -->|"sendMessage()"| ChatSvc
    VenueCtrl -->|"loadVenues()"| VenueSvc
    VenueCtrl -->|"addVenue()"| VenueSvc
    VenueCtrl -->|"getRoute()"| VenueSvc
    ReservationCtrl -->|"reserveVenue()"| VenueSvc

    %% Services to External/DB
    AuthSvc -->|"verifyPhone()"| FirebaseAuth
    AuthSvc -->|"getUser()"| FirebaseDB
    ChatSvc -->|"read/write messages()"| FirebaseDB
    VenueSvc -->|"read/write venues & reservations()"| FirebaseDB
    VenueSvc -->|"GET/POST geolocation()"| OpenRoute

    %% Data Models usage
    AuthSvc --> UserModel
    ChatSvc --> UserModel
    VenueSvc --> UserModel
    ReservationCtrl --> UserModel

    %% Native shells
    Android --> Main
    iOS --> Main

    %% Click Events
    click SignIn "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/views/sign_screen.dart"
    click ClientDash "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/client/client_page.dart"
    click VenueDetails "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/client/venue_details_page.dart"
    click ViewLocation "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/client/view_location_page.dart"
    click OwnerDash "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/owner/owner_page.dart"
    click AddVenue "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/owner/add_venue_page.dart"
    click OwnerLocation "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/owner/Location_Page.dart"
    click ChatScreen "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/shared/chatScreen.dart"
    click MessageStream "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/shared/message_stream_builder.dart"
    click Settings "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Frontend/shared/settings_screen.dart"
    click AuthCtrl "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/controllers/phone_auth_controller.dart"
    click ChatCtrl "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/controllers/chat_controller.dart"
    click VenueCtrl "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/controllers/venue_controller.dart"
    click ReservationCtrl "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/controllers/reservation_controller.dart"
    click AuthSvc "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/services/auth_service.dart"
    click ChatSvc "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/services/chat_service.dart"
    click VenueSvc "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/services/venue_service.dart"
    click UserModel "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/Backend/models/user.dart"
    click Main "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/main.dart"
    click Config "https://github.com/arsany-osama/spotta-flutterapp/blob/master/lib/firebase_options.dart"
    click Android "https://github.com/arsany-osama/spotta-flutterapp/blob/master/android/app/src/main/kotlin/com/example/spotta/MainActivity.kt"
    click iOS "https://github.com/arsany-osama/spotta-flutterapp/blob/master/ios/Runner/AppDelegate.swift"
    click FirebaseJson "https://github.com/arsany-osama/spotta-flutterapp/blob/master/firebase.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#000;
    classDef controller fill:#DFF6DD,stroke:#28A745,color:#000;
    classDef service fill:#FFE8CC,stroke:#FF8C00,color:#000;
    classDef datastore fill:#E8DFFE,stroke:#6F42C1,color:#000;
    classDef external fill:#FFEBE8,stroke:#CB2431,color:#000;
    classDef native fill:#F0F0F0,stroke:#6A737D,color:#000;
    classDef init fill:#FFF5B1,stroke:#D4A200,color:#000;
    classDef model fill:#F5F5F5,stroke:#CCCCCC,color:#000;
```
