# amar2kk/dar-al-bashir-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/amar2kk/dar-al-bashir-dashboard
- Repository: https://github.com/amar2kk/dar-al-bashir-dashboard

## Overview

##### Main System Components

A. Frontend Layer
- Client-Side Components
- Server Components (Next.js App Router)
- Authentication Layer
- Theme/UI Components

B. API Layer
- REST API Routes
- Store Management
- Product Management
- Order Management
- Billboard/Category Management

C. Database Layer
- Prisma ORM
- Database Tables/Relations

##### Key Architectural Elements to Highlight

a) App Router Structure:
- (auth) routes for authentication
- (dashboard) routes for store management
- (root) routes for main application
- Dynamic routes with [storeId] parameter

b) Feature Modules:
- Products
- Orders
- Billboards
- Categories
- Types
- Settings

c) Shared Components:
- UI Components
- Modals
- Providers
- Hooks

**┌─────────────────────────────────────────────────────────┐**
- Client Browser Layer                    │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Next.js Frontend Layer                  │
- ┬─────────────────┬────────────────────┤
- Auth Routes   │ Dashboard Routes │    Root Routes     │
- ┴─────────────────┴────────────────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- API Layer                           │
- ┬──────────┬──────────┬──────────┬───────────┤
- Stores  │ Products │  Orders  │Categories│Billboards  │
- ┴──────────┴──────────┴──────────┴───────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Database Layer                        │
- ┤
- Prisma ORM                          │
- ┘

##### Important Relationships

- Authentication flow between auth routes and API
- Dashboard routes interaction with API endpoints
- API routes connection to Prisma ORM
- Store-specific route parameters and their relationship to data access
- Component relationships within the dashboard features

##### Additional Elements

Supporting components:
- Modal providers
- Theme providers
- Toast notifications
- Hooks and utilities
- Shared UI components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Browser"]
        Browser["Web Browser"]:::client
    end

    subgraph Frontend["Frontend Layer"]
        Auth["Authentication Layer"]:::auth
        Dashboard["Dashboard Interface"]:::frontend
        MainNav["Main Navigation"]:::frontend
        Navbar["Navigation Bar"]:::frontend
        StoreSwitcher["Store Switcher"]:::frontend
        ThemeToggle["Theme Toggle"]:::frontend
        UIComponents["UI Components"]:::frontend
    end

    subgraph API["API Layer"]
        StoreAPI["Store API"]:::api
        ProductAPI["Product API"]:::api
        OrderAPI["Order API"]:::api
        BillboardAPI["Billboard API"]:::api
        CategoryAPI["Category API"]:::api
    end

    subgraph Database["Database Layer"]
        PrismaORM["Prisma ORM"]:::database
        DBSchema["Database Schema"]:::database
    end

    subgraph Providers["System Providers"]
        ModalProvider["Modal Provider"]:::provider
        ThemeProvider["Theme Provider"]:::provider
    end

    subgraph Analytics["Analytics Actions"]
        Revenue["Revenue Analytics"]:::analytics
        Sales["Sales Analytics"]:::analytics
        Stock["Stock Analytics"]:::analytics
    end

    Browser --> Auth
    Browser --> Dashboard
    
    Dashboard --> MainNav
    Dashboard --> Navbar
    Dashboard --> StoreSwitcher
    Dashboard --> ThemeToggle
    Dashboard --> UIComponents
    
    Auth --> StoreAPI
    Dashboard --> StoreAPI
    Dashboard --> ProductAPI
    Dashboard --> OrderAPI
    Dashboard --> BillboardAPI
    Dashboard --> CategoryAPI
    
    StoreAPI --> PrismaORM
    ProductAPI --> PrismaORM
    OrderAPI --> PrismaORM
    BillboardAPI --> PrismaORM
    CategoryAPI --> PrismaORM
    
    PrismaORM --> DBSchema
    
    Dashboard --> ModalProvider
    Dashboard --> ThemeProvider
    
    Dashboard --> Revenue
    Dashboard --> Sales
    Dashboard --> Stock

    %% Click Events
    click Auth "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/(auth)/(routes)"
    click Dashboard "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/(dashboard)/[storeId]/(routes)"
    click StoreAPI "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/api/stores"
    click ProductAPI "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/api/[storeId]/products"
    click OrderAPI "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/api/[storeId]/order"
    click BillboardAPI "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/api/[storeId]/billboards"
    click CategoryAPI "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/app/api/[storeId]/categories"
    click PrismaORM "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/lib/prismaDB.ts"
    click DBSchema "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/prisma/schema.prisma"
    click UIComponents "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/tree/main/components/ui"
    click ModalProvider "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/providers/modal-provider.tsx"
    click ThemeProvider "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/providers/theme-provider.tsx"
    click ThemeToggle "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/components/theme-toggle.tsx"
    click Revenue "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/actions/get-total-revenue.ts"
    click Sales "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/actions/get-sales-count.ts"
    click Stock "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/actions/get-stock-count.ts"
    click MainNav "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/components/main-nav.tsx"
    click Navbar "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/components/navbar.tsx"
    click StoreSwitcher "https://github.com/Amar2Kk/Dar-Al-Bashir-dashboard/blob/main/components/store-switcher.tsx"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#69c,stroke:#333,stroke-width:1px
    classDef auth fill:#b0f,stroke:#333,stroke-width:1px
    classDef api fill:#3b3,stroke:#333,stroke-width:1px
    classDef database fill:#f90,stroke:#333,stroke-width:1px
    classDef provider fill:#999,stroke:#333,stroke-width:1px
    classDef analytics fill:#39f,stroke:#333,stroke-width:1px
```
