How inkithai/pizza-billing-app works
Project Type and Purpose
• This is a full‐stack web application (“Pizza Billing Application”) for managing menu items and customer invoices for a pizza shop.
• Frontend: React-based SPA running on Node.js (port 3000).
• Backend: RESTful API server in Go (Gin or net/http) running on port 8080.
• Database: MySQL (database name: pizza_billing), accessed via Go’s database driver.
Key Architectural Components
a. Presentation Layer (Frontend)
• Browser / User
• React SPA (frontend/src):
• Components: Navbar, Welcome, ItemManagement, InvoiceManagement, InvoicePrint
• Third-party libs: react-to-print for invoice printing
• Static assets (frontend/public)
b. API Layer (Backend)
• HTTP Server (backend/main.go)
• Middleware (CORS handler in backend/middleware/cors.go)
• Routing (backend/routes/routes.go)
• Controllers (backend/controllers): invoice_controller.go, item_controller.go
• Models (backend/models): invoice.go, item.go
• Config (backend/config/db.go): MySQL connection setup
c. Data Layer
• MySQL database (“pizza_billing”)
• Tables: items, invoices (implied by models)
d. External Systems
• MySQL server (XAMPP stack)
• Printer (via browser’s print dialog triggered by react-to-print)
Interactions and Data Flow
• User interacts with the React UI in the browser.
• React app issues HTTP(S) requests to the Go API endpoints:
• /items (GET, POST), /items/{id} (GET, PUT, DELETE)
• /invoices (GET, POST), /invoices/{id} (GET, DELETE)
• API middleware handles CORS, then routes requests to controllers.
• Controllers invoke model methods to perform SQL queries.
• Models communicate with the MySQL database and return data or status.
• API serializes responses (JSON) back to the React app.
• For printing, the InvoicePrint component uses react-to-print to open the browser’s print dialog.
Architectural Patterns and Principles
• Layered (n-tier) architecture: Presentation → API/Business → Data
• MVC-style separation in backend: routes → controllers → models
• Single-Page Application pattern in frontend
• RESTful API design for CRUD operations
• CORS middleware to allow cross‐origin calls (frontend ↔ backend)
a. Components / Containers
• Browser / User
• React SPA (Node.js container)
• Go API Server (Go runtime container)
• MySQL Database
• Printer (external)
b. Relationships / Data Flows
c. Technologies & Frameworks
• Frontend: React, Node.js, react-to-print
• Backend: Go (go.mod), net/http or Gin, MySQL driver
• Database: MySQL (XAMPP)
d. Detailed Backend Sub‐components
• Middleware layer (CORS)
• Routing layer → controller functions
• Data access layer (models, config/db.go)