# felpower/projekt2_flutter_crush architecture

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

- Interactive diagram: https://gitdiagram.com/felpower/projekt2_flutter_crush
- Repository: https://github.com/felpower/projekt2_flutter_crush

## Overview

##### Project Type & Purpose
- This is primarily a Flutter application that appears to be a mobile game incorporating several “dark patterns” as part of its user experience. It integrates various services such as Firebase (for messaging, hosting, and deployment) and even includes a Unity module (the “unity/Match3” folder) likely to handle a Match3-style game component. In addition, there are several generator scripts (located in the generators directory) that are used for data extraction, error tracking, notifications, and statistics.
- The README also mentions mobile/web deployment (with instructions for both Android internal testing and Firebase web hosting) and hints at notifications testing through Firebase Cloud Messaging.

##### Analyzing the File Structure – Key Architectural Areas
- Platform-specific Code: Directories such as android, ios, linux, macos, and web indicate platform-specific builds and configurations. Each contains build files and platform adaptations.
- Unity Integration: There is a dedicated unity folder (and a nested “unity/Match3”) which contains Unity project files including scripts, prefabs, scenes, and plugins – indicating an integration of a Unity-based mini-game or component inside the Flutter app.
- Backend/Service Components: The lib/persistence directory and the lib/services directory show how data is stored (e.g., coins, levels, high scores) and how external services are integrated (Firebase messaging).
- Data Generators and Tools: The generators folder contains several Python scripts and JSON/Excel files to extract, generate, or analyze data such as levels, dark patterns feedback, and logs. This is a suite of CLI and scripting tools that support data management and game analytics.
- Continuous Integration/Deployment: The existence of .github/workflows and Firebase deployment scripts (firebase.json, etc.) shows automated pipelines for testing and deployment for both mobile builds and web.

a. Main Components to Include:
- Flutter Frontend: Represent the Flutter UI and logic (include main.dart, BLoC layers, and pages).
- Platform-Specific Bridges: Blocks for Android, iOS, Web, Linux, macOS showing that the core app has different deployment targets.
- Unity Module: A separate block that represents the Unity “Match3” component, possibly linked to a Flutter Unity integration controller (located in lib/controllers/unity).
- Firebase Services: A block showing integration with Firebase (messaging, hosting, and configuration via firebase_options.dart) and how notifications are handled.
- Data Generation & Analytics: A component showing the generators (Python scripts and associated data files) used for analytics, error logging, and level generation.
- External Services: If applicable, show communication with external services (for Firebase notifications or OAuth flows as mentioned).

b. Relationships & Interactions:
- How the Unity module is invoked via a dedicated Flutter controller (see lib/controllers/unity/unity_screen.dart) and how data flows back to the Flutter app.
- Demonstrate integration with Firebase services (e.g., messaging, hosting) and link the deployment pipelines from CI/CD (GitHub workflows).
- How asset resources are accessed and utilized by both the Flutter and Unity components.
- Interactions from backend services (Firebase, database exports in generators directory) which might feed analytics or dark patterns information into the app.

c. Architectural Patterns & Design Principles:
- Use of the BLoC architectural pattern for state management in Flutter (with separate blocs for game state, user state, dark patterns, and notifications).
- Modular design by segregating platform-specific configurations and the integration of a Unity module as a separate component.
- Clear separation between UI (pages, widgets), business logic (BLoC), data/model, and persistence (services).

d. Technologies & Frameworks:
- Flutter (with version 2.8.0) for the primary mobile application.
- Firebase for messaging, hosting, and backend services.
- Unity for the integrated Match3 game module.
- Python scripts and various generators for data processing.
- GitHub Actions for CI/CD workflows.

##### Putting It All Together
- Clarity in data flows and interactions, as this will aid not only in understanding the project architecture but also in future enhancements or debugging.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Flutter App Subgraph
    subgraph "Flutter App"
        UI["Flutter UI & Business Logic"]:::frontend
        BLOC["BLoC Layers (State Management)"]:::bloc
        UI -->|"stateFlow"| BLOC
    end

    %% Assets & Resources
    Assets["Assets & Resources"]:::assets

    %% Platform Specific Bridges Subgraph
    subgraph "Platform Bridges"
        Android["Android"]:::platform
        IOS["iOS"]:::platform
        Linux["Linux"]:::platform
        Mac["macOS"]:::platform
        Web["Web"]:::platform
    end

    %% Unity Integration Subgraph
    subgraph "Unity Integration"
        UnityController["Unity Controller (Flutter)"]:::unity
        UnityModule["Unity Module (Match3)"]:::unity
        UnityController -->|"integratesWith"| UnityModule
    end

    %% Firebase Services Integration
    Firebase["Firebase Services"]:::firebase

    %% Data Generation & Analytics Tools
    DataGen["Data Generators (Python Scripts & Data)"]:::datagen

    %% Continuous Integration/Deployment
    CI_CD["CI/CD Pipelines"]:::cicd

    %% Relationships
    UI -->|"usesAssets"| Assets
    UI -->|"invokesUnity"| UnityController
    BLOC -->|"triggersFirebase"| Firebase
    DataGen -->|"feedsData"| Firebase

    %% CI/CD deploying to platforms and Firebase
    CI_CD -->|"deploysTo"| Android
    CI_CD -->|"deploysTo"| IOS
    CI_CD -->|"deploysTo"| Linux
    CI_CD -->|"deploysTo"| Mac
    CI_CD -->|"deploysTo"| Web
    CI_CD -->|"deploysFirebase"| Firebase

    %% Class Definitions (Styles)
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef bloc fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef assets fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef platform fill:#FAD7A0,stroke:#000,stroke-width:2px;
    classDef unity fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef firebase fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef datagen fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFB6C1,stroke:#000,stroke-width:2px;

    %% Click Events
    click UI "https://github.com/felpower/projekt2_flutter_crush/tree/main/lib/"
    click BLOC "https://github.com/felpower/projekt2_flutter_crush/tree/main/lib/bloc/"
    click Assets "https://github.com/felpower/projekt2_flutter_crush/tree/main/assets/"
    click Android "https://github.com/felpower/projekt2_flutter_crush/tree/main/android/"
    click IOS "https://github.com/felpower/projekt2_flutter_crush/tree/main/ios/"
    click Linux "https://github.com/felpower/projekt2_flutter_crush/tree/main/linux/"
    click Mac "https://github.com/felpower/projekt2_flutter_crush/tree/main/macos/"
    click Web "https://github.com/felpower/projekt2_flutter_crush/tree/main/web/"
    click UnityController "https://github.com/felpower/projekt2_flutter_crush/blob/main/lib/controllers/unity/unity_screen.dart"
    click UnityModule "https://github.com/felpower/projekt2_flutter_crush/tree/main/unity/Match3/"
    click Firebase "https://github.com/felpower/projekt2_flutter_crush/blob/main/lib/firebase_options.dart"
    click Firebase "https://github.com/felpower/projekt2_flutter_crush/blob/main/lib/services/firebase_messaging.dart"
    click DataGen "https://github.com/felpower/projekt2_flutter_crush/tree/main/generators/"
    click CI_CD "https://github.com/felpower/projekt2_flutter_crush/tree/main/.github/workflows/"
```
