How hsu022210/snippets-frontend works
Project Type and Purpose
• This is a single-page frontend web application (“Code Snippets Frontend”) built with React, TypeScript, and Vite.
• It provides a UI for users to log in, create, view, search, filter, edit, and delete code snippets, with syntax highlighting (CodeMirror), theming, and responsive design.
• The app communicates with a separate backend API (not included here) via Axios-based services.
File Structure
Top-level files & folders
• public/index.html – host HTML
• src/main.tsx & src/App.tsx – React entrypoint and root component
• src/components/ – reusable UI components, subdivided into:
– auth (login/register forms, password rules, submit buttons)
– snippet (snippet-related UI: cards, filter, search, modals)
– shared (buttons, cards, code editor wrapper, containers)
– common components (Footer, Navigation, ErrorBoundary, Loading spinners)
• src/pages/ – page-level containers for routes (Home, Login, Register, SnippetList, SnippetDetail, Profile, Settings, etc.)
• src/contexts/ – React Contexts managing global state (AuthContext, ThemeContext, ToastContext)
• src/hooks/ – custom hooks for API calls, snippet management, theming, sharing, preview sizing, filter state
• src/services/ – API layer abstractions (api.ts config, authService.ts, snippetService.ts)
• src/utils/ – pure utility functions (language utilities, pagination, DOM helpers, theming)
• src/styles/ – SCSS files (variables, mixins, component-specific styles)
• src/types/ – TypeScript interfaces/types for API payloads, auth, snippets, routes, UI, errors
• src/test/ & __tests__ – Vitest/React Testing Library setup, handler mocks, tests for components, hooks, contexts, utils
Configuration & Build
• vite.config.ts, tsconfig.json, eslint.config.ts
README for Additional Insights
• Describes tech stack and testing strategy (Vitest, RTL).
• Explains project structure in brief.
Detail Recommendations
• Don’t treat the UI as a single block—break it into pages, component groups, shared vs. feature components.
• How state flows from Context Providers into UI, and how events bubble up to hooks.
• SCSS styling pipeline if needed to illustrate theming/customization.