How afnan006/qr-agent1 works
Project type and purpose
• QR Agent is a full-stack-style single-page application (SPA) focusing on the front end. It’s built with React 18/TypeScript, Vite, and Tailwind CSS.
• Purpose: a multi-role restaurant management system (Customer, Kitchen, Org Admin, Super Admin) that consumes external REST APIs, handles JWT authentication, payment gateways, and real-time order/inventory workflows.
Main Components
A. Client Application
• Vite Development Server & Build Pipeline
– Vite (dev server + HMR) → build → static assets
• Static Asset Server
– Docker + Nginx serving /index.html & JS/CSS bundles
• React App
– App.tsx → Router → Role‐specific sub-apps
· Customer module (/customer)
· Kitchen module (/kitchen)
· OrgAdmin module (/orgadmin)
· SuperAdmin module (/superadmin)
– Shared layers: Context Providers (Auth, Cart, Chat, KitchenContext), Shared Utils, Styling (Tailwind, PostCSS)
B. Backend & External Services
• Primary REST API (VITE_API_BASE_URL) – Authentication, Orders, Menu, Tables
• Kitchen-specific API (VITE_KITCHEN_API_URL) – Inventory, Recipes, Order Status
• Payment Gateway – External URL for processing payments
• JWT Service – Token issuance & decode on client
C. Developer Workflow & CI/CD (optional/high-level)
• GitHub → CI pipeline → Docker build → Production registry → Kubernetes/Nginx
Relationships & Data Flow
• Browser → Nginx (serves static bundle)
• React Router directs to role path → Component Tree → Context Providers
• UI Components call API client modules (customerApi.jsx, kitchenApi.js, etc.)
• HTTP(S) requests → Primary API or Kitchen API
• Payment → Payment Gateway endpoint
• Responses update Context → UI re-renders
• JWT stored in localStorage per role → Attached to Authorization header
• Shared utilities (e.g. LoadingSpinner, delay) used across modules
Architectural Patterns & Design Principles
• Component-based UI segregation by role (modular, pluggable)
• Context API for global state (Auth, Cart, Chat, Kitchen)
• API abstraction layer per role
• CSS utility-first (Tailwind) + CSS modules for theming
• Build separation: development (Vite) vs. production (Docker + Nginx)
• Role-based routing for access control
Technologies & Libraries to annotate
• Frontend: React 18, TypeScript 5, Vite 5, Tailwind 3.4, PostCSS
• State + APIs: React Context, Fetch/axios (in api/*), JWT-Decode
• UI libs: Framer Motion, Lucide React, Chart.js, jsPDF, html2canvas
• Testing: Jest, Testing Library
• Deployment: Docker, Nginx