# youssef-atef-20/abonagy-admin-dashboard architecture

> Architecture diagram of the GitHub repository youssef-atef-20/abonagy-admin-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/youssef-atef-20/abonagy-admin-dashboard
- Repository: https://github.com/youssef-atef-20/abonagy-admin-dashboard

## Overview

Abu Nagy Admin Dashboard is a private, Arabic-first menu-management application. An admin enters credentials on the login page; the auth context invokes the admin-auth Edge Function, establishes a Supabase session, and loads the user profile and permissions. Protected routes then lead to dashboard, category, product, variant, admin-management, and audit-log screens, which manage or display the restaurant’s data. The README documents these product capabilities and the Supabase schema. Some page-to-service and persistence wiring is not shown in excerpts, so uncertain links are omitted or marked unverified.

Main entry points: [`admin-dashboard/src/App.tsx`](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/App.tsx) (App routes), [`admin-dashboard/src/contexts/AuthContext.tsx`](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/contexts/AuthContext.tsx) (Auth context), [`admin-dashboard/src/lib/supabase.ts`](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/lib/supabase.ts) (Supabase client), [`admin-dashboard/src/components/ui`](https://github.com/youssef-atef-20/abonagy-admin-dashboard/tree/main/admin-dashboard/src/components/ui) (UI components)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Dashboard app"]
  node_routes["App routes<br/>[App.tsx]"]
  node_layout["Dashboard shell"]
  node_theme["Theme state<br/>[ThemeContext.tsx]"]
  node_ui["UI components"]
end

subgraph group_access["Identity and access"]
  node_login["Login screen<br/>[LoginPage.tsx]"]
  node_auth["Auth context<br/>[AuthContext.tsx]"]
  node_guard["Permission guards<br/>[ProtectedRoute.tsx]"]
  node_authfn["Admin auth function<br/>[index.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

subgraph group_menu["Menu management"]
  node_dashboard["Overview<br/>[DashboardPage.tsx]"]
  node_categories["Category management<br/>[CategoriesPage.tsx]"]
  node_category_data["Category service<br/>[categories.ts]"]
  node_products["Product management<br/>[ProductsPage.tsx]"]
  node_product_data["Product service<br/>[products.ts]"]
  node_variants["Variant pricing<br/>[VariantsPage.tsx]"]
  node_variant_data["Variant service<br/>[variants.ts]"]
end

subgraph group_oversight["Administration"]
  node_admins["Admin accounts<br/>[AdminsPage.tsx]"]
  node_admin_data["Admin service<br/>[admins.ts]"]
  node_audit["Audit history<br/>[AuditLogsPage.tsx]"]
  node_permissions["Permission controls"]
  node_audit_store[("Audit log migration")]
end

node_operator(("Restaurant admin"))
node_supabase_service[("Supabase platform")]

node_operator -->|"enters credentials"| node_login
node_operator -.->|"manages menu"| node_layout
node_routes -->|"routes to"| node_login
node_routes -->|"routes to"| node_dashboard
node_routes -->|"routes to"| node_categories
node_routes -->|"routes to"| node_products
node_routes -->|"routes to"| node_variants
node_routes -->|"routes to"| node_admins
node_routes -->|"routes to"| node_audit
node_routes -->|"provides auth"| node_auth
node_routes -->|"provides theme"| node_theme
node_routes -->|"protects routes"| node_guard
node_layout -.->|"presents controls"| node_operator
node_login -.->|"submits credentials"| node_auth
node_auth -->|"invokes login"| node_authfn
node_auth -->|"sets session"| node_supabase
node_auth -->|"loads profile and permissions"| node_supabase_service
node_authfn -.->|"authenticates user"| node_supabase_service
node_guard -->|"checks access"| node_auth
node_categories -.->|"uses service"| node_category_data
node_products -.->|"uses service"| node_product_data
node_variants -.->|"uses service"| node_variant_data
node_admins -->|"uses service"| node_admin_data
node_category_data -.->|"accesses client"| node_supabase
node_product_data -.->|"accesses client"| node_supabase
node_variant_data -.->|"accesses client"| node_supabase
node_admin_data -->|"accesses client"| node_supabase
node_dashboard -.->|"reads summary"| node_supabase
node_audit -.->|"reads audit records"| node_supabase_service
node_audit_store -.->|"defines audit system"| node_supabase_service
node_categories -->|"renders controls"| node_ui
node_products -->|"renders controls"| node_ui
node_variants -->|"renders controls"| node_ui
node_admins -->|"edits permissions"| node_permissions
node_audit -->|"renders records"| node_ui

click node_routes "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/App.tsx"
click node_layout "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/layouts/DashboardLayout.tsx"
click node_theme "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/contexts/ThemeContext.tsx"
click node_ui "https://github.com/youssef-atef-20/abonagy-admin-dashboard/tree/main/admin-dashboard/src/components/ui"
click node_login "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/LoginPage.tsx"
click node_auth "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/contexts/AuthContext.tsx"
click node_guard "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/components/auth/ProtectedRoute.tsx"
click node_authfn "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/supabase/functions/admin-auth/index.ts"
click node_supabase "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/lib/supabase.ts"
click node_dashboard "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/DashboardPage.tsx"
click node_categories "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/CategoriesPage.tsx"
click node_category_data "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/categories.ts"
click node_products "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/ProductsPage.tsx"
click node_product_data "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/products.ts"
click node_variants "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/VariantsPage.tsx"
click node_variant_data "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/variants.ts"
click node_admins "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/AdminsPage.tsx"
click node_admin_data "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/admins.ts"
click node_audit "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/AuditLogsPage.tsx"
click node_permissions "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/components/permissions/PermissionsChecker.tsx"
click node_audit_store "https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/supabase/migrations/audit_logs_system.sql"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_layout,node_theme,node_ui toneBlue
class node_login,node_auth,node_guard,node_authfn,node_supabase,node_supabase_service toneAmber
class node_dashboard,node_categories,node_category_data,node_products,node_product_data,node_variants,node_variant_data toneMint
class node_admins,node_admin_data,node_audit,node_permissions,node_audit_store toneRose
class node_operator toneIndigo
```

## Components

### Dashboard app

- [App routes](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/App.tsx): `admin-dashboard/src/App.tsx`
- [Dashboard shell](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/layouts/DashboardLayout.tsx): `admin-dashboard/src/layouts/DashboardLayout.tsx`
- [Theme state](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/contexts/ThemeContext.tsx): `admin-dashboard/src/contexts/ThemeContext.tsx`
- [UI components](https://github.com/youssef-atef-20/abonagy-admin-dashboard/tree/main/admin-dashboard/src/components/ui): `admin-dashboard/src/components/ui`

### Identity and access

- [Login screen](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/LoginPage.tsx): `admin-dashboard/src/pages/LoginPage.tsx`
- [Auth context](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/contexts/AuthContext.tsx): `admin-dashboard/src/contexts/AuthContext.tsx`
- [Permission guards](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/components/auth/ProtectedRoute.tsx): `admin-dashboard/src/components/auth/ProtectedRoute.tsx`
- [Admin auth function](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/supabase/functions/admin-auth/index.ts): `supabase/functions/admin-auth/index.ts`
- [Supabase client](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/lib/supabase.ts): `admin-dashboard/src/lib/supabase.ts`

### Menu management

- [Overview](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/DashboardPage.tsx): `admin-dashboard/src/pages/DashboardPage.tsx`
- [Category management](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/CategoriesPage.tsx): `admin-dashboard/src/pages/CategoriesPage.tsx`
- [Category service](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/categories.ts): `admin-dashboard/src/services/categories.ts`
- [Product management](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/ProductsPage.tsx): `admin-dashboard/src/pages/ProductsPage.tsx`
- [Product service](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/products.ts): `admin-dashboard/src/services/products.ts`
- [Variant pricing](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/VariantsPage.tsx): `admin-dashboard/src/pages/VariantsPage.tsx`
- [Variant service](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/variants.ts): `admin-dashboard/src/services/variants.ts`

### Administration

- [Admin accounts](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/AdminsPage.tsx): `admin-dashboard/src/pages/AdminsPage.tsx`
- [Admin service](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/services/admins.ts): `admin-dashboard/src/services/admins.ts`
- [Audit history](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/pages/AuditLogsPage.tsx): `admin-dashboard/src/pages/AuditLogsPage.tsx`
- [Permission controls](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/admin-dashboard/src/components/permissions/PermissionsChecker.tsx): `admin-dashboard/src/components/permissions/PermissionsChecker.tsx`
- [Audit log migration](https://github.com/youssef-atef-20/abonagy-admin-dashboard/blob/main/supabase/migrations/audit_logs_system.sql): `supabase/migrations/audit_logs_system.sql`

### Other components

- **Restaurant admin**
- **Supabase platform**

## Connections

- Restaurant admin → Login screen: enters credentials (evidence: `README.md`)
- Restaurant admin → Dashboard shell: manages menu (evidence: `README.md`)
- App routes → Login screen: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Overview: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Category management: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Product management: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Variant pricing: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Admin accounts: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Audit history: routes to (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Auth context: provides auth (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Theme state: provides theme (evidence: `admin-dashboard/src/App.tsx`)
- App routes → Permission guards: protects routes (evidence: `admin-dashboard/src/App.tsx`)
- Dashboard shell → Restaurant admin: presents controls (evidence: `README.md`)
- Login screen → Auth context: submits credentials (evidence: `admin-dashboard/src/pages/LoginPage.tsx`)
- Auth context → Admin auth function: invokes login (evidence: `admin-dashboard/src/contexts/AuthContext.tsx`)
- Auth context → Supabase client: sets session (evidence: `admin-dashboard/src/contexts/AuthContext.tsx`)
- Auth context → Supabase platform: loads profile and permissions (evidence: `README.md`)
- Admin auth function → Supabase platform: authenticates user (evidence: `README.md`)
- Permission guards → Auth context: checks access (evidence: `admin-dashboard/src/components/auth/ProtectedRoute.tsx`)
- Category management → Category service: uses service (evidence: `admin-dashboard/src/pages/CategoriesPage.tsx`)
- Product management → Product service: uses service (evidence: `admin-dashboard/src/pages/ProductsPage.tsx`)
- Variant pricing → Variant service: uses service (evidence: `admin-dashboard/src/pages/VariantsPage.tsx`)
- Admin accounts → Admin service: uses service (evidence: `admin-dashboard/src/pages/AdminsPage.tsx`)
- Category service → Supabase client: accesses client (evidence: `admin-dashboard/src/services/categories.ts`)
- Product service → Supabase client: accesses client (evidence: `admin-dashboard/src/services/products.ts`)
- Variant service → Supabase client: accesses client (evidence: `admin-dashboard/src/services/variants.ts`)
- Admin service → Supabase client: accesses client (evidence: `admin-dashboard/src/services/admins.ts`)
- Overview → Supabase client: reads summary (evidence: `admin-dashboard/src/pages/DashboardPage.tsx`)
- Audit history → Supabase platform: reads audit records (evidence: `README.md`)
- Audit log migration → Supabase platform: defines audit system
- Category management → UI components: renders controls (evidence: `admin-dashboard/src/pages/CategoriesPage.tsx`)
- Product management → UI components: renders controls (evidence: `admin-dashboard/src/pages/ProductsPage.tsx`)
- Variant pricing → UI components: renders controls (evidence: `admin-dashboard/src/pages/VariantsPage.tsx`)
- Admin accounts → Permission controls: edits permissions (evidence: `admin-dashboard/src/pages/AdminsPage.tsx`)
- Audit history → UI components: renders records (evidence: `admin-dashboard/src/pages/AuditLogsPage.tsx`)
