How marcoscarvalhodev/saporediluce works
Project type and purpose
• This is a client-only React + TypeScript web application, built with Vite, that provides an interactive 3D restaurant simulation in the browser.
• It uses a Canvas/WebGL scene (via libraries like React-Three-Fiber), React Context for state management, and static assets (3D models, audio) served from the public folder.
File structure
• Top level:
• public/ — all .glb models, textures, audio files, environment HDR
• src/ — React application source, subdivided by feature (AccessButtons, AudioManagement, CameraManagement, ModelsManagement, RestaurantMenu, RestaurantOverlays, RestaurantWaitress, ReviewsCustomers, TableCustomers)
• src/context/ — global state providers (AnimationsContext, AudioChoiceContext, ButtonsContext, etc.)
• src/helpers/ — pure functions and reducers (buttonsReducer)
• CanvasContainer.tsx, main.tsx — bootstrap and root scene container
• Configs: vite.config.ts, tsconfig*.json, eslint.config.js
README for additional insights
• The README is the standard React+TS+Vite template description (HMR, ESLint recommendations), confirming the tech stack but not prescribing architecture.
• Browser / User Interface
• Vite Dev/Prod Server (static hosting)
• React Application
– Root Mount (index.html → main.tsx)
– CanvasContainer (sets up WebGL canvas and providers)
– Context Providers (AnimationsContext, AudioChoiceContext, ButtonsContext, CameraMovementContext, FoodContext, HumansContext, OverlaysContext)
– Feature Components (AccessButtons, CameraManagement, ModelsManagement, RestaurantMenu, RestaurantOverlays, RestaurantWaitress, ReviewsCustomers, TableCustomers)
• Asset Loader / Static Assets (public folder: .glb, audio, textures)
• External Libraries (React, React-Three-Fiber, Drei/GLTFLoader, Web Audio API, ESLint)
– Browser GETs index.html from Vite → main.tsx mounts React tree
– CanvasContainer initializes WebGL scene → wraps Context Providers
– Context Providers supply global state → consumed by Feature Components
– Feature Components dispatch actions (e.g. button click → ButtonsContext → triggers OverlaysContext + AudioChoiceContext + AnimationsContext)
– ModelsManagement uses GLTFLoader to pull .glb files from public → adds meshes to scene graph
– AudioManagement plays sounds via Web Audio API based on AudioChoiceContext
– CameraManagement updates camera parameters in Three.js scene
c. Architectural patterns & principles:
– Component-based UI (React)
– Unidirectional data flow via React Context (Flux-like)
– Scene Graph pattern for 3D (WebGL/Three.js)
– Separation of concerns: static asset hosting, state management, presentation, side effects
d. Key technologies & frameworks:
– React 18, TypeScript, Vite (bundler/dev server)
– React-Three-Fiber (Three.js in React) & @react-three/drei (GLTFLoader)
– Web Audio API for sound effects
– ESLint for code quality