# nasa/api-docs architecture

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

- Interactive diagram: https://gitdiagram.com/nasa/api-docs
- Repository: https://github.com/nasa/api-docs

## Overview

##### Project Type and Purpose
- This project is a static front-end website for displaying NASA public API documentation and for providing an API key generation form.
- Its primary purpose is to dynamically display details about various NASA APIs from a JSON data file, alongside static HTML content that includes sections like “Authentication,” “Browse APIs,” and “Generate API Key.”
- The README indicates it also serves as the “current iteration” of api.nasa.gov and acted as a pass-through for endpoints, so it is primarily concerned with presentation and client-side behavior.

##### Analyzing the File Structure
- Top-level directories include assets (containing HTML snippets, CSS/SCSS, JavaScript, fonts, images, and JSON files) that form the building blocks of the UI.
- The assets folder is well organized into sub-folders for HTML templates (e.g., header, footer, authentication, browseAPI), CSS/SCSS files for both the NASA Web Design System and custom styles, JavaScript scripts that handle API loading and UI setup, and apis.json that holds the API data.
- There are configuration files like the GitHub workflows in the .github directory, and others for version control, which emphasize that this repository is managed as a static site updated primarily by front-end developers.

##### README Insights
- The README clarifies that the site is used to list NASA’s public APIs and to integrate with the GSA API key form.
- It also mentions key libraries such as the NASA Web Design Service and jQuery. This gives you clues about the dependencies.
- The README also hints at dynamic generation of pages by reading the apis.json data using JavaScript functions (e.g., APILoader.js and contentLoader.js).

a. Frontend/UI (Client-side Presentation):
- Web Browser: The client (user’s browser) interacting with the website.
- HTML Pages: Representing separate views/templates like index.html, authentication.html, browseAPI.html, recoverKey.html, etc.
- CSS/SCSS Assets: Responsible for layout and styling, with separate components (hero, header, footer, navigation, etc.) from both NASA’s design system and custom application styling.
- JavaScript Components: Scripts such as APILoader.js, contentLoader.js, gui.js, and setup.js that drive dynamic content, form interactions, and API key generation.
b. Data Layer:
- apis.json: The static JSON file which acts as the repository for NASA API listings.
c. External Dependencies and Services:
- NASA Web Design Service Library: Supplies consistent design patterns.
- jQuery: Provides simplified DOM manipulation and event handling.
- External API Endpoints: Although this site is static, it uses API key generation that pass-throughs to external GSA APIs or the original API endpoints.
- GitHub Pages: Hosting environment for serving all static assets.
d. Supporting Assets:
- Assets like fonts, images, footer components, and additional HTML snippets that make up the site’s visual components.

##### Relationships and Interactions
- The Browser (client) loads static HTML pages and associated assets (CSS, JS, fonts, images) directly from GitHub Pages.
- JavaScript components in the client retrieve data from apis.json, parse it, and dynamically render parts of the UI (for example, filling in API listings).
- The API key generation form interacts with an external API key system (as mentioned in the README, though this may be a passthrough) through an HTTP request.
- The layout components pull in sub-templates such as headers and footers that are stored under assets/html and assets/footer.

##### Important Architectural Patterns to Highlight
- Client-side rendering and dynamic data loading (AJAX-like fetching of local JSON).
- Separation of concerns where the presentation (HTML/CSS) is decoupled from the data service (apis.json) and user interaction (JavaScript logic).
- Use of modular assets (well-organized SCSS and JS libraries) that can be updated independently.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Hosting Environment
    subgraph "GitHub Pages (Hosting)"
        gp["GitHub Pages"]
    end

    %% Client: Web Browser
    subgraph "Client: Web Browser"
        direction TB

        subgraph "HTML Pages"
            index["index.html"]
            auth["authentication.html"]
            browse["browseAPI.html"]
            recover["recoverKey.html"]
        end

        subgraph "Template Components"
            subgraph "Header Templates"
                header["header.html"]
                headerNo["header_noButtons.html"]
            end
            subgraph "Footer Components"
                footerHtml["OIT-footer.html"]
                footerCss["OIT-footer.css"]
                footerJs["OIT-footer.js"]
            end
        end

        subgraph "CSS/SCSS Assets"
            nasawdscss["NASA WDS CSS"]
            customcss["Custom Styles (indexFormat.css)"]
            scss["SCSS Files"]
        end

        subgraph "JavaScript Components"
            apiLoader["APILoader.js"]
            contentLoader["contentLoader.js"]
            gui["gui.js"]
            setup["setup.js"]
            nasawdsjs["nasawds.js"]
        end
    end

    %% Data Layer
    subgraph "Data Layer"
        apis["apis.json"]
    end

    %% External Services
    subgraph "External API Services"
        extApi["External API (GSA/NASA)"]
    end

    %% Supporting Assets
    subgraph "Supporting Assets"
        fonts["Fonts"]
        images["Images"]
        footerImages["Footer Images"]
    end

    %% Connections
    index -->|"loadAssets"| gp
    nasawdscss -->|"loadCSS"| gp
    customcss -->|"loadCSS"| gp
    scss -->|"loadStyles"| gp

    apiLoader -->|"fetchData"| apis
    contentLoader -->|"fetchData"| apis

    gui -->|"formSubmit"| extApi
    setup -->|"initUI"| index

    index -->|"loadFonts"| fonts
    index -->|"loadImages"| images
    footerHtml -->|"loadFooterImg"| footerImages

    %% Styles
    classDef browser fill:#cce5ff,stroke:#003366,stroke-width:1px;
    classDef template fill:#e6ffe6,stroke:#006600,stroke-width:1px;
    classDef css fill:#fff0e6,stroke:#cc6600,stroke-width:1px;
    classDef js fill:#e6f7ff,stroke:#005266,stroke-width:1px;
    classDef data fill:#f9e6ff,stroke:#8a2be2,stroke-width:1px;
    classDef external fill:#ffe6e6,stroke:#cc0000,stroke-width:1px;
    classDef support fill:#ffffcc,stroke:#999900,stroke-width:1px;
    classDef host fill:#e6e6e6,stroke:#666666,stroke-width:1px;

    class index,auth,browse,recover browser;
    class header,headerNo,footerHtml,footerCss,footerJs template;
    class nasawdscss,customcss,scss css;
    class apiLoader,contentLoader,gui,setup,nasawdsjs js;
    class apis data;
    class extApi external;
    class fonts,images,footerImages support;
    class gp host;

%% Click Events
click index "https://github.com/nasa/api-docs/blob/gh-pages//index.html"
click auth "https://github.com/nasa/api-docs/blob/gh-pages//assets/html/authentication.html"
click browse "https://github.com/nasa/api-docs/blob/gh-pages//assets/html/browseAPI.html"
click recover "https://github.com/nasa/api-docs/blob/gh-pages//assets/html/recoverKey.html"

click header "https://github.com/nasa/api-docs/blob/gh-pages//assets/html/header.html"
click headerNo "https://github.com/nasa/api-docs/blob/gh-pages//assets/html/header_noButtons.html"
click footerHtml "https://github.com/nasa/api-docs/blob/gh-pages//assets/footer/OIT-footer.html"
click footerCss "https://github.com/nasa/api-docs/blob/gh-pages//assets/footer/OIT-footer.css"
click footerJs "https://github.com/nasa/api-docs/blob/gh-pages//assets/footer/OIT-footer.js"

click nasawdscss "https://github.com/nasa/api-docs/blob/gh-pages//assets/css/nasawds.css"
click customcss "https://github.com/nasa/api-docs/blob/gh-pages//assets/css/indexFormat.css"
click scss "https://github.com/nasa/api-docs/tree/gh-pages//assets/scss/"

click apiLoader "https://github.com/nasa/api-docs/blob/gh-pages//assets/js/APILoader.js"
click contentLoader "https://github.com/nasa/api-docs/blob/gh-pages//assets/js/contentLoader.js"
click gui "https://github.com/nasa/api-docs/blob/gh-pages//assets/js/gui.js"
click setup "https://github.com/nasa/api-docs/blob/gh-pages//assets/js/setup.js"
click nasawdsjs "https://github.com/nasa/api-docs/blob/gh-pages//assets/js/nasawds.js"

click apis "https://github.com/nasa/api-docs/blob/gh-pages//assets/json/apis.json"

click fonts "https://github.com/nasa/api-docs/tree/gh-pages//assets/fonts/"
click images "https://github.com/nasa/api-docs/tree/gh-pages//assets/img/"
click footerImages "https://github.com/nasa/api-docs/tree/gh-pages//assets/footer/img/"
```
