How harmanjeet-kaur-3/smart-shop-ai works
Purpose and Runtime Entry Points
SmartShop AI is a full-stack product comparison application: users search and compare products, receive AI recommendations, and manage authentication and wishlists. The React/Vite client starts at src/main.tsx and renders application routing/UI from src/App.tsx. The Node/Express API is entered through server.ts.
Frontend Application Shell
The client is organized as route-level experiences backed by reusable product and recommendation UI:
• Product discovery/comparison: src/pages/Home.tsx, src/pages/Search.tsx, src/components/ProductCard.tsx
• Authenticated user areas: src/pages/Dashboard.tsx, src/pages/History.tsx, src/pages/Wishlist.tsx
• Authentication and input/upload flows: src/pages/Auth.tsx, src/pages/Upload.tsx
• Shared navigation and AI presentation: src/components/Navbar.tsx, src/components/AIRecommendation.tsx
Client-to-API Boundary
src/services/api.ts centralizes browser calls to the Express backend, while src/types.ts defines frontend domain contracts. UI pages invoke this service rather than directly coupling to server routes. The Vite runtime is configured by vite.config.ts; index.html is its document entry point.
HTTP API and Access Control
The Express server divides core capabilities into route modules:
• Identity/session endpoints: server/routes/auth.ts
• Product lookup and search orchestration: server/routes/search.ts
• Saved-product management: server/routes/wishlist.ts
• Usage or product analytics: server/routes/analytics.ts
Authentication enforcement is a middleware boundary in server/middleware/auth.ts, separating protected user data flows from public API behavior.
Product Enrichment and AI Pipeline
Search requests can cross two service boundaries: product acquisition/scraping in server/services/scraper.ts, then AI-driven comparison, specification analysis, or recommendations in server/services/ai.ts. The AI service is expected to use the externally configured Groq API via GROQ_API_KEY, despite the README’s earlier Gemini wording. Results are returned through API routes for rendering by src/components/AIRecommendation.tsx and product-oriented pages.
Persistence and Infrastructure
The application uses a local JSON-backed data store, represented by data/db.json and accessed through server/db.ts. This is the persistence boundary for user-associated state such as wishlists and potentially history/analytics; it is not a separately provisioned database service. Runtime infrastructure is TypeScript across client and server, React/Vite in the browser build path, and Node.js/Express for the API process.
Main entry points: search.ts API route modules · App.tsx App routing shell · Home.tsx Discovery & comparison · api.ts API client
Components 16
React/Vite Client
- Vite document entry
index.html - React bootstrap
src/main.tsx - App routing shell
src/App.tsx - Discovery & comparison · Home and search experiences render product comparisons.
src/pages/Home.tsx - Product card
src/components/ProductCard.tsx - User areas · Dashboard, history, and wishlist views.
src/pages/Dashboard.tsx - Auth & upload · Authentication and upload flows.
src/pages/Auth.tsx - API client · Centralizes browser calls to Express.
src/services/api.ts - AI recommendation UI
src/components/AIRecommendation.tsx
Express API
- Express server
server.ts - API route modules · Auth, search, wishlist, and analytics endpoints.
server/routes/search.ts - Access control · Protects user-associated API flows.
server/middleware/auth.ts - JSON store access
server/db.ts
Enrichment Services
- Product acquisition
server/services/scraper.ts - AI comparison service · Analyzes specifications and produces recommendations using GROQ_API_KEY.
server/services/ai.ts
Other components
- Local JSON store · Stores user-associated state such as wishlists and history.
data/db.json
Connections 18
- Vite document entry → React bootstrap: loads
- React bootstrap → App routing shell: renders
- App routing shell → Discovery & comparison: routes to
- App routing shell → User areas: routes to
- App routing shell → Auth & upload: routes to
- Discovery & comparison → Product card: renders
- Discovery & comparison → AI recommendation UI: presents AI results
- Discovery & comparison → API client: requests data
- User areas → API client: manages saved state
- Auth & upload → API client: submits
- API client → Express server: HTTP
- Express server → API route modules: mounts
- API route modules → Access control: protects user routes
- API route modules → Product acquisition: searches products
- Product acquisition → AI comparison service: supplies product data
- API route modules → AI comparison service: requests analysis
- API route modules → JSON store access: reads and writes state
- JSON store access → Local JSON store: persists