How tatyana25081974/goit-typescript-hw-02 works
Project Type and Purpose
• This is a single-page React application written in TypeScript, bootstrapped with Vite.
• It consumes the Unsplash API to provide a searchable image gallery with modal previews, load-more functionality, and error/loader states.
Main Components
a. Build & Dev Tooling
• Vite dev server & bundler (vite.config.ts)
• ESLint configuration (eslint.config.js)
• TypeScript compiler configurations (tsconfig.*.json)
b. Static Assets
• index.html (app shell)
• /public folder (favicon, global static files)
c. Application Entry Points
• src/main.tsx – React bootstrap and mounting into index.html
• src/index.css – global styles
d. API Layer
• src/api/unsplashApi.ts – wrapper around fetch/XHR to Unsplash REST endpoints
• src/types/unsplash.ts – TS interfaces for API contracts
e. Core React Components (component-based UI layer)
• App – top-level container, holds search state and image list
• SearchBar – user input → triggers API calls
• ImageGallery – receives array of image metadata, renders ImageCard
• ImageCard – displays a thumbnail, click → opens ImageModal
• ImageModal – shows full-size image + info
• LoadMoreBtn – fetches next page, appends to gallery
• Loader / ErrorMessage – show spinner or error on API calls
f. External Service
• Unsplash API (remote REST service)
Relationships & Data Flow
• User → (SearchBar) → App state → unsplashApi.fetchImages(query, page) → HTTP request → Unsplash API → JSON response → App state update → ImageGallery → ImageCard → ImageModal
• LoadMoreBtn triggers the same API layer with an incremented page parameter
• Loader/ErrorMessage subscribe to App’s “loading” and “error” flags
Architectural Patterns & Principles
• Component-based UI decomposition (React functional components, CSS Modules)
• Unidirectional data flow: parent (App) supplies props to children; children raise events back up
• Separation of concerns: API logic isolated from UI; types isolated in /types
Technologies & Frameworks
• Vite for bundling, HMR, and dev server
• React + ReactDOM for UI rendering
• TypeScript for static typing
• Babel or SWC via @vitejs/plugin-react for Fast Refresh
• CSS Modules for scoped styles
• ESLint + plugin-react for linting