# ives97/galeno-public architecture

> Architecture diagram of the GitHub repository ives97/galeno-public, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ives97/galeno-public
- Repository: https://github.com/ives97/galeno-public

## Overview

##### Project Type and Purpose
- This is a Flutter‑based mobile application (Android & iOS) for quizzes, user profiles, notifications, ads, and in‑app purchases.
- It has no custom backend code in the repo; it relies on Firebase services (Auth, Firestore, Cloud Messaging), AdMob, local storage, and other external systems.

##### File Structure and Key Modules
- Native Shells:
– android/… and ios/… directories hold the platform‑specific Runner projects and Gradle/Pods configuration.
- Flutter Core:
– lib/main.dart and lib/app.dart – application entry point and root widget.
- UI Layer:
– lib/pages/… – screen definitions (login, signup, quiz screens, settings, etc.).
– lib/widgets/… and lib/cards/… – reusable UI components.
- State Management:
– lib/blocs/… – BLoC classes (ads_bloc, question_bloc, user_bloc, etc.) implementing the BLoC pattern.
- Service Layer:
– lib/services/… – wrappers for Firebase (auth_service, firebase_service), local storage (sp_service), notifications (notification_service), and common app business logic (app_service).
- Data Models & Configs:
– lib/models/… – Dart model classes (User, Question, Quiz, etc.).
– lib/configs/… – configuration objects for ads, app settings, theming, and supported languages.
- Resources & Assets:
– assets/… – JSON animations, fonts, images, translations, and audio.
- Build & Dependency Files:
– pubspec.yaml, android/build.gradle, ios/Podfile – declare dependencies and configure builds.

##### Architectural Patterns
- Layered architecture with clear separation:
– Presentation (Flutter UI widgets + Pages)
– Business Logic (BLoCs)
– Data & Integration (Service classes + Models)
- BLoC pattern ensures unidirectional data flow: UI → Events → BLoC → State → UI.
- External service integrations: Firebase for backend functions, AdMob for ads, Shared Preferences for local storage.

##### Main Components and Interactions
a. Mobile Client (Android/iOS shell)
– Flutter Engine & Dart VM
– Your Dart code (UI, BLoCs, Services)
b. UI Layer
– Pages & Widgets grouped by features (Authentication, Quiz Flow, Profile, Settings, etc.)
c. State Management Layer (BLoCs)
– List each BLoC module or group by domain (UserBloc, QuestionBloc, SettingsBloc, etc.)
d. Service Layer
– FirebaseService (Auth, Firestore)
– NotificationService (FCM)
– AppService (in‑app logic)
– SPService (local storage)
e. Data Layer
– Models and Configs
f. External Systems
– Firebase (Auth, Firestore, Cloud Messaging)
– AdMob / Ad networks
– In‑app purchase providers (if used)

##### Relationships & Data Flow
- From BLoCs to Services: “Fetch/Update data → Service”.
- From Services to External Systems: “HTTP/SDK calls → Firebase / AdMob / etc.”

##### Important Design Principles
- Unidirectional data flow (BLoC)
- Layer separation (UI, Business Logic, Data)
- Modularization: group related pages/widgets, group BLoCs by domain
- Dependency inversion: UI depends on abstract bloc interfaces

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Native Shells
    subgraph "Native Shells"
        direction TB
        AndroidShell["Android Shell"]:::external
        IOShell["iOS Shell"]:::external
    end

    %% Flutter Engine
    FlutterEngine["Flutter Engine & Dart VM"]:::external

    %% Flutter Core
    subgraph "Flutter Core"
        direction TB
        Main["main.dart"]:::ui
        App["app.dart"]:::ui
    end

    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        Pages["Pages (lib/pages/)"]:::ui
        Widgets["Widgets (lib/widgets/)"]:::ui
        Cards["Cards (lib/cards/)"]:::ui
        Tabs["Tabs (lib/tabs/)"]:::ui
    end

    %% State Management (BLoCs)
    subgraph "Business Logic (BLoCs)"
        direction TB
        Blocs["BLoCs (lib/blocs/)"]:::bloc
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        Services["Services (lib/services/)"]:::service
    end

    %% Data & Configs
    subgraph "Data Models & Configs"
        direction TB
        Models["Models (lib/models/)"]:::data
        Configs["Configs (lib/configs/)"]:::data
    end

    %% Utilities
    Utils["Utilities (lib/utils/)"]:::util

    %% Assets & Resources
    Assets["Assets (assets/)"]:::external

    %% Build & Config Files
    subgraph "Build & Config"
        direction TB
        Pubspec["pubspec.yaml"]:::data
        Gradle["android/build.gradle"]:::data
        Podfile["ios/Podfile"]:::data
    end

    %% External Systems
    subgraph "External Services"
        direction TB
        Firebase["Firebase Services"]:::external
        AdMob["AdMob / Ad Networks"]:::external
        IAP["In-App Purchase Providers"]:::external
    end

    %% Connections
    AndroidShell --> FlutterEngine
    IOShell --> FlutterEngine
    FlutterEngine --> Main
    Main --> App

    App --> Pages
    App --> Widgets
    App --> Cards
    App --> Tabs

    Pages --> Blocs
    Widgets --> Blocs
    Cards --> Blocs
    Tabs --> Blocs

    Blocs --> Services
    Services --> Firebase
    Services --> AdMob
    Services --> IAP
    Services --> Utils
    Services --> Models
    Services --> Configs

    Assets --> Pages
    Assets --> Widgets
    Assets --> Tabs

    Pubspec --> App
    Gradle --> AndroidShell
    Podfile --> IOShell

    %% Click Events
    click AndroidShell "https://github.com/ives97/galeno-public/tree/main/android/"
    click IOShell "https://github.com/ives97/galeno-public/tree/main/ios/"
    click Main "https://github.com/ives97/galeno-public/blob/main/lib/main.dart"
    click App "https://github.com/ives97/galeno-public/blob/main/lib/app.dart"
    click Pages "https://github.com/ives97/galeno-public/tree/main/lib/pages/"
    click Widgets "https://github.com/ives97/galeno-public/tree/main/lib/widgets/"
    click Cards "https://github.com/ives97/galeno-public/tree/main/lib/cards/"
    click Tabs "https://github.com/ives97/galeno-public/tree/main/lib/tabs/"
    click Blocs "https://github.com/ives97/galeno-public/tree/main/lib/blocs/"
    click Services "https://github.com/ives97/galeno-public/tree/main/lib/services/"
    click Models "https://github.com/ives97/galeno-public/tree/main/lib/models/"
    click Configs "https://github.com/ives97/galeno-public/tree/main/lib/configs/"
    click Utils "https://github.com/ives97/galeno-public/tree/main/lib/utils/"
    click Assets "https://github.com/ives97/galeno-public/tree/main/assets/"
    click Pubspec "https://github.com/ives97/galeno-public/blob/main/pubspec.yaml"
    click Gradle "https://github.com/ives97/galeno-public/blob/main/android/build.gradle"
    click Podfile "https://github.com/ives97/galeno-public/tree/main/ios/Podfile"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef bloc fill:#90EE90,stroke:#333,stroke-width:1px
    classDef service fill:#FFA500,stroke:#333,stroke-width:1px
    classDef data fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef util fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef external fill:#F0E68C,stroke:#333,stroke-width:1px
```
