# mjaber5/qanoni-app architecture

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

- Interactive diagram: https://gitdiagram.com/mjaber5/qanoni-app
- Repository: https://github.com/mjaber5/qanoni-app

## Overview

##### Project type and purpose
- Qanoni-App is a cross-platform (Android, iOS, Web, Windows, macOS, Linux) mobile application built with Flutter.
- It follows a Clean MVVM architecture: UI → ViewModel (Bloc/Cubit) → Services → Data → External.
- Backend is provided by Firebase (Authentication, Firestore, Cloud Storage) plus a Node.js layer for custom logic (e.g., Cloud Functions).

##### File structure
- Top-level “android/”, “ios/”, “web/”, “windows/”, “macos/”, “linux/” directories: platform-specific Flutter embedder code.
- “lib/”: the main Flutter code organized into:
- core/ – shared services (api_services.dart), utilities, theme, widgets, errors
- features/ – feature modules (authentication, home/contracts, payment, chatbot, notification, profile, splash, theme, languages) each subdivided into data (models/repos), presentation (views, blocs/cubits), etc.
- packages/user_repository – a Dart package encapsulating user-related domain entities and repository interfaces.
- Configuration files (pubspec.yaml, firebase.json, analysis_options.yaml) and test/ for unit/widget tests.

##### README
- Confirms Clean MVVM, Flutter frontend, Firebase backend, Firestore DB, Firebase Auth/Storage, Node.js micro-services.
- Features: electronic contract creation, templates, security, multi-platform.

##### Components
a. Frontend (Flutter App)
- Platform Embedders (Android, iOS, Web, Desktop)
- Flutter Engine
- Presentation Layer: Views (Widgets), ViewModels (Bloc/Cubit)
- core/services/api_services.dart – HTTP / RPC calls abstraction
- packages/user_repository – domain-level repo interface
b. Domain & Data
- Repositories (FirebaseUserRepo, ContractRepo, NotificationRepo, etc.)
- Data Models & Mappers
c. External Services
- Firebase Authentication
- Firestore Database
- Firebase Cloud Storage
- Node.js Cloud Functions / REST API (if present)
d. Third-party SDKs & Plugins
- FlutterFire plugins (auth, firestore, storage)
- Any payment gateway or chat APIs (if used)

##### Relationships & Data Flow
- User taps UI → View (Widget) invokes ViewModel event
- ViewModel calls core/services (ApiServices) or calls Repository interface
- Repository implementation uses Firebase SDK or HTTP to Cloud Functions
- Firebase Auth returns credential → Firestore reads/writes Contract documents → Cloud Storage stores attachments → results bubble back up to ViewModel → UI updates

##### Architectural patterns & design principles
- Clean MVVM: strict separation of concerns
- Feature-based modularization: each feature has its own data & presentation packages
- Dependency inversion: ViewModels depend on abstract Repos, not concrete Firebase classes
- Single responsibility: services/api_services.dart handles networking; repositories handle data persistence
- Testability: each layer can be mocked or stubbed

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Flutter App"
    subgraph "Platform Embedders"
      Android["Android Embedder"]:::engine
      iOS["iOS Embedder"]:::engine
      Web["Web Embedder"]:::engine
      macOS["macOS Embedder"]:::engine
      Windows["Windows Embedder"]:::engine
      Linux["Linux Embedder"]:::engine
    end

    Main["Main App\nlib/main.dart"]:::domain
    FirebaseOptions["Firebase Options\nfirebase_options.dart"]:::domain
    BlocObserver["Bloc Observer\nsimple_bloc_observer.dart"]:::domain

    FlutterEngine["Flutter Engine"]:::engine

    subgraph "Presentation Layer" 
      Widgets["Widgets (Views)"]:::ui
      ViewModels["ViewModels (Bloc/Cubit)"]:::ui

      subgraph "Features" 
        AuthFeature["Authentication"]:::ui
        HomeFeature["Home/Contract"]:::ui
        PaymentFeature["Payment"]:::ui
        ChatbotFeature["Chatbot"]:::ui
        NotificationFeature["Notification"]:::ui
        ProfileFeature["Profile"]:::ui
        SplashFeature["Splash"]:::ui
        ThemeFeature["Theme"]:::ui
        LanguagesFeature["Languages"]:::ui
      end
    end

    subgraph "Core Services"
      ApiServices["ApiServices"]:::domain
      BaseService["Base Service"]:::domain
      Router["App Router"]:::domain
      Constants["Constants & Helpers"]:::domain
      ThemeUtils["Theme Utils"]:::domain
    end

    subgraph "Domain & Data"
      UserRepoInterface["User Repo Interface"]:::domain
      FirebaseUserRepo["FirebaseUserRepo Impl"]:::domain
      Repositories["Feature Repositories"]:::domain
      Models["Data Models & Mappers"]:::domain
    end
  end

  subgraph "External Services"
    FirebaseAuth["Firebase Auth"]:::external
    Firestore["Firestore DB"]:::external
    CloudStorage["Cloud Storage"]:::external
    NodeFunctions["Node.js Functions"]:::external
    FlutterFire["FlutterFire Plugins"]:::plugin
  end

  Android --> FlutterEngine
  iOS --> FlutterEngine
  Web --> FlutterEngine
  macOS --> FlutterEngine
  Windows --> FlutterEngine
  Linux --> FlutterEngine

  Main --> FlutterEngine
  Main --> FirebaseOptions
  Main --> BlocObserver

  FlutterEngine --> Widgets
  Widgets --> ViewModels

  ViewModels --> ApiServices
  ViewModels --> UserRepoInterface
  ViewModels --> Repositories

  ApiServices --> FirebaseAuth
  ApiServices --> Firestore
  ApiServices --> CloudStorage
  ApiServices --> NodeFunctions

  UserRepoInterface --> FirebaseUserRepo
  FirebaseUserRepo --> FirebaseAuth
  FirebaseUserRepo --> Firestore

  Repositories --> Models

  FlutterFire --> FirebaseAuth
  FlutterFire --> Firestore
  FlutterFire --> CloudStorage

  classDef ui fill:#E0F7FA,stroke:#0288D1
  classDef engine fill:#E1BEE7,stroke:#8E24AA
  classDef domain fill:#E8F5E9,stroke:#2E7D32
  classDef external fill:#FFF3E0,stroke:#EF6C00
  classDef plugin fill:#FFEBEE,stroke:#C62828

  click Android "https://github.com/mjaber5/qanoni-app/tree/master/android/"
  click iOS "https://github.com/mjaber5/qanoni-app/tree/master/ios/"
  click Web "https://github.com/mjaber5/qanoni-app/tree/master/web/"
  click macOS "https://github.com/mjaber5/qanoni-app/tree/master/macos/"
  click Windows "https://github.com/mjaber5/qanoni-app/tree/master/windows/"
  click Linux "https://github.com/mjaber5/qanoni-app/tree/master/linux/"
  click ApiServices "https://github.com/mjaber5/qanoni-app/blob/master/lib/core/services/api_services.dart"
  click BaseService "https://github.com/mjaber5/qanoni-app/blob/master/lib/core/services/base.dart"
  click Router "https://github.com/mjaber5/qanoni-app/blob/master/lib/core/utils/app_router.dart"
  click Constants "https://github.com/mjaber5/qanoni-app/tree/master/lib/core/utils/constants/"
  click ThemeUtils "https://github.com/mjaber5/qanoni-app/blob/master/lib/core/utils/theme/theme.dart"
  click ThemeUtils "https://github.com/mjaber5/qanoni-app/tree/master/lib/core/utils/theme/custom_themes/"
  click AuthFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/authentication/auth_blocs/"
  click AuthFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/authentication/login/presentation/view_model/sign_in_bloc/"
  click AuthFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/authentication/login/presentation/views/login_view.dart"
  click AuthFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/authentication/signup/presentation/view_model/sign_up_bloc/"
  click AuthFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/authentication/signup/presentation/views/signup_view.dart"
  click HomeFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/home/data/contract_repo.dart"
  click HomeFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/home/data/model/"
  click HomeFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/home/presentation/view_model/contract_status/contract_status_cubit.dart"
  click HomeFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/home/presentation/views/contracts/"
  click PaymentFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/payment/presentation/view/"
  click PaymentFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/payment/presentation/view/widget/"
  click ChatbotFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/chatbot/data/test.dart"
  click ChatbotFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/chatbot/presentation/views/chatbot_view.dart"
  click ChatbotFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/chatbot/presentation/views/widgets/"
  click NotificationFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/notification/data/modelnotification.dart"
  click NotificationFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/notification/presentation/view_model/notification_cubit/"
  click NotificationFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/notification/presentation/views/widgets/"
  click ProfileFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/profile/presentation/view_model/my_cache_manager.dart"
  click ProfileFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/profile/presentation/views/"
  click ProfileFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/profile/presentation/views/widgets/"
  click SplashFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/splash/data/test.dart"
  click SplashFeature "https://github.com/mjaber5/qanoni-app/tree/master/lib/features/splash/presentation/views/"
  click ThemeFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/theme/presentation/view_model/cubit/change_theme_cubit.dart"
  click LanguagesFeature "https://github.com/mjaber5/qanoni-app/blob/master/lib/features/languages/view_model/app_langauge_cubit/app_language_cubit.dart"
  click UserRepoInterface "https://github.com/mjaber5/qanoni-app/blob/master/packages/user_repository/lib/src/user_repo.dart"
  click UserRepoInterface "https://github.com/mjaber5/qanoni-app/blob/master/packages/user_repository/lib/src/entites/user_entity.dart"
  click FirebaseUserRepo "https://github.com/mjaber5/qanoni-app/blob/master/packages/user_repository/lib/src/firebase_user_repo.dart"
  click Main "https://github.com/mjaber5/qanoni-app/blob/master/lib/main.dart"
  click FirebaseOptions "https://github.com/mjaber5/qanoni-app/blob/master/lib/firebase_options.dart"
  click BlocObserver "https://github.com/mjaber5/qanoni-app/blob/master/lib/simple_bloc_observer.dart"
```
