# santiagoqp23/restaurant-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/santiagoqp23/restaurant-web-app
- Repository: https://github.com/santiagoqp23/restaurant-web-app

## Overview

##### Project type and purpose
- This is a single-page application (SPA) implemented in React + TypeScript, built with Vite, and deployed as static assets (Netlify).
- Purpose: a full-featured restaurant management system (order taking, kitchen display, billing, menu management, reports, user & table management) that communicates with an external backend via REST and WebSockets.

##### File structure
- Top-level:
- public/: static assets (images, index.html)
- src/: all React code
- src/api/: Axios REST client + React Query setup
- src/context/, src/hooks/: cross-cutting concerns (SocketContext, MenuContext, custom hooks)
- src/redux/: Redux slices for auth, menu, orders, tables, users
- src/pages/: feature folders (Public/Auth/Shop, Private/Dashboard, Orders, Menu, Bills, Balance, Reports, etc.)
- src/components/ui: shared UI primitives
- src/theme, src/styles: theming & global styles
- config: .env, netlify.toml, tsconfig, vite.config.ts

##### README for additional insights
- It confirms core features: Dashboard, Orders, Kitchen view, Menu management, Tables, Users, Clients, Cash register, Reports.
- It does not ship its own backend—relies on a REST API (“restauranteApi.ts”) and WebSocket events for real-time updates.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Infrastructure"
        CDN["CDN / Netlify"]:::infra
    end

    subgraph "Client"
        Browser["Browser / React SPA"]:::infra
    end

    CDN -->|GET index.html & JS/CSS| Browser

    subgraph "SPA Bootstrap"
        Main["src/main.tsx"]:::infra
        App["src/App.tsx"]:::infra
    end

    Browser --> Main --> App

    subgraph "Presentation Layer"
        UIP["UI Primitives"]:::ui
        Pages["Feature Pages"]:::ui
    end

    App --> UIP
    App --> Pages

    subgraph "State Management"
        Query["React Query\n(src/api/query-client.ts)"]:::state
        ReduxStore["Redux Store\n(src/redux/store.ts)"]:::state
        Slices["Redux Slices\n(src/redux/slices/)"]:::state
        MenuCtx["MenuContext"]:::state
        SocketCtx["SocketContext"]:::state
    end

    UIP --> Query
    Pages --> ReduxStore
    Pages --> MenuCtx
    Pages --> SocketCtx
    Query --> API
    ReduxStore --> API
    MenuCtx --> API
    SocketCtx --> RealTime

    subgraph "Data Access"
        API["Axios REST Client\n(src/api/restauranteApi.ts)"]:::network
        APIIndex["src/api/index.ts"]:::network
    end

    APIIndex --> API

    subgraph "Real-time Client"
        UseSocket["useSocket.ts"]:::state
        UseEmit["useEmitWebSocketsEvent.ts"]:::state
        UseOn["useOnWebSocketsEvent.ts"]:::state
    end

    SocketCtx --> UseSocket
    SocketCtx --> UseEmit
    SocketCtx --> UseOn
    UseSocket --> WS
    UseOn --> WS
    UseEmit --> WS

    subgraph "PDF Generation Helpers"
        BillPdf["generateBillPdf.helper.ts"]:::util
        CashPdf["pdf-cash-report.ts"]:::util
        OrdersPdf["pdf-orders.ts"]:::util
        InvPdf["generateInvoicePdf.helper.ts"]:::util
    end

    Pages --> BillPdf
    Pages --> CashPdf
    Pages --> OrdersPdf
    Pages --> InvPdf

    subgraph "Theming & Routing"
        Theme["ThemeProvider.tsx"]:::util
        Styles["global-styles.css"]:::util
        AppRouter["AppRouter.tsx"]:::util
        PublicRouter["Public.router.tsx"]:::util
        PrivateRouter["private.router.tsx"]:::util
    end

    App --> Theme
    App --> Styles
    App --> AppRouter
    AppRouter --> PublicRouter
    AppRouter --> PrivateRouter

    subgraph "External Services"
        REST["REST API"]:::external
        WS["WebSocket Server"]:::external
    end

    API -->|HTTP| REST

    classDef infra fill:#d3d3d3,stroke:#333;
    classDef ui fill:#9fdfbf,stroke:#333;
    classDef state fill:#add8e6,stroke:#333;
    classDef network fill:#ffe599,stroke:#333;
    classDef util fill:#d5a6bd,stroke:#333;
    classDef external fill:#f4cccc,stroke:#333;

    click CDN "https://github.com/santiagoqp23/restaurant-web-app/blob/main/netlify.toml"
    click Main "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/main.tsx"
    click App "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/App.tsx"
    click UIP "https://github.com/santiagoqp23/restaurant-web-app/tree/main/src/components/ui/"
    click Pages "https://github.com/santiagoqp23/restaurant-web-app/tree/main/src/pages/"
    click Query "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/api/query-client.ts"
    click ReduxStore "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/redux/store.ts"
    click Slices "https://github.com/santiagoqp23/restaurant-web-app/tree/main/src/redux/slices/"
    click MenuCtx "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/context/MenuContext.tsx"
    click SocketCtx "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/context/SocketContext.tsx"
    click UseSocket "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/hooks/useSocket.ts"
    click UseEmit "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/hooks/useEmitWebSocketsEvent.ts"
    click UseOn "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/hooks/useOnWebSocketsEvent.ts"
    click API "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/api/restauranteApi.ts"
    click APIIndex "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/api/index.ts"
    click BillPdf "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Private/Bills/views/Bill/generateBillPdf.helper.ts"
    click CashPdf "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Private/Balance/helpers/pdf-cash-report.ts"
    click OrdersPdf "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Private/Orders/helpers/pdf-orders.ts"
    click InvPdf "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Private/Invoices/helpers/generateInvoicePdf.helper.ts"
    click Theme "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/theme/ThemeProvider.tsx"
    click Styles "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/styles/global-styles.css"
    click AppRouter "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/routers/AppRouter.tsx"
    click PublicRouter "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Public/router/Public.router.tsx"
    click PrivateRouter "https://github.com/santiagoqp23/restaurant-web-app/blob/main/src/pages/Private/router/private.router.tsx"
```
