# nasa/code-nasa-gov architecture

> Architecture diagram of the GitHub repository nasa/code-nasa-gov, 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/code-nasa-gov
- Repository: https://github.com/nasa/code-nasa-gov

## Overview

##### Project Overview
- This project is a front-end driven, static website that catalogs NASA’s open-source software. It is built using Polymer and uses JSON files as the data source (e.g., code.json, catalog.json). In addition, there are supporting scripts (in cron_scripts) and build configurations that help transform and deploy content.
- The primary goal is to display NASA’s open-source software projects, using a data visualization approach that leverages pre-built JSON catalogs and dynamically loaded Polymer components.

##### Main Components
a. Frontend Application:
- UI Assets: Include the HTML, CSS, and JS files found in directories such as AR/ and src/. These are the main building blocks for the visible interface.
- Polymer Components: Highlight how Polymer (with its CLI and configuration in polymer.json) is used to structure the application, including lazy-loading fragments (as described in the “Adding a new view” section).
- Service Worker: Represent the service-worker.js and sw-precache-config.js files. This indicates client-side offline caching and pre-caching of resources.

b. Data Layers:
- JSON Data Files: Represent the various JSON files in the data folder (e.g., catalog.json, SRA.json, code.json in the deprecated folder, etc.). These provide the application with the core content and feeds.
- Data Transformation Process: Note the role of the cron_scripts (e.g., code_to_catalog.py, release.sh) which transform the original code.json to category.json for the application’s consumption.

c. Build & Deployment Process:
- Build Pipeline: Include the build process commanded by Polymer CLI (with commands such as “polymer build” and “polymer serve”). This builds the project into two main outputs: “unbundled” (optimized for push-enabled servers) and “bundled” (for legacy or non-H2 servers).
- Deployment Artifacts: Emphasize that the built output (especially folder build/bundled) is the one that’s deployed, with configurations in files like app.yaml (which suggests possible deployment on a cloud platform such as Google App Engine).

d. Development & CI/CD:
- Source Control & CI: Indicate that the project uses Git (with .gitignore and .gitattributes) and continuous integration via Travis CI (and GitHub workflows such as stale.yml and test.yml). These can be shown as peripheral components that ensure code quality and automated testing.

e. Static Assets and Miscellaneous:
- Supporting assets like images, fonts, and additional static documents (e.g., NASA-M-16-21-Framework.pdf) should also be shown as resource feeds for the frontend.

##### Relationships and Data Flow
- How the cron scripts update or transform the JSON data.
- The build step where Polymer CLI reads configuration (polymer.json, sw-precache-config.js) to bundle assets and generate a service worker.
- The flow of data from the transformed JSON towards the Polymer components, which render the UI.

##### Final Advice
- Be very detailed where possible. Capture even the “supporting” components such as the CI scripts and deployment configurations.

## Diagram (Mermaid)

```mermaid
graph TD
  %% Frontend Application (Polymer)
  subgraph "Frontend Application (Polymer)"
    AR_UI["AR: UI Assets"]:::frontend
    SRC_UI["src: Polymer Components"]:::frontend
    PolyConfig["Polymer Config (polymer.json, bower.json)"]:::frontend
    SW["Service Worker (service-worker.js, sw-precache-config.js)"]:::frontend
  end

  %% Data Layer (JSON Files)
  subgraph "Data Layer (JSON Files)"
    JSON_Data["JSON Data Files (data)"]:::data
    Deprecated_Data["Deprecated JSON (data/deprecated)"]:::data
  end

  %% Data Transformation Process
  subgraph "Data Transformation"
    Cron["Cron Scripts"]:::processing
  end

  %% Build & Deployment Process
  subgraph "Build & Deployment"
    Build_Process["Build Process (Polymer CLI)"]:::build
    Deployment_Config["Deployment Config (app.yaml, package.json, package-lock.json)"]:::deploy
    Deployment_Server["Deployment Server (Static Hosting)"]:::deploy
  end

  %% Development & CI/CD
  subgraph "Development & CI/CD"
    Git_CI["Source Control (Git)"]:::ci
    CI_Config["CI Configuration (Travis CI, GitHub workflows)"]:::ci
  end

  %% Static Assets and Miscellaneous
  subgraph "Static Assets"
    F_images["Images"]:::static
    F_fonts["Fonts"]:::static
    F_docs["Supporting Documents"]:::static
  end

  %% Relationships and Data Flow
  JSON_Data --> Cron
  Deprecated_Data --> Cron
  Cron --> SRC_UI
  PolyConfig --> Build_Process
  CI_Config --> Build_Process
  Build_Process --> Deployment_Config
  Deployment_Config --> Deployment_Server
  AR_UI --> SW
  SRC_UI --> SW
  F_images --> AR_UI
  F_fonts --> AR_UI
  F_docs --> AR_UI
  Git_CI --> CI_Config

  %% Click Events for Frontend Application – UI Assets
  click AR_UI "https://github.com/nasa/code-nasa-gov/tree/master/AR/"
  click SRC_UI "https://github.com/nasa/code-nasa-gov/tree/master/src/"

  %% Click Events for Frontend Application – Polymer Components & Configuration
  click PolyConfig "https://github.com/nasa/code-nasa-gov/blob/master/polymer.json"

  %% Click Events for Frontend Application – Service Worker
  click SW "https://github.com/nasa/code-nasa-gov/blob/master/service-worker.js"

  %% Click Events for Data Layers – JSON Data Files
  click JSON_Data "https://github.com/nasa/code-nasa-gov/tree/master/data/"
  click Deprecated_Data "https://github.com/nasa/code-nasa-gov/tree/master/data/deprecated"

  %% Click Event for Data Transformation Process – Cron Scripts
  click Cron "https://github.com/nasa/code-nasa-gov/tree/master/cron_scripts/"

  %% Click Event for Build & Deployment Process – Deployment Configuration
  click Deployment_Config "https://github.com/nasa/code-nasa-gov/blob/master/app.yaml"

  %% Click Events for Development & CI/CD
  click Git_CI "https://github.com/nasa/code-nasa-gov/blob/master/.gitignore"
  click CI_Config "https://github.com/nasa/code-nasa-gov/blob/master/.travis.yml"

  %% Click Events for Static Assets
  click F_images "https://github.com/nasa/code-nasa-gov/tree/master/images/"
  click F_fonts "https://github.com/nasa/code-nasa-gov/tree/master/fonts/"
  click F_docs "https://github.com/nasa/code-nasa-gov/blob/master/NASA-M-16-21-Framework.pdf"

  %% Styles
  classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
  classDef data fill:#d4edda,stroke:#155724,stroke-width:2px;
  classDef processing fill:#fff3cd,stroke:#856404,stroke-width:2px;
  classDef build fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
  classDef deploy fill:#f8d7da,stroke:#721c24,stroke-width:2px;
  classDef ci fill:#e2e3e5,stroke:#41464b,stroke-width:2px;
  classDef static fill:#fefefe,stroke:#6c757d,stroke-width:2px;
```
