How bhavdiya/dynamic-mart works
Project type and purpose
• price-pilot-commerce is a front-end single-page e-commerce “demo” application.
• Built with Vite, React, TypeScript, Tailwind CSS, and shadcn-ui.
• It renders product listings, pricing dashboards, shopping cart flows and uses a local pricing engine and mock data.
File structure
• Top level:
• index.html, Vite + Tailwind + TS configs, package.json
• public/robots.txt (static assets)
• src/:
• main.tsx, App.tsx, index.css – entry point and global styles
• components/:
– pages-level (PricingDashboard.tsx, ShoppingCart.tsx, ProductCard.tsx)
– ui/ – shadcn-ui primitives (button, dialog, table, etc.)
• pages/ (Index.tsx, NotFound.tsx) – route targets
• services/pricingEngine.ts – core business logic (pricing calculations)
• data/mockProducts.ts – local data store
• hooks/ – custom React hooks (useMobile, useToast)
• lib/utils.ts, types/ – utility and type definitions
• No backend folder: entirely client-side.
README for insights
• Confirms tech stack and that it is a Vite + React demo.
• No mention of external APIs or runtime services—uses mock data.
Main components & interactions
a. Browser / Client
• Hosts the SPA
• Executes bundled JS/CSS
b. Vite Dev Server / Build Pipeline
• Transpiles TSX → JS, processes Tailwind CSS, bundles assets
• Outputs static files for deployment
c. React Application
• App Shell (App.tsx → Routes in pages/)
• UI Layer (shadcn-ui components)
• Feature Components (ProductCard, ShoppingCart, PricingDashboard)
d. Business Logic Layer
• pricingEngine.ts (calculates discounts, totals, promotions)
• utils.ts (helper functions)
e. Data Layer
• mockProducts.ts (in-memory product definitions)
• types/index.ts (domain models)
f. Custom Hooks
• useMobile.tsx (responsive logic)
• useToast.ts (notification system tied to UI primitives)
g. (Optional) Deployment / CDN
• Static host (Netlify / Vercel / S3+CloudFront) serving index.html + assets
Relationships & data flow
• User interacts in Browser → React Components
• Components call custom hooks (e.g., useMobile, useToast)
• Components fetch from Data Layer (mockProducts) or call Business Logic Layer (pricingEngine)
• pricingEngine returns calculated values → Components render updated UI
• All UI primitives come from shadcn-ui (imported under components/ui/)
• During dev: file changes → Vite dev server hot-reloads in Browser
Architectural patterns & design principles
• Component-based architecture (React)
• Separation of concerns:
• UI primitives vs. feature components vs. page routes
• Business logic in services/pricingEngine.ts
• Data storage in data/mockProducts.ts
• Single Source of Truth for data (mockProducts + React state)
• Hook abstraction for cross-cutting concerns (responsive design, toasts)
Technologies & frameworks
• Vite (dev server & bundler)
• React + TypeScript
• Tailwind CSS
• shadcn-ui (prebuilt component library)
• No external API—mock data