How gustavomorinaga/copyscotch works
Project type and purpose
• This is “Copyscotch,” a SvelteKit–based reimplementation of an API‐request builder (Hoppscotch).
• It’s a full‑stack web application (SSR + client) that allows users to construct, send, and view HTTP requests/responses to arbitrary external APIs.
File structure
• Top‑level:
• src/routes → SvelteKit pages and layouts (UI entry points, error pages).
• src/lib → Shared code (components, features, contexts, repositories, schemas, utils).
• src/server → SvelteKit server hooks and utilities (minification).
• service-worker.ts → PWA support / offline caching.
• Everything under src/lib/components is a UI component library (shadcn‑svelte + custom infra).
• src/lib/features/rest & settings & support hold the core domain logic and feature‑specific components and views.
• src/lib/functions (export, fetcher) encapsulate cross‑cutting logic.
• src/lib/repositories contain the HTTP request abstractions.
• No external database: it’s purely client‑driven state (contexts + localStorage / file export).
README for additional insights
• Tech stack: SvelteKit 1.0 (SSR + CSR), TypeScript, TailwindCSS, PostCSS & CSSnano, Zod + Superforms for validation, shadcn‑svelte UI primitives.
• Purpose: demo learning SvelteKit while mimicking Hoppscotch’s functionality.
Main components & interactions
a. Components
• Browser (Client)
– UI Shell (SvelteKit client hydration)
– Service Worker
– Feature Modules (REST builder, Settings, Support)
– Component Library (ui/, infra/, metadata/, mode/screen watchers)
• SvelteKit Server (Node)
– SSR Engine (renders + serves HTML)
– Server Hooks & Utilities (minify hook, fetcher function)
• Static Asset Server
– Static/: images, manifest, robots.txt
• External APIs
– Target HTTP endpoints under user control (the ones the user wants to test)
b. Relationships & Data Flow
1. Client requests a page → hits SvelteKit server SSR → returns HTML + hydration script.
2. Client hydrates, loads component library.
3. User composes a request in UI → repository.fetcher calls browser fetch → goes to External API → response flows back to UI.
4. Export feature: client triggers export.function → triggers browser download (no server round‑trip).
5. Service Worker: intercepts navigations/static assets for caching/offline.
c. Architectural patterns
• Monorepo‑style grouping under src/lib by domain (components, features, contexts, repositories, schemas, utils).
• Feature‑driven folders for REST, settings, support.
• MVC‑like separation:
• Views = src/lib/features/*/views
• Controllers/State = contexts & repositories & superforms
• Models = Zod schemas in src/lib/schemas
• Server‑side hooks for build‑time minification.
d. Key technologies
• SvelteKit: SSR + routing (src/routes) + server hooks
• TypeScript (tsconfig.json)
• Tailwind/PostCSS/CSSnano (tailwind.config.js + postcss.config.js)
• Vite (vite.config.js)
• Superforms & Zod (form validation)
• Shadcn‑svelte (UI components)