How akash-design-prog/dice-simulator works
1. Repository shape
- This is a monorepo with two runtime boundaries: a Node/Express backend in backend/ and a React/Vite frontend in frontend/.
- Root-level vercel.json ties them together for deployment, serving the frontend build and routing API requests to the backend.
2. Primary architecture
- The product is a browser-based dice simulator.
- The frontend owns the visual experience and user interaction.
- The backend owns the source of randomness, which the README explicitly positions as the trust boundary for “server-side truth.”
3. Backend subsystem
- backend/server.js is the server entrypoint.
- It is a lightweight Node.js/Express service whose main architectural role is to produce dice results that cannot be tampered with in the browser.
- There is no database or long-lived persistence in the current tree, so the backend appears stateless.
4. Frontend application
- frontend/src/ contains the React app.
- App.jsx is the top-level UI/scene composition layer; main.jsx mounts it into the page.
- The frontend is built with Vite and styled with Tailwind CSS, with local CSS files for app-specific layout and polish.
5. 3D rendering and simulation boundary
- The README says the dice are rendered with Three.js / React Three Fiber.
- That means the dice animation and scene lighting are fully client-side WebGL concerns, separate from the server’s randomness logic.
- The backend does not render graphics; it only supplies the roll outcome that the client then visualizes.
6. Roll flow
- User interaction starts in the browser.
- The frontend requests a new roll from the backend.
- The backend returns the result.
- The frontend uses that result to drive the 3D animation and final face selection, creating the “fair roll” experience.
7. Visual and material system
- The README describes dynamic face textures generated with HTML5 Canvas, so dice faces are created at runtime rather than shipped as many static image assets.
- The dice appearance uses meshStandardMaterial with tuned roughness/metalness, and scene lighting is handled in the frontend to create the acrylic/polished look.
- This is a client-only rendering concern and does not affect the backend.
8. Audio asset path
- frontend/public/sounds_roll.ogg is a browser-delivered asset used for roll sound effects.
- Because it lives under public/, it is served statically by the frontend build and consumed directly by the UI during the roll interaction.
9. Build and tooling boundaries
- The frontend uses Vite for development and production bundling.
- Tailwind config, PostCSS config, and ESLint config indicate the frontend has its own build/tooling stack independent of the backend.
- The backend has its own package.json and lockfile, so it is separately installable and runnable.
10. Deployment model
- vercel.json suggests a deployment where the frontend is built to static files and the backend is exposed as serverless/route-backed Node code.
- This matters architecturally because the same repo contains both a static SPA and an API service, but they are deployed through different Vercel targets.
11. State and future expansion
- The current system is intentionally minimal: no visible storage layer, auth layer, or analytics pipeline.
- The TODO in the README mentions future MongoDB support for global statistics, which would add a new persistence subsystem if implemented.
- For now, the architecture is best understood as stateless API + client-side simulation.
12. How to diagram it
- Draw two main boxes: Browser frontend and Node backend.
- Inside the browser box, separate React UI, Three.js/WebGL scene, and static assets/audio.
- Between browser and backend, show a roll request / random result flow.
- Around both, note the Vercel monorepo deployment boundary that serves the SPA and routes API traffic.
Main entry points: App.jsx App UI · package.json Frontend pkg · server.js API server · vercel.json Vercel config
Components 14
Deployment
Repo-level Vercel routing and build boundary
- Vercel config · Routes the frontend build and API traffic for deployment
vercel.json - Root package · Top-level package entry for repo-wide install and orchestration
package.json
Backend
Stateless Node/Express roll service
- Backend pkg · Backend dependency boundary and runtime packaging
backend/package.json - API server · Node/Express entrypoint that returns tamper-resistant roll results
backend/server.js
Browser App
React, WebGL, and static assets in the client
- Frontend pkg · Frontend dependency boundary and build packaging
frontend/package.json - Vite build · Development server and production bundling for the SPA
frontend/vite.config.js - Tailwind · Utility styling pipeline for the frontend
frontend/tailwind.config.js - Index page · Static HTML entry used by the Vite app
frontend/index.html - App mount · Mounts the React application into the page
frontend/src/main.jsx - App UI · Top-level UI composition and roll interaction flow
frontend/src/App.jsx - 3D scene · Client-side dice animation, lighting, and face selection
frontend/src/App.jsx - App styles · App-specific layout and polish styles
frontend/src/App.css - Base styles · Global frontend styling foundation
frontend/src/index.css - Roll sound · Browser-delivered roll audio used during interaction
frontend/public/sounds_roll.ogg
Connections 16
- Root package → Backend pkg: workspace install · Repo-level package management includes the backend runtime
- Root package → Frontend pkg: workspace install · Repo-level package management includes the frontend runtime
- Vercel config → Frontend pkg: serve SPA · Deployment serves the frontend build as the browser entry
- Vercel config → API server: route API · Deployment forwards API requests to the backend service
- Backend pkg → API server: runtime · Backend package defines the Express server runtime
- Frontend pkg → Vite build: builds with · Frontend uses Vite for dev and production bundling
- Frontend pkg → Tailwind: styles with · Frontend styling pipeline is driven by Tailwind
- Frontend pkg → Index page: shell · The SPA is bootstrapped from the HTML entry page
- Index page → App mount: loads · The index page loads the React entrypoint
- App mount → App UI: mounts · React entry mounts the top-level application
- App UI → 3D scene: renders · App composition drives the 3D dice experience
- App UI → App styles: uses · App-specific CSS shapes the UI layout
- App UI → Base styles: inherits · Global base styles support the application shell
- App UI → Roll sound: plays · Roll interaction uses the browser audio asset
- App UI → API server: requests roll · Frontend asks the backend for the authoritative dice result
- API server → 3D scene: returns result · Backend roll output drives the client-side animation and final face