-
Notifications
You must be signed in to change notification settings - Fork 0
Frontend Guide
t957095 edited this page Jun 15, 2026
·
1 revision
The ShelfWise frontend is a vanilla JavaScript single-page application. It is intentionally dependency-free to keep the bundle small and the runtime predictable.
frontend/
├── index.html # App shell
├── app.js # Application logic
├── styles.css # Dark theme and responsive layout
└── sw.js # Service worker for offline caching
- Accessibility first: WCAG 2.1 AA compliant.
- No build step: plain HTML, CSS, and ES modules are not required.
- Responsive: works on desktop, tablet, and mobile.
- Offline capable: service worker caches static assets.
- UPC textarea (one per line)
- CSV file input
- Process UPCs, Load Demo, Upload CSV, and Clear buttons
- Live progress bar
- Counts: total, queued, running, completed, failed
- SSE connection status indicator
- Sort by confidence, name, brand, or category
- Search/filter by keyword
- Product cards showing image, name, brand, category, confidence badge, and citations
- View Trace: opens a modal with the step-by-step reasoning trace.
- View Image: opens a lightbox.
- Buttons for CSV, JSON, Shopify, Amazon, WooCommerce, eBay, Etsy, BigCommerce.
- Portfolio totals, confidence distribution, top brands, top categories.
app.js keeps state in a simple object:
const state = {
products: [],
jobId: null,
eventSource: null,
sortKey: 'confidence',
sortDir: 'desc',
searchQuery: ''
};The frontend connects to /api/jobs/{job_id}/stream to receive live updates:
const es = new EventSource(`/api/jobs/${jobId}/stream`);
es.onmessage = (event) => {
const update = JSON.parse(event.data);
updateProgress(update);
if (update.completed + update.failed === update.total) {
es.close();
loadProducts();
}
};| Shortcut | Action |
|---|---|
Ctrl/Cmd + Enter |
Submit UPCs |
/ |
Focus search |
Esc |
Close modals / lightbox |
- Skip link to main content
- Semantic HTML (
header,main,section,button) - ARIA labels on icon buttons
- Focus-visible outlines
- Screen-reader announcements for job status
-
prefers-reduced-motionrespected -
prefers-contrast: moresupported
CSS custom properties are defined in :root at the top of styles.css:
:root {
--bg: #0f172a;
--surface: #1e293b;
--primary: #38bdf8;
--text: #f8fafc;
--muted: #94a3b8;
}Change these values to retheme the app.
sw.js caches static assets and API GET responses. It is installed automatically on first load.
To force an update:
navigator.serviceWorker.getRegistrations().then(rs => rs.forEach(r => r.unregister()));- Add a button in
index.html. - Add a click handler in
app.jscallingPOST /api/exportwith the new format. - Add the format implementation in
backend/main.py.
- Ensure the backend includes the field in
ConsolidatedProduct. - Update
renderProductCard()inapp.js. - Style the new element in
styles.css.
ShelfWise — AI Product Portfolio Builder · GitHub · MIT License
- Home
- Getting Started
- Use Cases
- Roadmap
- Architecture
- API Reference
- Configuration
- Backend Guide
- Frontend Guide
- Scraping & Reasoning
- Testing
- Deployment
- Changelog
Quick Start
docker-compose up --build
# open http://localhost:8000/app