How paulinetaillemite/my-own-unsplash works
Project type and purpose
• This is a minimalist single-page front-end application.
• Its only responsibility is to load static assets (HTML, CSS, JS) in the browser, take user input, fetch random images from the Unsplash API, loop over the results, and render them on the page.
File structure
• index.html: entry point and container for the UI.
• style.css: styling rules and layout definitions.
• script.js: contains the business logic—listens for user input, issues fetch requests to the Unsplash API, processes the JSON, and dynamically injects image elements into the DOM.
• No backend code or databases are present—everything runs in the browser.
Key architectural insights from the README
• Technologies: plain HTML, CSS, and JavaScript.
• Core feature: fetch images by theme (user input) using the Unsplash API.
• Challenge: managing asynchronous data and looping through results to render them efficiently.
Main components
a. Client / Browser
– Renders index.html, applies styles from style.css, runs script.js.
– Holds the UI form/input, image gallery container.
b. Static Asset Server (or CDN)
– Hosts and serves index.html, script.js, style.css to the client.
c. Unsplash External API
– Receives HTTP GET requests from script.js including query parameters (search term, API key).
– Returns JSON payload with image URLs and metadata.
d. DOM & Rendering Engine
– The browser’s internal component that takes the JSON from script.js, loops through it, and injects <img> elements into the page.
Relationships and interactions
• User types a theme and submits the form in the browser.
• script.js captures the event, calls fetch() to Unsplash API via the network.
• Unsplash API processes the request and returns a JSON response.
• script.js receives the JSON Promise, loops through the results, builds HTML snippets, and appends them to the DOM.
• The browser’s rendering engine paints the new images on screen.
Architectural patterns and principles
• Separation of concerns: HTML for structure, CSS for style, JS for behavior.
• Event-driven flow: user events trigger asynchronous fetch operations.
• External API integration: clear boundary between client code and third-party service.
• Stateless interactions: each fetch is independent; no client-side persistence beyond the DOM.
Technologies to call out
• HTML5 and DOM APIs
• CSS3 (hover effects, hidden/display logic)
• JavaScript fetch API and Promise chaining
• Unsplash REST API (authentication via API key in request headers or query string)