# dungngminh/app_creaty architecture

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

- Interactive diagram: https://gitdiagram.com/dungngminh/app_creaty
- Repository: https://github.com/dungngminh/app_creaty

## Overview

##### Main Components Identification

The system consists of these major components:
- Frontend (UI/Presentation Layer)
- State Management Layer
- Data Layer
- External Services Integration

##### Component Relationships

- Data flow between layers
- Dependencies between components
- User interaction flows
- State updates and propagation

##### Specific Implementation Details

Specialized sections for:
- Widget Tree Management
- Drag and Drop Implementation
- Code Generation System
- Project Synchronization

##### Technical Stack Indicators

Technologies:
- Flutter/Dart
- Supabase
- BLoC Pattern
- Hive
- Material 3

Create clear boundaries for:
- Core Application Logic
- Feature Modules
- External Integrations
- Platform-Specific Code

##### The project synchronization with Supabase

- How components communicate
- How state is managed and propagated
- How the drag-and-drop functionality integrates with the widget tree
- How the code generation system works
- How project data is synchronized between local and remote storage

This architecture should reflect the application's focus on providing a visual development environment while maintaining clean separation of concerns and robust state management.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        UI_Editor["Editor Module"]
        UI_Preview["Virtual App Preview"]
        UI_Tools["Tool Panel"]
        UI_Props["Property Panel"]
        UI_CompTree["Component Tree"]
        UI_Auth["Authentication UI"]
    end

    subgraph "State Management Layer"
        AppBloc["App BLoC"]
        EditorBloc["Editor BLoC"]
        VirtualBloc["Virtual App BLoC"]
        CompTreeBloc["Component Tree BLoC"]
        LoginCubit["Login Cubit"]
        RegCubit["Register Cubit"]
        NewProjCubit["New Project Cubit"]
    end

    subgraph "Data Layer"
        AuthRepo["Auth Repository"]
        ProjRepo["Project Repository"]
        HiveDB[(Hive Database)]
        SecureStore[(Secure Storage)]
        DBService["Database Services"]
    end

    subgraph "Core Components"
        CodeGen["Code Generation"]
        TreeMgmt["Widget Tree Management"]
        Algorithm["Algorithm Implementation"]
        ProjModels["Project Models"]
    end

    %% Frontend to State Management
    UI_Editor --> EditorBloc
    UI_Preview --> VirtualBloc
    UI_CompTree --> CompTreeBloc
    UI_Auth --> LoginCubit
    UI_Auth --> RegCubit
    UI_Tools --> NewProjCubit

    %% State Management to Data Layer
    AppBloc --> AuthRepo
    AppBloc --> ProjRepo
    EditorBloc --> ProjRepo
    LoginCubit --> AuthRepo
    RegCubit --> AuthRepo
    NewProjCubit --> ProjRepo

    %% Data Layer Connections
    AuthRepo --> DBService
    ProjRepo --> DBService
    DBService --> HiveDB
    DBService --> SecureStore

    %% Core Component Connections
    EditorBloc --> CodeGen
    CompTreeBloc --> TreeMgmt
    TreeMgmt --> Algorithm
    ProjRepo --> ProjModels

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef statemgmt fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef core fill:#9b59b6,stroke:#8e44ad,color:white

    class UI_Editor,UI_Preview,UI_Tools,UI_Props,UI_CompTree,UI_Auth frontend
    class AppBloc,EditorBloc,VirtualBloc,CompTreeBloc,LoginCubit,RegCubit,NewProjCubit statemgmt
    class AuthRepo,ProjRepo,HiveDB,SecureStore,DBService data
    class CodeGen,TreeMgmt,Algorithm,ProjModels core

    %% Click Events
    click UI_Editor "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/editor/"
    click UI_Preview "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/virtual_app/"
    click UI_Tools "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/tool_panel/"
    click UI_Props "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/prop_panel/"
    click UI_CompTree "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/tool_panel/component_tree/"
    click UI_Auth "https://github.com/dungngminh/app_creaty/tree/master/lib/presentation/auth/"
    click AppBloc "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/app/bloc/app_bloc.dart"
    click EditorBloc "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/editor/bloc/editor_bloc.dart"
    click VirtualBloc "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/virtual_app/bloc/virtual_app_bloc.dart"
    click CompTreeBloc "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/tool_panel/component_tree/bloc/component_tree_bloc.dart"
    click LoginCubit "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/auth/login/cubit/login_cubit.dart"
    click RegCubit "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/auth/register/cubit/register_cubit.dart"
    click NewProjCubit "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/new_project/cubit/new_project_cubit.dart"
    click AuthRepo "https://github.com/dungngminh/app_creaty/blob/master/lib/repositories/auth_repository.dart"
    click ProjRepo "https://github.com/dungngminh/app_creaty/blob/master/lib/repositories/project_repository.dart"
    click HiveDB "https://github.com/dungngminh/app_creaty/blob/master/lib/local/intiialize_hive.dart"
    click SecureStore "https://github.com/dungngminh/app_creaty/blob/master/lib/local/secure_storage_helper.dart"
    click DBService "https://github.com/dungngminh/app_creaty/blob/master/lib/data/project_database_service.dart"
    click CodeGen "https://github.com/dungngminh/app_creaty/blob/master/lib/commons/gen_code/gen_code_module.dart"
    click TreeMgmt "https://github.com/dungngminh/app_creaty/blob/master/lib/presentation/tool_panel/component_tree/models/widget_tree_node.dart"
    click Algorithm "https://github.com/dungngminh/app_creaty/blob/master/lib/commons/algorithm/app_creaty_algorithm.dart"
    click ProjModels "https://github.com/dungngminh/app_creaty/blob/master/lib/models/app_creaty_project.dart"
```
