How santiaguf/spacex-platzi works
Main Components
• User Interface Layer:
• HTML Files: index.html and launch.html serve as the primary entry points for the web pages.
• CSS & Image Assets: Located under src/css and src/img (with further subdirectories like AppImages for different platforms), these provide styling and visuals.
• JavaScript Application Logic:
• JavaScript Modules: Files such as src/js/data.js, src/js/launch.js, and src/js/launches.js are responsible for fetching API data and managing the application’s dynamic behavior.
• Service Worker: src/serviceWorker.js, which likely serves for offline capabilities or caching, enhancing performance.
• Manifest and Configuration Files: src/manifest.json (for PWA capabilities) accompanied by configuration files (.babelrc, .eslintrc) that ensure code quality and proper transpilation.
• External Dependency:
• SpaceX REST API: The external API that supplies the data displayed in the application.
• Testing Infrastructure:
• Test Directory: Contains unit tests, e.g., test/data.spec.js (with its own ESLint configuration) to validate functionality.
Relationships and Interactions
• The browser loads HTML files (index.html/launch.html) which link to the CSS files and JavaScript modules.
• The JavaScript modules (from the src/js directory) are responsible for fetching data from the SpaceX REST API and injecting the dynamic content into the DOM.
• The Service Worker registers in the background to handle resource caching and potentially offline support.
• The manifest.json describes how the app should behave as a Progressive Web App (PWA), influencing both caching and installation options.
• The test suite interacts solely with the JavaScript code, verifying that API calls and data processing behave as expected.
Architectural Patterns and Design Principles
• Separation of Concerns: Clearly separate HTML for structure, CSS for presentation, and JavaScript for logic.
• Modularization: The division of JavaScript logic into separate files (data.js, launch.js, launches.js) suggests a modular structure.
• Progressive Enhancement: The inclusion of a service worker and manifest.json indicates a move toward PWA capabilities.