# santiaguf/spacex-platzi architecture

> Architecture diagram of the GitHub repository santiaguf/spacex-platzi, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santiaguf/spacex-platzi
- Repository: https://github.com/santiaguf/spacex-platzi

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Client Browser"]:::browser

    subgraph "User Interface Layer"
        IndexHTML["index.html"]:::ui
        LaunchHTML["launch.html"]:::ui
        CSSAssets["CSS Assets"]:::ui
        ImageAssets["Image Assets"]:::ui
    end

    subgraph "Application Logic"
        DataJS["data.js"]:::logic
        LaunchJS["launch.js"]:::logic
        LaunchesJS["launches.js"]:::logic
        ServiceWorker["Service Worker"]:::sw
        Manifest["manifest.json"]:::config
        BabelRC[".babelrc"]:::config
        ESLint["ESLint Config"]:::config
    end

    TestSuite["Test Suite"]:::testing
    API["SpaceX REST API"]:::external

    %% Flow connections
    Browser --> IndexHTML
    Browser --> LaunchHTML
    Browser --> CSSAssets
    Browser --> ImageAssets

    IndexHTML --> DataJS
    LaunchHTML --> DataJS

    DataJS -->|"fetches"| API
    LaunchJS -->|"fetches"| API
    LaunchesJS -->|"fetches"| API

    DataJS -->|"caches via"| ServiceWorker
    LaunchJS -->|"caches via"| ServiceWorker
    LaunchesJS -->|"caches via"| ServiceWorker

    TestSuite -->|"tests"| DataJS
    TestSuite -->|"tests"| LaunchJS
    TestSuite -->|"tests"| LaunchesJS

    %% Click Events
    click IndexHTML "https://github.com/santiaguf/spacex-platzi/blob/master/src/index.html"
    click LaunchHTML "https://github.com/santiaguf/spacex-platzi/blob/master/src/launch.html"
    click CSSAssets "https://github.com/santiaguf/spacex-platzi/tree/master/src/css"
    click ImageAssets "https://github.com/santiaguf/spacex-platzi/tree/master/src/img"
    click DataJS "https://github.com/santiaguf/spacex-platzi/blob/master/src/js/data.js"
    click LaunchJS "https://github.com/santiaguf/spacex-platzi/blob/master/src/js/launch.js"
    click LaunchesJS "https://github.com/santiaguf/spacex-platzi/blob/master/src/js/launches.js"
    click ServiceWorker "https://github.com/santiaguf/spacex-platzi/blob/master/src/serviceWorker.js"
    click Manifest "https://github.com/santiaguf/spacex-platzi/blob/master/src/manifest.json"
    click BabelRC "https://github.com/santiaguf/spacex-platzi/blob/master/.babelrc"
    click ESLint "https://github.com/santiaguf/spacex-platzi/blob/master/.eslintrc"
    click TestSuite "https://github.com/santiaguf/spacex-platzi/tree/master/test"

    %% Styles
    classDef browser fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef ui fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef logic fill:#D0E0E3,stroke:#5DADE2,stroke-width:2px;
    classDef sw fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
    classDef config fill:#EBF5FB,stroke:#3498DB,stroke-width:2px;
    classDef external fill:#F8CECC,stroke:#B85450,stroke-width:2px;
    classDef testing fill:#E1D5E7,stroke:#8E44AD,stroke-width:2px;
```
