{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "initial_id",
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    ""
   ]
  },
  {
   "metadata": {
    "jupyter": {
     "is_executing": true
    }
   },
   "cell_type": "code",
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.patches as patches\n",
    "\n",
    "def draw_box(x, y, text, width=3.5, height=1.5, color=\"#cce5ff\"):\n",
    "    rect = patches.FancyBboxPatch((x, y), width, height, boxstyle=\"round,pad=0.02\", \n",
    "                                  edgecolor=\"black\", facecolor=color, linewidth=1.5)\n",
    "    plt.gca().add_patch(rect)\n",
    "    plt.text(x + width/2, y + height/2, text, ha='center', va='center', fontsize=10, wrap=True)\n",
    "\n",
    "def draw_arrow(x1, y1, x2, y2):\n",
    "    plt.gca().annotate('', xy=(x2, y2), xytext=(x1, y1),\n",
    "                       arrowprops=dict(facecolor='black', shrink=0.05, width=1.5, headwidth=8))\n",
    "\n",
    "plt.figure(figsize=(16, 10))\n",
    "plt.xlim(0, 16)\n",
    "plt.ylim(0, 14)\n",
    "plt.axis('off')\n",
    "\n",
    "draw_box(6, 12, \"Identity (User: Alice)\", color=\"#ffeeba\")\n",
    "draw_box(6, 10, \"IdentityStandardRole\\n→ StandardRole\", color=\"#d4edda\")\n",
    "draw_box(6, 8, \"StandardRoleType (read-only)\\n→ ResourceType (EMPLOYEES)\", color=\"#d4edda\")\n",
    "draw_box(6, 6, \"ResourceAction\\n(read, create, etc.)\", color=\"#f8d7da\")\n",
    "draw_box(2, 6, \"ActionInclusion\\n(delete → update, read)\", color=\"#f8d7da\")\n",
    "draw_box(10, 6, \"ResourceType\\n(parent-child hierarchy)\", color=\"#f8d7da\")\n",
    "draw_box(6, 4, \"Resolved: IdentityResourceAction\", color=\"#c3e6cb\")\n",
    "draw_box(6, 2, \"Access Check:\\nGET /employee-service/employees → read?\", color=\"#bee5eb\")\n",
    "draw_box(6, 0.5, \"✅ Access GRANTED\", color=\"#c3e6cb\")\n",
    "\n",
    "draw_arrow(8, 12, 8, 11.5)\n",
    "draw_arrow(8, 10, 8, 9.5)\n",
    "draw_arrow(8, 8, 8, 7.5)\n",
    "draw_arrow(8, 6, 8, 5.5)\n",
    "draw_arrow(8, 4, 8, 3.5)\n",
    "draw_arrow(8, 2, 8, 1.5)\n",
    "\n",
    "draw_arrow(6, 6.75, 3.5, 6.75)  # to ActionInclusion\n",
    "draw_arrow(9.5, 6.75, 10.5, 6.75)  # to ResourceType hierarchy\n",
    "\n",
    "plt.title(\"🔐 User-to-Resource Access Flow\", fontsize=14, weight='bold', pad=20)\n",
    "plt.tight_layout()\n",
    "plt.show()\n"
   ],
   "id": "6f623d114870667e",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "1f62901246fe265e"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
