# sushant-poudel-dev/scrapvisualizer architecture

> Architecture diagram of the GitHub repository sushant-poudel-dev/scrapvisualizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushant-poudel-dev/scrapvisualizer
- Repository: https://github.com/sushant-poudel-dev/scrapvisualizer

## Overview

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: [`app/page.tsx`](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/page.tsx) (Dashboard), [`app/layout.tsx`](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/layout.tsx) (App shell), [`types/index.ts`](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/types/index.ts) (Quote types), [`app/api/scrape/route.ts`](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/api/scrape/route.ts) (Scrape API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI layer"]
  node_app_page["Dashboard<br/>Next page<br/>[page.tsx]"]
  node_quote_card["Quote card<br/>Client component<br/>[QuoteCard.tsx]"]
  node_search_filter["Search filter<br/>Client component<br/>[SearchFilter.tsx]"]
  node_theme_provider["Theme provider<br/>Client boundary<br/>[ThemeProvider.tsx]"]
  node_app_layout["App shell<br/>Next layout<br/>[layout.tsx]"]
  node_app_loading["Loading<br/>Route state<br/>[loading.tsx]"]
  node_app_error["Error<br/>Route state<br/>[error.tsx]"]
  node_app_not_found["Not found<br/>Route state<br/>[not-found.tsx]"]
end

subgraph group_server["Data layer"]
  node_scrape_route["Scrape API<br/>Route handler<br/>[route.ts]"]
  node_scraper["Scraper<br/>Playwright backend<br/>[scraper.ts]"]
  node_upstream_site[("Quote site<br/>External source")]
end

subgraph group_shared["Shared"]
  node_quote_types["Quote types<br/>Type definitions<br/>[index.ts]"]
  node_globals_css["Global styles<br/>Stylesheet<br/>[globals.css]"]
  node_next_config["Next config<br/>Build config<br/>[next.config.ts]"]
  node_postcss_config["PostCSS config<br/>Build config<br/>[postcss.config.mjs]"]
  node_tsconfig["TS config<br/>Build config<br/>[tsconfig.json]"]
end

node_app_layout -->|"wraps"| node_theme_provider
node_app_layout -->|"renders"| node_app_page
node_app_page -->|"uses"| node_search_filter
node_app_page -->|"renders"| node_quote_card
node_app_page -->|"requests"| node_scrape_route
node_search_filter -->|"updates"| node_app_page
node_quote_card -->|"interacts"| node_app_page
node_scrape_route -->|"delegates"| node_scraper
node_scraper -->|"scrapes"| node_upstream_site
node_scraper -->|"emits"| node_quote_types
node_scrape_route -->|"returns"| node_quote_types
node_app_page -->|"consumes"| node_quote_types
node_theme_provider -->|"drives"| node_globals_css
node_app_layout -->|"includes"| node_globals_css
node_next_config -.->|"supports"| node_app_layout
node_postcss_config -.->|"processes"| node_globals_css
node_tsconfig -.->|"types"| node_quote_types
node_app_page -->|"fallback"| node_app_loading
node_app_page -->|"fallback"| node_app_error
node_app_page -->|"fallback"| node_app_not_found

click node_app_page "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/page.tsx"
click node_quote_card "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/QuoteCard.tsx"
click node_search_filter "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/SearchFilter.tsx"
click node_theme_provider "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/ThemeProvider.tsx"
click node_app_layout "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/layout.tsx"
click node_app_loading "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/loading.tsx"
click node_app_error "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/error.tsx"
click node_app_not_found "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/not-found.tsx"
click node_scrape_route "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/api/scrape/route.ts"
click node_scraper "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/lib/scraper.ts"
click node_quote_types "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/types/index.ts"
click node_globals_css "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/globals.css"
click node_next_config "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/next.config.ts"
click node_postcss_config "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/postcss.config.mjs"
click node_tsconfig "https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/tsconfig.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_page,node_quote_card,node_search_filter,node_theme_provider,node_app_layout,node_app_loading,node_app_error,node_app_not_found toneBlue
class node_scrape_route,node_scraper,node_upstream_site toneAmber
class node_quote_types,node_globals_css,node_next_config,node_postcss_config,node_tsconfig toneMint
```

## Components

### UI layer

App Router shell and client-side quote browsing experience.

- [Dashboard](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/page.tsx): Next page · Main quote browsing entry point with search, filters, pagination, and cards. · `app/page.tsx`
- [Quote card](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/QuoteCard.tsx): Client component · Renders individual quotes with expand/collapse and copy-to-clipboard behavior. · `app/components/QuoteCard.tsx`
- [Search filter](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/SearchFilter.tsx): Client component · Text, author, and tag filtering controls for narrowing visible quotes. · `app/components/SearchFilter.tsx`
- [Theme provider](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/components/ThemeProvider.tsx): Client boundary · Provides dark/light theme state for the app. · `app/components/ThemeProvider.tsx`
- [App shell](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/layout.tsx): Next layout · Global layout wrapper that wires providers and shared structure. · `app/layout.tsx`
- [Loading](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/loading.tsx): Route state · Route-level loading UI. · `app/loading.tsx`
- [Error](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/error.tsx): Route state · Route-level runtime error UI. · `app/error.tsx`
- [Not found](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/not-found.tsx): Route state · 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](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/api/scrape/route.ts): Route handler · Server endpoint that exposes scraped quote data to the app. · `app/api/scrape/route.ts`
- [Scraper](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/lib/scraper.ts): Playwright backend · Automates browsing, authentication, and extraction from the upstream quote site. · `lib/scraper.ts`
- **Quote site**: External source · Protected upstream website that provides the quote data.

### Shared

Types and styling used across the app.

- [Quote types](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/types/index.ts): Type definitions · Shared quote data model used by the scraper, API, and UI. · `types/index.ts`
- [Global styles](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/app/globals.css): Stylesheet · Base styling, CSS variables, and theme classes. · `app/globals.css`
- [Next config](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/next.config.ts): Build config · Next.js build/runtime configuration. · `next.config.ts`
- [PostCSS config](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/postcss.config.mjs): Build config · Tailwind/PostCSS processing configuration. · `postcss.config.mjs`
- [TS config](https://github.com/sushant-poudel-dev/scrapvisualizer/blob/main/tsconfig.json): Build config · TypeScript compiler configuration. · `tsconfig.json`

## Connections

- 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.
