# miguelloaizadev/gestion-restaurante architecture

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

- Interactive diagram: https://gitdiagram.com/miguelloaizadev/gestion-restaurante
- Repository: https://github.com/miguelloaizadev/gestion-restaurante

## Overview

A. Project Type and Purpose
##### This is a full-stack, single-page web application (SPA) for restaurant management.
- Frontend: React 18 + Vite + Bootstrap, deployed via Firebase Hosting.
- Backend: Node.js (Express) serving a RESTful API, with JSON files as the data store.

B. File-Structure Analysis

##### Architectural Patterns & Conventions
- SPA routing → React Router Dom in src/pages/ → each page handles a domain: Inventory, Orders, Reports.
- Reusable UI → src/components/ (modals, panels, tables).
- Data-flow: components → pages → API clients → backend endpoints.
- Backend: minimal MVC—Express “controllers” in index.js reading/writing JSON.

##### Main Components
1. User & Browser (Client)
2. React/Vite Dev Server (during development)
3. Firebase Hosting (production static‐asset hosting)
4. REST API Server (Node.js + Express)
5. JSON Files (Data Store)
6. (Optional) CI/CD Pipeline (npm scripts, firebase deploy)

##### Relationships & Data Flows
- User→Browser: clicks UI.
- Browser→Frontend App: React Router navigates between pages.
- Frontend→API Server: HTTP REST calls (GET /products, POST /pedidos, GET /reportes, etc.).
- API Server→File Store: read/write JSON files (ingredientes.json, pedidos.json, movimientos_inventario.json, etc.).
- Build & Deploy: Vite build → Firebase CLI → Firebase Hosting.

##### Architectural Patterns
- SPA with Client-side Routing (React Router).
- RESTful API layer (Express endpoints) separate from UI.
- File-based persistence (JSON) as a simple NoSQL store (no external DB).
- Modular UI (components/pages), separation of concerns.
- Monorepo with clearly separated frontend/backend.

##### Call Out Key Technologies & Frameworks
Backend: Node.js, Express (in index.js), file-system module (fs) for JSON manipulation, npm scripts.
Hosting/Deployment: Firebase Hosting, firebase.json/.firebaserc.

##### Use two main horizontal tiers
Tier 1 (Client): Browser & Static Hosting
Tier 2 (Server): API Server & Data Store

E. Diagramming Guidelines
##### Components & Labels
- Rectangles for Frontend and Backend services.

##### Sketch the top-level view
[User/Browser] → [React SPA (Firebase Hosting)] → [Express API Server] → [JSON Data Store]
- src/pages (InventoryPanel, BillingModal, Reports)
- src/components (TableCard, NavigationBar)
##### A side-note on deployment
Vite (build) → firebase.json → Firebase Hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Side"
        User(["User"]):::external
        Browser(["Browser"]):::external
        ReactSPA["React SPA"]:::frontend
        subgraph "React SPA Modules"
            EntryMain["main.jsx"]:::frontend
            AppJS["App.jsx"]:::frontend
            ViteConfig["vite.config.js"]:::frontend
            subgraph "Firebase Config"
                FirebaseJSON["firebase.json"]:::frontend
                Firebaserc[".firebaserc"]:::frontend
                FirebaseDir[".firebase/"]:::frontend
            end
            subgraph "Public Assets"
                IndexHTML["index.html"]:::frontend
                NotFoundHTML["404.html"]:::frontend
                PublicDir["public/"]:::frontend
            end
            subgraph "Global Styles"
                IndexCSS["index.css"]:::frontend
                AppCSS["App.css"]:::frontend
                VarsCSS["variables.css"]:::frontend
            end
            subgraph "Components"
                BillingModal["BillingModal.jsx"]:::frontend
                InventoryPanel["InventoryPanel.jsx"]:::frontend
                NavigationBar["NavigationBar.jsx"]:::frontend
                PedidoDetailModal["PedidoDetailModal.jsx"]:::frontend
                Summary["Summary.jsx"]:::frontend
                TableCard["TableCard.jsx"]:::frontend
                TableListRow["TableListRow.jsx"]:::frontend
                TableModal["TableModal.jsx"]:::frontend
            end
            subgraph "Pages"
                Home["Home.jsx"]:::frontend
                ShowInventory["ShowInventory.jsx"]:::frontend
                ViewOrders["ViewOrders.jsx"]:::frontend
                ReportsPage["Reports.jsx"]:::frontend
                CuadreCaja["CuadreCaja.jsx"]:::frontend
                EnterProducts["EnterProducts.jsx"]:::frontend
                EnterIngredients["EnterIngredients.jsx"]:::frontend
                EnterGrains["EnterGrains.jsx"]:::frontend
                EnterInputs["EnterInputs.jsx"]:::frontend
                EnterCrockery["EnterCrockery.jsx"]:::frontend
            end
        end
    end

    subgraph "Build & Deploy"
        Build["Vite Build"]:::external
        FirebaseHost(["Firebase Hosting"]):::external
    end

    subgraph "Server Side"
        APIServer["Express API Server"]:::server
        subgraph "API Internals"
            IndexJS["index.js"]:::server
            PackageBackend["package.json"]:::server
            Scripts["Insert Scripts"]:::server
            subgraph "Data Store"
                DataStore["JSON Data Store"]:::datastore
            end
        end
    end

    User -->|"uses"| Browser
    Browser -->|"loads SPA"| ReactSPA
    ReactSPA -->|"GET /products\nPOST /pedidos\nGET /reportes"| APIServer
    APIServer -->|"read/write JSON files"| DataStore
    ReactSPA -.->|"npm run build"| Build
    Build -.->|"firebase deploy"| FirebaseHost
    FirebaseHost -->|"serves static assets"| Browser

    click ReactSPA "https://github.com/miguelloaizadev/gestion-restaurante/tree/main/frontend/"
    click EntryMain "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/main.jsx"
    click AppJS "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/App.jsx"
    click ViteConfig "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/vite.config.js"
    click FirebaseJSON "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/firebase.json"
    click Firebaserc "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/.firebaserc"
    click FirebaseDir "https://github.com/miguelloaizadev/gestion-restaurante/tree/main/frontend/.firebase/"
    click IndexHTML "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/index.html"
    click NotFoundHTML "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/404.html"
    click PublicDir "https://github.com/miguelloaizadev/gestion-restaurante/tree/main/frontend/public/"
    click IndexCSS "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/index.css"
    click AppCSS "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/App.css"
    click VarsCSS "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/styles/variables.css"
    click BillingModal "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/BillingModal.jsx"
    click InventoryPanel "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/InventoryPanel.jsx"
    click NavigationBar "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/NavigationBar.jsx"
    click PedidoDetailModal "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/PedidoDetailModal.jsx"
    click Summary "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/Summary.jsx"
    click TableCard "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/TableCard.jsx"
    click TableListRow "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/TableListRow.jsx"
    click TableModal "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/components/TableModal.jsx"
    click Home "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/Home.jsx"
    click ShowInventory "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/ShowInventory.jsx"
    click ViewOrders "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/ViewOrders.jsx"
    click ReportsPage "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/Reports.jsx"
    click CuadreCaja "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/CuadreCaja.jsx"
    click EnterProducts "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/EnterProducts.jsx"
    click EnterIngredients "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/EnterIngredients.jsx"
    click EnterGrains "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/EnterGrains.jsx"
    click EnterInputs "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/EnterInputs.jsx"
    click EnterCrockery "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/frontend/src/pages/EnterCrockery.jsx"
    click IndexJS "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/backend/index.js"
    click PackageBackend "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/backend/package.json"
    click DataStore "https://github.com/miguelloaizadev/gestion-restaurante/tree/main/backend/"
    click Scripts "https://github.com/miguelloaizadev/gestion-restaurante/blob/main/backend/insertIngredientes.js"

    classDef frontend fill:#cce5ff,stroke:#004085
    classDef server fill:#d4edda,stroke:#155724
    classDef datastore fill:#e2e3e5,stroke:#6c757d
    classDef external fill:#fff3cd,stroke:#856404
```
