# willpower0304/nasa_api_astro architecture

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

- Interactive diagram: https://gitdiagram.com/willpower0304/nasa_api_astro
- Repository: https://github.com/willpower0304/nasa_api_astro

## Overview

##### Project type and purpose
- This is a full-stack (front-heavy) web application built with Astro, functioning as a static-site generator. Its primary role is to present real-time astronomical data (APOD, Near-Earth Asteroids) from NASA’s Open APIs in a modern, responsive UI.

##### File structure
- Top-level files:
- `astro.config.mjs` & `tsconfig.json` – build/runtime configs for Astro and TypeScript.
- `package.json` & `pnpm-lock.yaml` – dependency management via pnpm.
- `.gitignore`, `.vscode` – IDE and VCS settings.
- `public/` – static assets (fonts, images).
- `src/` – Astro source code:
– `layouts/` (Layout.astro),
– `components/` (Navbar.astro, Footer.astro),
– `pages/` (.astro pages: about, index, info, mission),
– `assets/` (styles or images if any).
- The pattern is standard Astro SSG: reusable components + layouts + pages. No microservices but client-side data fetching.

##### README for additional insights
- Tech stack: Astro (SSG), JavaScript, CSS.
- Hosting: Netlify.
- Data source: NASA Open APIs (APOD, asteroid data).
- Build/deploy commands: `pnpm run dev`, `pnpm run build`, deploy via Netlify.
- Environment variable: `import.meta.env.NASA_API_KEY`.

##### Main components & interactions
a. Components
1. Developer workstation (writes code, pushes to GitHub)
2. Version Control (GitHub repo)
3. CI/CD & Hosting (Netlify)
4. Build Process (Astro + pnpm)
5. Deployed Static Assets (HTML/CSS/JS under Netlify CDN)
6. Browser / Client (user’s device)
7. External Service (NASA Open APIs)

b. Relationships & data flow
- Developer → GitHub (push code)
- GitHub → Netlify (webhook triggers build)
- Netlify → Build Process (runs `pnpm install`, `pnpm run build`)
- Build → Netlify CDN (deploy `dist/` static files)
- Browser requests site assets from Netlify CDN
- In-browser JS fetches real-time data from NASA API (via `fetch(https://api.nasa.gov/…?api_key=…)`)
- NASA API responds with JSON (APOD, asteroid data) → Browser

c. Architectural patterns & design principles
- Static-site generation with client-side data fetching
- Component-based UI (Astro components + layouts)
- Separation of concerns:
- Layout & routing (pages)
- UI components (Navbar, Footer)
- Asset management (public, src/assets)
- CI/CD pipeline for automated deploy

d. Key technologies & libraries
- Astro – SSG framework
- pnpm – package manager
- JavaScript – logic in `.astro` files or client scripts
- CSS – styling
- Netlify – build & hosting environment
- NASA Open APIs – external data

##### Elements
- Code push → trigger build → deploy → client requests → API calls
- Static Hosting: another (e.g., green)
- A note on environment variables managing the API key during build or runtime.

1. Start by drawing the developer workflow: Developer → GitHub → Netlify.
3. Deployment of the `dist/` folder to Netlify’s CDN edge nodes.
4. User’s browser fetching static files and then executing JS to call NASA’s API.
5. Data flow back from NASA API into the UI components (e.g., APOD component).
6. Annotations for key files/folders:
- `src/pages/*.astro` as entry points
- `src/components/` as UI modules
- `public/` for fonts/assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer["Developer Workstation"]:::developer
    Developer -->|"push code"| GitHub["GitHub Repo"]:::vcs

    subgraph "Version Control"
        GitIgnore[".gitignore"]:::file
        VSCode[".vscode/"]:::dir
    end
    GitIgnore --> GitHub
    VSCode --> GitHub

    GitHub -->|"webhook trigger"| NetlifyCI["Netlify CI/CD"]:::cicd

    subgraph "Build Process"
        BP1["Install Dependencies"]:::build
        BP2["Run Astro Build"]:::build
    end
    NetlifyCI -->|"pnpm install"| BP1
    NetlifyCI -->|"pnpm run build"| BP2

    subgraph "Project Config"
        Config1["astro.config.mjs"]:::file
        Config2["tsconfig.json"]:::file
        Config3["package.json"]:::file
        Config4["pnpm-lock.yaml"]:::file
    end
    BP1 --> Config1
    BP1 --> Config2
    BP1 --> Config3
    BP1 --> Config4

    subgraph "Source Code"
        Layout["src/layouts/Layout.astro"]:::file
        Navbar["src/components/Navbar.astro"]:::file
        Footer["src/components/Footer.astro"]:::file
        Home["src/pages/index.astro"]:::file
        About["src/pages/about.astro"]:::file
        Mission["src/pages/mission.astro"]:::file
        Info["src/pages/info.astro"]:::file
        AssetsDir["src/assets/"]:::dir
    end
    BP2 --> Layout
    BP2 --> Navbar
    BP2 --> Footer
    BP2 --> Home
    BP2 --> About
    BP2 --> Mission
    BP2 --> Info
    BP2 --> AssetsDir

    subgraph "Public Resources"
        PublicDir["public/"]:::dir
        FontsDir["public/fonts/"]:::dir
    end
    PublicDir --> CDNUpload
    FontsDir --> CDNUpload

    BP2 --> CDNUpload["Deploy dist/ to Netlify CDN"]:::cdn

    subgraph "Delivery"
        CDN["Netlify CDN"]:::cdn
    end
    CDNUpload --> CDN

    CDN -->|"serve static assets"| Browser["Browser / Client"]:::client
    Browser -->|"fetch static assets"| CDN
    Browser -->|"client-side fetch"| NASA["NASA Open APIs"]:::external
    NASA -->|"JSON data"| Browser

    classDef developer fill:#f9f,stroke:#333,stroke-width:1px;
    classDef vcs fill:#bbf,stroke:#333,stroke-width:1px;
    classDef cicd fill:#88f,stroke:#333,stroke-width:1px;
    classDef build fill:#acf,stroke:#333,stroke-width:1px;
    classDef cdn fill:#8f8,stroke:#333,stroke-width:1px;
    classDef client fill:#ff8,stroke:#333,stroke-width:1px;
    classDef external fill:#f88,stroke:#333,stroke-width:1px;
    classDef file fill:#fff,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2;
    classDef dir fill:#eee,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2;

    click Config1 "https://github.com/willpower0304/nasa_api_astro/blob/main/astro.config.mjs"
    click Config2 "https://github.com/willpower0304/nasa_api_astro/blob/main/tsconfig.json"
    click Config3 "https://github.com/willpower0304/nasa_api_astro/blob/main/package.json"
    click Config4 "https://github.com/willpower0304/nasa_api_astro/blob/main/pnpm-lock.yaml"
    click PublicDir "https://github.com/willpower0304/nasa_api_astro/tree/main/public/"
    click FontsDir "https://github.com/willpower0304/nasa_api_astro/tree/main/public/fonts/"
    click Layout "https://github.com/willpower0304/nasa_api_astro/blob/main/src/layouts/Layout.astro"
    click Navbar "https://github.com/willpower0304/nasa_api_astro/blob/main/src/components/Navbar.astro"
    click Footer "https://github.com/willpower0304/nasa_api_astro/blob/main/src/components/Footer.astro"
    click Home "https://github.com/willpower0304/nasa_api_astro/blob/main/src/pages/index.astro"
    click About "https://github.com/willpower0304/nasa_api_astro/blob/main/src/pages/about.astro"
    click Mission "https://github.com/willpower0304/nasa_api_astro/blob/main/src/pages/mission.astro"
    click Info "https://github.com/willpower0304/nasa_api_astro/blob/main/src/pages/info.astro"
    click AssetsDir "https://github.com/willpower0304/nasa_api_astro/tree/main/src/assets/"
    click VSCode "https://github.com/willpower0304/nasa_api_astro/tree/main/.vscode/"
    click GitIgnore "https://github.com/willpower0304/nasa_api_astro/blob/main/.gitignore"
```
