How sushant-poudel-dev/scrapvisualizer works
1. Project shape
- This is a Next.js App Router application written in TypeScript.
- The repo is split into three clear layers: UI components, server-side scraping/API logic, and shared types/styling.
2. Primary user-facing surface
- app/page.tsx is the main dashboard entry point.
- It renders the quote browsing experience: search, filtering, pagination, quote cards, and theme-aware UI.
3. Client-side presentation layer
- app/components/QuoteCard.tsx handles how individual quotes are displayed, including truncated/expanded presentation and copy-to-clipboard behavior.
- app/components/SearchFilter.tsx owns the filtering controls used to narrow quotes by text, author, or tags.
- These components are the core interaction layer and are responsible for fast in-browser updates.
4. Theme and UI state boundary
- app/components/ThemeProvider.tsx is the theme boundary for dark/light mode.
- app/layout.tsx wraps the app with global providers and shared page structure.
- Styling is driven by app/globals.css plus Tailwind/PostCSS config, with theme switching implemented through CSS variables and the .dark class.
5. Scraping/data acquisition backend
- app/api/scrape/route.ts exposes the server API endpoint that fetches quote data.
- It delegates the actual browser automation and extraction work to lib/scraper.ts.
- This is the main backend boundary: the client never scrapes directly; it calls the API route instead.
6. External dependency and authentication
- The scraper depends on environment variables defined outside the codebase: SCRAPE_URL, SCRAPE_USERNAME, and SCRAPE_PASSWORD.
- The external quote website is the system’s real upstream data source; authentication and page traversal happen there via Playwright.
7. Data flow
- Flow is: browser UI → /api/scrape → Playwright scraper → external quote site → parsed quote objects → UI rendering.
- The response appears to be a collection of quotes with associated metadata such as author and tags, which then feeds filtering and pagination in the client.
8. Shared data model
- types/index.ts centralizes the quote-related TypeScript types used across the API, scraper, and UI.
- This keeps the server extraction format aligned with what the frontend expects to render and filter.
9. Interaction and performance model
- The README indicates client-side interaction uses React hooks such as useState, useMemo, useCallback, and useDeferredValue.
- That means filtering/searching is designed to stay responsive in the browser rather than re-querying the server on every keystroke.
10. App-level resilience
- app/loading.tsx, app/error.tsx, and app/not-found.tsx provide route-level UX for loading, runtime errors, and missing routes.
- These are part of the Next.js runtime boundary and are important when drawing the request/response and failure paths.
11. Runtime/tooling
- The stack is Next.js 16, React, Tailwind CSS, and Playwright.
- next.config.ts, eslint.config.mjs, postcss.config.mjs, and tsconfig.json support build-time concerns rather than runtime architecture, but they reinforce that this is a modern React SSR/route-handler app.
12. Architecture summary
- The system is essentially a quote ingestion and display pipeline:
- a server-side scraper collects data from a protected upstream site,
- an API route exposes that data to the app,
- the client renders, searches, filters, paginates, and copies quotes locally,
- theming and layout are shared across the entire experience.
Main entry points: page.tsx Dashboard · layout.tsx App shell · index.ts Quote types · route.ts Scrape API
Components 16
UI layer
App Router shell and client-side quote browsing experience.
- Dashboard · Main quote browsing entry point with search, filters, pagination, and cards.
app/page.tsx - Quote card · Renders individual quotes with expand/collapse and copy-to-clipboard behavior.
app/components/QuoteCard.tsx - Search filter · Text, author, and tag filtering controls for narrowing visible quotes.
app/components/SearchFilter.tsx - Theme provider · Provides dark/light theme state for the app.
app/components/ThemeProvider.tsx - App shell · Global layout wrapper that wires providers and shared structure.
app/layout.tsx - Loading · Route-level loading UI.
app/loading.tsx - Error · Route-level runtime error UI.
app/error.tsx - Not found · Route-level missing page UI.
app/not-found.tsx
Data layer
Server route and scraper that acquire quote data from the upstream site.
- Scrape API · Server endpoint that exposes scraped quote data to the app.
app/api/scrape/route.ts - Scraper · Automates browsing, authentication, and extraction from the upstream quote site.
lib/scraper.ts - Quote site · Protected upstream website that provides the quote data.
Shared
Types and styling used across the app.
- Quote types · Shared quote data model used by the scraper, API, and UI.
types/index.ts - Global styles · Base styling, CSS variables, and theme classes.
app/globals.css - Next config · Next.js build/runtime configuration.
next.config.ts - PostCSS config · Tailwind/PostCSS processing configuration.
postcss.config.mjs - TS config · TypeScript compiler configuration.
tsconfig.json
Connections 20
- App shell → Theme provider: wraps · Layout establishes the theme boundary for the app.
- App shell → Dashboard: renders · Shared shell surrounds the main dashboard route.
- Dashboard → Search filter: uses · Dashboard delegates filtering controls to the search component.
- Dashboard → Quote card: renders · Dashboard displays results as individual quote cards.
- Dashboard → Scrape API: requests · Browser UI loads quote data through the API route.
- Search filter → Dashboard: updates · Filter state narrows the visible quote set in the page.
- Quote card → Dashboard: interacts · Card actions affect how quotes are presented in the dashboard.
- Scrape API → Scraper: delegates · Route handler offloads browser automation and extraction.
- Scraper → Quote site: scrapes · Playwright authenticates and traverses the external quote site.
- Scraper → Quote types: emits · Scraped records are shaped to the shared quote model.
- Scrape API → Quote types: returns · API response uses the shared quote type contract.
- Dashboard → Quote types: consumes · UI expects the same quote structure for rendering and filtering.
- Theme provider → Global styles: drives · Theme state is expressed through CSS variables and dark class styles.
- App shell → Global styles: includes · Global styles apply across the entire application shell.
- Next config → App shell: supports · Build/runtime configuration supports the app router setup.
- PostCSS config → Global styles: processes · PostCSS/Tailwind pipeline compiles the global stylesheet.
- TS config → Quote types: types · TypeScript configuration supports the shared type system.
- Dashboard → Loading: fallback · Loading state covers the dashboard during route/data work.
- Dashboard → Error: fallback · Error state covers runtime failures in the route.
- Dashboard → Not found: fallback · Not-found state handles missing routes in the app shell.