# iamimmanuelraj/block_administrator architecture

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

- Interactive diagram: https://gitdiagram.com/iamimmanuelraj/block_administrator
- Repository: https://github.com/iamimmanuelraj/block_administrator

## Overview

##### Project Type & Purpose
- This is a specialized Frappe app focused on security, specifically to prevent admin login under certain conditions.
- While it is primarily a backend Python application (integrated within the Frappe framework), it has a frontend aspect (via public assets and templates) to support user interaction or configuration (e.g., system settings JavaScript).

##### Analyzing the File Structure
- Top-Level Components:
- .github folder, which contains workflows for CI, linters, dependency checks, etc. These are supportive elements for development rather than parts of the core system.
- package.json, eslint.config.mjs, and related JS resources signal that there is a frontend aspect for system settings or admin interface enhancements.
- Python-centric components in the “block_administrator” directory are the core of the app. There are multiple subdirectories:
○ “auth” directory indicates security or authentication-related logic.
○ “block_administrator/block_administrator/doctype/…” holds the implementation of the custom doctype and its associated business rules (including JavaScript and Python files, plus tests).
○ “config” and “hooks.py” suggest integration points with the Frappe framework to override or extend default behaviors.
○ “templates” directory supports the rendering of pages or configuration dialogs in the Frappe desk.
- Testing and Configuration:
- Presence of test files (e.g., test_block_administrator.py) shows that there is a defined mechanism for validation.
- Additional configuration files like pyproject.toml and package-lock.json indicate dependency management for both Python and Node ecosystems.

##### Identifying Main System Components
- Frappe Integration Module: This is the core that integrates with Frappe. It includes hooks, initialization routines, and configuration specifics.
- Authentication/Authorization: The “auth” directory and related logic enforce the blocking mechanism.
- Custom Doctype & Business Logic: Under “block_administrator/block_administrator/doctype/block_administrator”, the app’s core functionality (including relevant JS and Python scripts) is implemented.
- Frontend/Display Layer: Comprises the public JS, templates, and possibly the system settings UI for administrators configuring the app.
- CI/CD Pipeline: Represented by the .github folder content (workflows for linting, dependency scanning, and tests).

##### Detailing Relationships & Interactions
- The Frappe framework is the underlying platform that orchestrates the entire app. The hooks integrate the app's custom behavior (e.g., blocking admin login) with Frappe events.
- The authentication module ties into the login logic of Frappe. It likely intercepts the login sequence and checks if the login is attempted for the administrator account.
- The custom doctype and its associated UI (JS and JSON for meta definitions) allow you to configure and extend how the block mechanism is applied.
- The frontend components (templates and public JS) facilitate viewing or managing system settings related to blocking functionality.
- CI/CD pipelines ensure code quality and stability before deployment.

##### Architectural Patterns & Technology Highlights
- Modular Design: The separation of authentication, doctype definitions, hooks, and configuration establishes clear modularity.
- MVC Elements: While not a strict MVC, there is a separation between data models (doctype), business logic (hooks and authentication), and views (templates and public JS).
- Integration with Frappe: Utilizes Frappe’s event hooks and module system.
- Use of modern CI/CD practices, by including GitHub workflows, ensures that development cycles are automated and tested.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User (Login Page)"]:::frontend

    subgraph "Frontend/UI Elements"
        FS1["System Settings JS"]:::frontend
        FS2["Templates"]:::frontend
    end

    U -->|"initiatesRequest"| FS1
    U -->|"initiatesRequest"| FS2
    FS1 -->|"sendsLoginData"| FF
    FS2 -->|"rendersUI"| FF

    FF["Frappe Framework"]:::backend

    subgraph "Block Administrator App"
        FI_Hooks["Frappe Hooks"]:::backend
        FI_Config["Frappe Config"]:::backend
        AM["Authentication Module"]:::backend
        CD["Custom Doctype Module"]:::backend
    end

    FF -->|"hookInvocation"| FI_Hooks
    FI_Hooks -->|"loginInterception"| AM
    FI_Hooks -->|"businessRules"| CD
    FI_Config -->|"integrated"| FI_Hooks

    subgraph "Configuration & Dependency Management"
        Config1["package.json"]:::config
        Config2["pyproject.toml"]:::config
        Config3["package-lock.json"]:::config
    end

    Config1 -->|"configPush"| FI_Config
    Config2 -->|"configPush"| FI_Config
    Config3 -->|"configPush"| FI_Config

    CICD["CI/CD Pipeline"]:::cicd
    CICD -->|"deployUpdates"| FI_Config

    classDef frontend fill:#ddf,stroke:#333,stroke-width:2px;
    classDef backend fill:#fdd,stroke:#333,stroke-width:2px;
    classDef config fill:#ffd,stroke:#333,stroke-width:2px;
    classDef cicd fill:#dfd,stroke:#333,stroke-width:2px;

    click FS1 "https://github.com/iamimmanuelraj/block_administrator/blob/develop/block_administrator/public/js/system_settings.js"
    click FS2 "https://github.com/iamimmanuelraj/block_administrator/tree/develop/block_administrator/templates/pages/"
    click AM "https://github.com/iamimmanuelraj/block_administrator/tree/develop/block_administrator/auth/"
    click CD "https://github.com/iamimmanuelraj/block_administrator/tree/develop/block_administrator/block_administrator/doctype/block_administrator/"
    click FI_Hooks "https://github.com/iamimmanuelraj/block_administrator/blob/develop/block_administrator/hooks.py"
    click FI_Config "https://github.com/iamimmanuelraj/block_administrator/tree/develop/block_administrator/config/"
    click CICD "https://github.com/iamimmanuelraj/block_administrator/tree/develop/.github/"
    click Config1 "https://github.com/iamimmanuelraj/block_administrator/blob/develop/package.json"
    click Config2 "https://github.com/iamimmanuelraj/block_administrator/blob/develop/pyproject.toml"
    click Config3 "https://github.com/iamimmanuelraj/block_administrator/blob/develop/package-lock.json"
```
