
flowchart TD
    A[User Login] --> B{Authentication}
    B -->|Success| C[Load User Profile]
    B -->|Failure| Z[Access Denied]
    
    C --> D[Load User Groups]
    D --> E[Evaluate Policies]
    
    subgraph "Policy Evaluation"
        E --> F{Check Built-in Policies}
        F -->|Match| G[Apply Built-in Permissions]
        F -->|No Match| H{Check Custom Policies}
        H -->|Match| I[Apply Custom Permissions]
        H -->|No Match| J[Apply Default Permissions]
    end
    
    G --> K[Filter Resources]
    I --> K
    J --> K
    
    K --> L[Display Authorized Resources]
    
    style A fill:#f9d5e5,stroke:#333,stroke-width:2px
    style B fill:#eeeeee,stroke:#333,stroke-width:2px
    style Z fill:#ffcccc,stroke:#333,stroke-width:2px
    style E fill:#d5e8d4,stroke:#333,stroke-width:2px
    style F fill:#d5e8d4,stroke:#333,stroke-width:2px
    style G fill:#d5e8d4,stroke:#333,stroke-width:2px
    style H fill:#d5e8d4,stroke:#333,stroke-width:2px
    style I fill:#d5e8d4,stroke:#333,stroke-width:2px
    style J fill:#d5e8d4,stroke:#333,stroke-width:2px
    style K fill:#dae8fc,stroke:#333,stroke-width:2px
    style L fill:#dae8fc,stroke:#333,stroke-width:2px

