# yuganka/bernoulli architecture

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

- Interactive diagram: https://gitdiagram.com/yuganka/bernoulli
- Repository: https://github.com/yuganka/bernoulli

## Overview

##### Main Components

a) Core Components:
- Bernoulli Core Engine
- Annotation Processing System
- Flow Management System
- Activity Management Layer
- Managers Layer
- Desilting (State Management) Layer

b) Integration Components:
- Android Application Layer
- AspectJ Weaving System

**┌─ Application Layer ─────────────────────┐**
- BernoulliActivity                       │
- Annotation Layer ──────────────────────┤
- @RequiresPermission  @RequiresSetting   │
- Aspect Processing Layer ───────────────┤
- FlowAspect                              │
- Core Engine Layer ────────────────────┤
- Bernoulli → FlowStateEvaluator         │
- Managers Layer ──────────────────────┤
- PermissionsManager  SettingsManager    │
- GPSManager         NetworkManager      │
- ┘

##### Key Relationships to Highlight

a) Control Flow:
- How BernoulliActivity interfaces with the core engine
- Aspect weaving process from annotations to runtime behavior
- Demonstrate the permission/settings flow evaluation process

b) Data Flow:
- How permissions and settings states are managed
- Flow state evaluation process
- Callback mechanisms to the application layer

##### Important Implementation Details

Specific components:
- StreamFlowState management
- Permission and Settings policies
- Desilting system (Dam, AskPermissionSet, AskSettingSet)
- Annotation processing system

##### Notes for Implementation

- The library's AOP nature
- Runtime permission/settings handling
- Integration with Android components
- Flow control mechanisms

##### Additional Recommendations

- Notes about AspectJ weaving process
- Initialization sequence
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef android fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef aspect fill:#FFA500,stroke:#333,stroke-width:2px
    classDef annotation fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef manager fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef state fill:#98FB98,stroke:#333,stroke-width:2px

    %% Application Layer
    subgraph AppLayer
        BA[BernoulliActivity]:::android
    end

    %% Annotation Layer
    subgraph AnnotationLayer
        RP[RequiresPermission]:::annotation
        RS[RequiresSetting]:::annotation
    end

    %% Aspect Processing Layer
    subgraph AspectLayer
        FA[FlowAspect]:::aspect
        FSE[FlowStateEvaluator]:::aspect
    end

    %% Core Engine Layer
    subgraph CoreLayer
        BE[Bernoulli]:::core
        SFS[StreamFlowState]:::core
        Stream[Stream]:::core
    end

    %% Managers Layer
    subgraph ManagersLayer
        PM[PermissionsManager]:::manager
        SM[SettingsManager]:::manager
        GPSM[GPSManager]:::manager
        NM[NetworkManager]:::manager
    end

    %% Desilting Layer
    subgraph DesiltingLayer
        Dam[Dam]:::state
        APS[AskPermissionSet]:::state
        ASS[AskSettingSet]:::state
    end

    %% Policy Layer
    subgraph PolicyLayer
        PDP[PermissionDisabledPolicy]:::core
        SSP[SettingsStateMismatchPolicy]:::core
    end

    %% Relationships
    BA --> BE
    BE --> FA
    BE --> FSE
    FA --> FSE
    FSE --> SFS
    SFS --> Stream

    RP --> FA
    RS --> FA

    BE --> PM
    BE --> SM
    BE --> GPSM
    BE --> NM

    PM --> Dam
    SM --> Dam
    Dam --> APS
    Dam --> ASS

    PM --> PDP
    SM --> SSP

    %% Click Events
    click BA "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/android/BernoulliActivity.java"
    click BE "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/Bernoulli.java"
    click FA "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/FlowAspect.java"
    click FSE "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/FlowStateEvaluator.java"
    click RP "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/annotation/RequiresPermission.java"
    click RS "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/annotation/RequiresSetting.java"
    click PM "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/managers/PermissionsManager.kt"
    click SM "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/managers/SettingsManager.kt"
    click GPSM "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/managers/GPSManager.kt"
    click NM "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/managers/NetworkManager.kt"
    click Dam "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/desilting/Dam.kt"
    click APS "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/desilting/AskPermissionSet.kt"
    click ASS "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/desilting/AskSettingSet.kt"
    click SFS "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/StreamFlowState.kt"
    click Stream "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/Stream.java"
    click PDP "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/PermissionDisabledPolicy.java"
    click SSP "https://github.com/Yuganka/Bernoulli/blob/master/bernoulli/src/main/java/co/yuganka/bernoulli/SettingsStateMismatchPolicy.java"
```
