# wagnetto/restaurant-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/wagnetto/restaurant-dashboard
- Repository: https://github.com/wagnetto/restaurant-dashboard

## Overview

##### Project type and purpose
- This is a single-page, full-stack-ready dashboard application for restaurant order management.
- The front end is built with React (Vite), TypeScript, Tailwind CSS, Shadcn-ui and uses TanStack Query for data fetching.
- It supports two backend modes:
- Mock mode via MSW (no external API needed)
- Real mode pointing to a NodeJS/Express API (with a backing database)

##### File structure
- Top-level artifacts:
- package.json, pnpm-lock.yaml, Vite/Tailwind/ESLint/Prettier configs
- public/: static assets + MSW service worker
- src/: application code
- “src/api/…”: one file per endpoint & a parallel mocks folder for MSW handlers
- “src/lib/axios.ts” + “src/lib/react-query.ts”: shared HTTP client & React Query setup
- “src/components/…”: presentational and compound components (UI primitives vs dashboards vs dialogs)
- “src/pages/…”: routed pages organized under “auth” and “app” layouts
- test/ & playwright.config.ts: E2E and integration tests

##### README for additional insights
- Key features: profile management, order status flows, metrics (daily/monthly revenue, canceled orders, popular products)
- Technical goals: simulating HTTP calls with MSW, complex state with React Query, form validation with Zod & React Hook Form
- Two run modes: `dev:test` (MSW) vs `dev` (real API)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Browser / Client"
        style Browser fill:#E0F2FE,stroke:#0284C7
        Browser["User"]:::user
        ReactSPA["React SPA<br>(src/main.tsx,<br>src/app.tsx,<br>index.html)"]:::client
        Routing["Client-Side Routing<br>(src/routes.tsx)"]:::client
        subgraph "Components"
            direction TB
            CompAll["Presentational & Compound Components<br>(src/components/)"]:::client
            CompUI["UI Primitives<br>(src/components/ui/)"]:::client
            CompTheme["Theme Components<br>(src/components/theme/)"]:::client
        end
        subgraph "Pages & Layouts"
            direction TB
            AuthLayout["Auth Layout<br>(src/pages/_layouts/auth.tsx)"]:::client
            AppLayout["App Layout<br>(src/pages/_layouts/app.tsx)"]:::client
            AuthPages["Auth Pages<br>(src/pages/auth/)"]:::client
            AppPages["App Pages<br>(src/pages/app/)"]:::client
            Page404["404 Page<br>(src/pages/404.tsx)"]:::client
            PageError["Error Page<br>(src/pages/error.tsx)"]:::client
        end
    end

    %% State/Query Layer
    ReactQuery["React Query Setup<br>(src/lib/react-query.ts)"]:::state
    Axios["Axios HTTP Client<br>(src/lib/axios.ts)"]:::state

    %% Env Config
    Env["Environment Config<br>(.env.development,<br>.env.test,<br>src/env.ts)"]:::env

    %% API Layer
    subgraph "API Layer"
        style API fill:#FEF3C7,stroke:#F59E0B
        subgraph "Mock API (MSW)"
            direction TB
            MSWWorker["MSW Service Worker<br>(public/mockServiceWorker.js)"]:::api
            MSWIndex["Mock Handlers Index<br>(src/api/mocks/index.ts)"]:::api
        end
        subgraph "Real API (NodeJS/Express)"
            direction TB
            RealAPI["Real API Endpoints<br>(src/api/sign-in.ts, …)"]:::api
        end
    end

    %% Data Layer
    Database["Database (PostgreSQL)"]:::data

    %% Flows
    Browser -->|"uses"| ReactSPA
    ReactSPA -->|routes via| Routing
    Routing -->|renders| CompAll
    CompAll --> CompUI
    CompAll --> CompTheme
    CompAll --> AuthLayout
    CompAll --> AppLayout
    AuthLayout --> AuthPages
    AppLayout --> AppPages
    AuthPages --> Page404
    AppPages --> PageError

    CompAll -->|"queries/mutations"| ReactQuery
    ReactQuery -->|"calls"| Axios

    Env -->|"selects mode"| Axios

    Axios -->|"if MOCK_MODE"| MSWWorker
    MSWWorker --> MSWIndex
    MSWIndex --> ReactQuery

    Axios -->|"if REAL_MODE"| RealAPI
    RealAPI --> Database
    Database --> RealAPI
    RealAPI --> ReactQuery

    %% Click Events
    click ReactSPA "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/main.tsx"
    click Routing "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/routes.tsx"
    click CompAll "https://github.com/wagnetto/restaurant-dashboard/tree/main/src/components/"
    click CompUI "https://github.com/wagnetto/restaurant-dashboard/tree/main/src/components/ui/"
    click CompTheme "https://github.com/wagnetto/restaurant-dashboard/tree/main/src/components/theme/"
    click AuthLayout "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/pages/_layouts/auth.tsx"
    click AppLayout "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/pages/_layouts/app.tsx"
    click AuthPages "https://github.com/wagnetto/restaurant-dashboard/tree/main/src/pages/auth/"
    click AppPages "https://github.com/wagnetto/restaurant-dashboard/tree/main/src/pages/app/"
    click Page404 "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/pages/404.tsx"
    click PageError "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/pages/error.tsx"
    click ReactQuery "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/lib/react-query.ts"
    click Axios "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/lib/axios.ts"
    click MSWWorker "https://github.com/wagnetto/restaurant-dashboard/blob/main/public/mockServiceWorker.js"
    click MSWIndex "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/api/mocks/index.ts"
    click RealAPI "https://github.com/wagnetto/restaurant-dashboard/blob/main/src/api/sign-in.ts"

    %% Styles
    classDef client fill:#DBEAFE,stroke:#1E40AF,color:#1E40AF
    classDef state fill:#DCFCE7,stroke:#16A34A,color:#166534
    classDef api fill:#FEF3C7,stroke:#F59E0B,color:#B45309
    classDef data fill:#F3F4F6,stroke:#6B7280,color:#4B5563
    classDef env fill:#F5F3FF,stroke:#7C3AED,color:#5B21B6
    classDef user fill:#FFFFFF,stroke:#000000,color:#000000,stroke-dasharray: 5 5
```
