# max60213/starmap architecture

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

- Interactive diagram: https://gitdiagram.com/max60213/starmap
- Repository: https://github.com/max60213/starmap

## Overview

##### Project type and purpose
- This is a single-page application (SPA) built with React and Vite.
- It’s an educational/content site delivering photography/video tutorials and interactive 3D visualizations (via three-js).
- All content (JSON article data, images, videos) lives in the public folder.

##### File structure
- Top-level config: package.json, vite.config.js, ESLint config.
- public/: static assets (HTML shell, media, article JSON).
- src/: application source code
- main.jsx & App.jsx: entry point and root component
- Landing, Loading, Scene: high-level route targets
- components/: reusable UI pieces (pages/, article/, GalaxyContext)
- three-js/: custom 3D helpers and scene builder
- css/ and css files under components: SCSS styles for global and feature-specific styling
- No backend folder—this is purely front-end, content-First SPA.

##### Insights from README
- Confirms minimal Vite + React setup with HMR & ESLint.
- No server-side logic—builds down to static assets for hosting.

a) Main components
- Browser (User)
- Static Web Host / CDN (serves index.html, JS bundle, media)
- React SPA
– Router / PathChecker
– Page Components (Landing, Slider, View, Window, Article pages)
– GalaxyContext & three-js engine
– Asset loader (fetch JSON, images, videos from public/)
- Build Pipeline
– Node.js / npm scripts
– Vite bundler (JSX → JS, SCSS → CSS)
– ESLint plugin

b) Relationships & interactions
- Browser → HTTP GET → Static Host → index.html + assets
- index.html bootstraps React bundle
- React Router / PathChecker reads URL, renders appropriate page/component
- Components call fetch() to load JSON article files under public/articles
- GalaxyContext initializes three-js helpers (InfiniteGridHelper, galaxy)
- SCSS files imported in JSX become CSS at build time
- During development: Browser ↔ HMR-enabled Vite dev server

c) Architectural patterns & principles
- SPA / component-based architecture
- Context API for global state (GalaxyContext)
- File-system segregation of concerns: pages vs. shared components vs. assets
- Build-time asset handling via Vite (tree-shaking, module hot reload)

d) Key technologies/frameworks
- React + JSX
- Vite (fast bundler + dev server)
- three-js (3D scene rendering)
- SCSS for styling
- ESLint & @vitejs/plugin-react

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Deploy Layer
    subgraph "Build & Deploy" 
        direction TB
        NPM["Node.js / npm scripts"]:::build
        Vite["Vite Bundler"]:::build
        ESLint["ESLint & @vitejs/plugin-react"]:::build
        Configs["vite.config.js<br/>package.json<br/>.eslintrc.cjs"]:::build
    end

    NPM -->|"runs"| Vite
    Vite -->|"uses"| ESLint
    Vite -->|"outputs JS/CSS"| StaticHost

    %% Static Host / CDN
    subgraph "Static Host / CDN" 
        direction TB
        StaticHost["index.html<br/>bundle.js<br/>public/articles/**<br/>media"]:::content
    end

    %% Browser / Runtime Layer
    subgraph "Browser (Client Runtime)"
        direction TB
        Browser["Browser"]:::client
        Browser -->|"GET /"| StaticHost
        Browser -->|"loads index.html"| ReactEntry
    end

    %% React SPA
    subgraph "React SPA" 
        direction TB
        ReactEntry["src/main.jsx"]:::client
        AppComp["src/App.jsx"]:::client
        PathCheck["src/components/PathChecker.jsx"]:::client
        GalaxyCtx["src/components/GalaxyContext.jsx"]:::client
        Router["React Router"]:::client
        AssetLoader["Asset Loader<br/>(fetch from public/articles)"]:::client
        Loading["src/Loading.jsx"]:::client
        SceneHost["src/Scene.jsx"]:::client

        %% Pages
        subgraph "Page Components"
            direction TB
            Landing["src/Landing.jsx"]:::client
            Slider["src/components/pages/Slider.jsx"]:::client
            View["src/components/pages/View.jsx"]:::client
            WindowPage["src/components/pages/Window.jsx"]:::client
            Info["src/components/pages/Info.jsx"]:::client
        end

        %% Article Parts
        subgraph "Article Components"
            direction TB
            ArticleShell["src/components/article/Article.jsx"]:::client
            Aside["src/components/article/Aside.jsx"]:::client
            MxBasics["src/components/article/MxBasics.jsx"]:::client
            ToggleAdvance["src/components/article/ToggleAdvance.jsx"]:::client
        end

        %% Shared UI
        subgraph "Shared Components"
            direction TB
            MainContent["src/components/MainContent.jsx"]:::client
            Navigate["src/components/Navigate.jsx"]:::client
        end

        %% Styles
        Styles["SCSS Styles<br/>src/css/**/*.scss<br/>src/components/**/css/*.scss"]:::client
    end

    ReactEntry -->|"renders"| AppComp
    AppComp -->|"uses"| Router
    Router -->|"pathcheck"| PathCheck
    Router -->|"renders page"| Landing
    Router -->|"renders page"| Slider
    Router -->|"renders page"| View
    Router -->|"renders page"| WindowPage
    Router -->|"renders page"| Info
    AppComp -->|"provides context"| GalaxyCtx
    AppComp -->|"renders"| Loading
    AppComp -->|"renders"| SceneHost
    GalaxyCtx -->|"initializes"| ThreeEngine
    AssetLoader -->|"fetches JSON/media"| StaticHost
    Loading -->|"shows while loading"| AssetLoader
    SceneHost -->|"renders"| ThreeEngine

    %% 3D Engine Layer
    subgraph "three-js Engine & Helpers"
        direction TB
        InfiniteGrid["src/three-js/InfiniteGridHelper.js"]:::engine
        GalaxyScene["src/three-js/galaxy.js"]:::engine
    end

    ThreeEngine["three-js Engine"]:::engine
    ThreeEngine --> InfiniteGrid
    ThreeEngine --> GalaxyScene

    GalaxyCtx -->|"calls helpers"| InfiniteGrid
    GalaxyCtx -->|"calls builder"| GalaxyScene

    %% Styles import
    Styles --> AppComp

    %% Click Events
    click ReactEntry "https://github.com/max60213/starmap/blob/main/src/main.jsx"
    click AppComp "https://github.com/max60213/starmap/blob/main/src/App.jsx"
    click PathCheck "https://github.com/max60213/starmap/blob/main/src/components/PathChecker.jsx"
    click GalaxyCtx "https://github.com/max60213/starmap/blob/main/src/components/GalaxyContext.jsx"
    click InfiniteGrid "https://github.com/max60213/starmap/blob/main/src/three-js/InfiniteGridHelper.js"
    click GalaxyScene "https://github.com/max60213/starmap/blob/main/src/three-js/galaxy.js"
    click Landing "https://github.com/max60213/starmap/blob/main/src/Landing.jsx"
    click Slider "https://github.com/max60213/starmap/blob/main/src/components/pages/Slider.jsx"
    click View "https://github.com/max60213/starmap/blob/main/src/components/pages/View.jsx"
    click WindowPage "https://github.com/max60213/starmap/blob/main/src/components/pages/Window.jsx"
    click Info "https://github.com/max60213/starmap/blob/main/src/components/pages/Info.jsx"
    click ArticleShell "https://github.com/max60213/starmap/blob/main/src/components/article/Article.jsx"
    click Aside "https://github.com/max60213/starmap/blob/main/src/components/article/Aside.jsx"
    click MxBasics "https://github.com/max60213/starmap/blob/main/src/components/article/MxBasics.jsx"
    click ToggleAdvance "https://github.com/max60213/starmap/blob/main/src/components/article/ToggleAdvance.jsx"
    click MainContent "https://github.com/max60213/starmap/blob/main/src/components/MainContent.jsx"
    click Navigate "https://github.com/max60213/starmap/blob/main/src/components/Navigate.jsx"
    click Loading "https://github.com/max60213/starmap/blob/main/src/Loading.jsx"
    click SceneHost "https://github.com/max60213/starmap/blob/main/src/Scene.jsx"

    %% Styles Classes
    classDef build fill:#f0f0f0,stroke:#999,stroke-width:1px;
    classDef content fill:#e0f7e9,stroke:#2d8f4e,stroke-width:1px;
    classDef client fill:#d0e7ff,stroke:#1a6fb3,stroke-width:1px;
    classDef engine fill:#ffe0b2,stroke:#e65c00,stroke-width:1px;
```
