# imjaineel/on-demand-admin-access architecture

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

- Interactive diagram: https://gitdiagram.com/imjaineel/on-demand-admin-access
- Repository: https://github.com/imjaineel/on-demand-admin-access

## Overview

##### Project type and purpose
- This is a ServiceNow custom application (“On-Demand-Admin-Access”) packaged as update‐sets and authoring XML files.
- It provides a UI (Service Catalog + Forms) for requesting temporary administrative access, enforces UI policies, triggers Flow Designer flows, grants roles, enforces ACLs, and sends email notifications.

##### File structure
- Top-level:
- README.md, LICENSE, sn_source_control.properties, checksum.txt
- dictionary/ – custom table definitions (x_snc_admin_temporary_access.xml)
- author_elective_update/ – initial app metadata (sys_app, sys_module, UI Policies, catalog items, table definitions, flows)
- update/ – incremental metadata changes (client scripts, catalog UI policies & actions, item options, questions, script includes, flows, ACLs, email actions, UI form sections)
- Key patterns:
- MVC-style low-code: tables (Model), UI Policies/Forms/Catalog Items (View), Script Includes/Flows (Controller)
- Flow Designer (sys_hub_flow_*.xml) for orchestration
- ACLs & Roles for security
- Email action triggers for notifications

##### README
- Confirms purpose: on‐demand temporary admin access in ServiceNow.

a. Main components
- ServiceNow Platform (hosted instance)
- Custom Application “On-Demand-Admin-Access”
– Data Layer: x_snc_admin_temporary_access table & related dictionary entries
– UI Layer:
· Service Catalog Item (request form)
· Record producer/form sections & client scripts
· UI Policies & UI Policy Actions
– Orchestration Layer: Flow Designer flows (`sys_hub_flow_*`) & Hub Action Type Definitions
– Business Logic Layer: Script Includes (`sys_script_include_*`)
– Security Layer: Roles (sys_user_role_*), ACLs (`sys_security_acl_*`), Scope Privileges
– Notification Layer: Email Actions (`sysevent_email_action_*`)
- External Services
– Email server (SMTP)
– (Optional) Update‐set import/export via source control

b. Relationships & interactions
1. User → ServiceNow UI (Catalog request)
2. UI Policies & Client Scripts validate/modify form inputs
3. Upon submission, Flow Designer flow is triggered
4. Flow calls Script Includes to create a temporary grant record in x_snc_admin_temporary_access
5. Flow assigns a temporary role to the user, records start/end times
6. ACLs enforce access control on the record and on admin functionality
7. Email Action fires to notify approvers and the requester
8. At end time, a scheduled flow revokes the role

c. Architectural patterns & design principles
- Low-code MVC on ServiceNow
- Event-driven flows for orchestration
- Fine-grained ACLs for data security
- Separation of concerns: UI policies (view rules), Business logic in Flows & Script Includes (controllers), Data definitions in Dictionary (models)

d. Key technologies & frameworks
- ServiceNow Platform scoped application
- Service Catalog & Record Producers
- Flow Designer & Hub Actions
- UI Policies & Client Scripts (JavaScript)
- Script Includes (server-side JavaScript)
- ACLs & Role-based access control
- Email Notifications via ServiceNow mail API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["User"]:::external
    EmailServer["Email Server (SMTP)"]:::external

    subgraph "ServiceNow Platform"
        subgraph "UI Layer"
            UICI["Catalog Item: Request Admin Access"]:::ui
            UIForm["Record Producer / Form Sections"]:::ui
            UIPolicies["UI Policies & Client Scripts"]:::ui
        end

        subgraph "Orchestration Layer"
            FlowRequest["Flow: OnSubmit Catalog Request"]:::flow
            FlowRevoke["Scheduled Flow: Revoke Role"]:::flow
        end

        subgraph "Business Logic Layer"
            ScriptInclude["Script Include: Admin Access Manager"]:::logic
        end

        subgraph "Data Layer"
            Table["Table: x_snc_admin_temporary_access"]:::data
        end

        subgraph "Security Layer"
            Roles["Roles & Scope Privileges"]:::security
            ACLs["ACLs"]:::security
        end

        subgraph "Notification Layer"
            EmailAction["Email Actions"]:::notification
        end
    end

    %% Data Flows
    User -->|"requests via catalog"| UICI
    UICI -->|"validate / modify inputs"| UIPolicies
    UICI -->|"onSubmit trigger"| FlowRequest
    FlowRequest -->|"invoke business logic"| ScriptInclude
    ScriptInclude -->|"create record"| Table
    FlowRequest -->|"assign temporary role"| Roles
    FlowRequest -->|"trigger notification"| EmailAction
    Table -->|"enforced by"| ACLs
    Roles -->|"enforced by"| ACLs
    FlowRevoke -->|"revoke role"| Roles
    FlowRevoke -->|"scheduled by flow"| ScriptInclude
    EmailAction -->|"send email"| EmailServer

    %% Click Events - Data Layer
    click Table "https://github.com/imjaineel/on-demand-admin-access/blob/main/dictionary/x_snc_admin_temporary_access.xml"
    click Table "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_db_object_581a4b34c34152106a0cd4fc05013187.xml"
    click Table "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_dictionary_x_snc_admin_temporary_access_*.xml"
    click Table "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_dictionary_x_snc_admin_temporary_access_*.xml"

    %% Click Events - UI Layer
    click UICI "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sc_cat_item_catalog_*.xml"
    click UICI "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sc_cat_item_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/catalog_ui_policy_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/catalog_ui_policy_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/catalog_ui_policy_action_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/catalog_ui_policy_action_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/catalog_script_client_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_ui_form_sections_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_ui_section_*.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_ui_list_x_snc_admin_temporary_acess_null.xml"
    click UIPolicies "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_ui_list_x_snc_admin_temporary_access_null.xml"

    %% Click Events - Orchestration Layer
    click FlowRequest "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_hub_flow_91d8a598837826104cd2c900feaad3ee.xml"
    click FlowRequest "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_hub_flow_03d6add4837826104cd2c900feaad35a.xml"
    click FlowRequest "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_hub_flow_1cdfc86883f466104cd2c900feaad30e.xml"
    click FlowRequest "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_hub_flow_d2ecf87e83f71690827999c0deaad3f4.xml"
    click FlowRequest "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_hub_action_type_definition_5e25d97a83735690827999c0deaad38b.xml"

    %% Click Events - Business Logic Layer
    click ScriptInclude "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_script_include_0541c2be83379690827999c0deaad3e3.xml"

    %% Click Events - Security Layer
    click ACLs "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_security_acl_*.xml"
    click ACLs "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_security_acl_*.xml"
    click Roles "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_security_acl_role_*.xml"
    click Roles "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_user_role_*.xml"
    click Roles "https://github.com/imjaineel/on-demand-admin-access/blob/main/author_elective_update/sys_scope_privilege_*.xml"
    click Roles "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sys_scope_privilege_*.xml"

    %% Click Events - Notification Layer
    click EmailAction "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sysevent_email_action_2eb1319483b826104cd2c900feaad38b.xml"
    click EmailAction "https://github.com/imjaineel/on-demand-admin-access/blob/main/update/sysevent_email_action_e03f61d083b826104cd2c900feaad385.xml"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6,stroke-width:1px;
    classDef flow fill:#DFF2BF,stroke:#4F8A10,color:#4F8A10,stroke-width:1px;
    classDef data fill:#FFF2CC,stroke:#E69138,color:#E69138,stroke-width:1px;
    classDef logic fill:#F0F0F0,stroke:#555555,color:#555555,stroke-width:1px;
    classDef security fill:#FFE6CC,stroke:#CC5200,color:#CC5200,stroke-width:1px;
    classDef notification fill:#E6E6FA,stroke:#6A5ACD,color:#6A5ACD,stroke-width:1px;
    classDef external fill:#F2F2F2,stroke:#888888,color:#888888,stroke-width:1px,stroke-dasharray: 5 5;
    class User,EmailServer external
```
