# harvey-andrew/trajectory-roaming architecture

> Architecture diagram of the GitHub repository harvey-andrew/trajectory-roaming, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harvey-andrew/trajectory-roaming
- Repository: https://github.com/harvey-andrew/trajectory-roaming

## Overview

##### Project Type and Purpose
- This is a single‐page front-end application built with Vue.js and Vite, focused on 3D map visualization using Cesium.js.
- It loads bus stop and trajectory data (load.json), renders a Cesium map with AMap imagery, animates vehicles along routes, and provides UI controls (play/pause, speed, perspective).

##### High-Level Components
a. Entry Point & Build
- index.html – loads the app shell
- vite.config.js & pnpm-lock.yaml – build/config tooling
- package.json – dependencies (vue, cesium, turf, tailwindcss)
b. Bootstrapping
- src/main.js – creates Vue app, injects global CSS
- src/App.vue – root component orchestrating map + panels
c. UI Components
- src/components/Popup.vue – informational overlays (“bubble windows”)
- src/components/PopupCar.vue – vehicle-specific popups
- Tailwind CSS – styling via tailwind.config.js + postcss.config.js
d. API Layer
- src/api/request.js – base HTTP request wrapper (fetch/axios)
- src/api/houseApi/index.js, buildApi/index.js – specific endpoints (if used)
e. Cesium Map & Tools
- src/tool/*.js – utility modules for:
– bubbleCar.js (popup logic)
– cesiumToZh.js (coordinate transforms)
– load3D.js (model loading)
– trajectory.js (path/time sampling)
f. Static Assets

##### Data Flow & Interactions
1. On load, App.vue calls initData():
– fetch load.json via request.js
– parse trajectory points & stations
– convert to Cesium.Cartesian3 positions
2. Cesium Initialization:
– Cesium.Viewer ‹imageryProvider› gets AMap tiles
– apply filterColor to adjust map appearance
3. Render Layers:
– load3D.js: add station models & bus entity with orientationController
– trajectory.js: compute siteTimes & Clock samples for vehicle animation
4. UI Controls:
– user events in PopupCar.vue trigger Cesium Clock (start, pause, reset)
– speed adjustments recompute siteTimes → update Clock.stopTime
– viewpoint switches:
- free view: viewer.trackedEntity = null;
- follow view: viewer.trackedEntity = busEntity;
- in-car view: camera.lookAtTransform(… computed transform)
5. External Services:
– AMap tile server (Cesium.UrlTemplateImageryProvider)
– (Optional) houseApi, buildApi endpoints for remote data

##### Architectural Patterns & Principles
- Separation of Concerns:
- UI (Vue components) vs. Data (API modules) vs. Map logic (tool modules)
- Single Source of Truth:
- Vue reactive state for control panel, current index, play state
- Modular Utilities:
- trajectory.js for time/distance computation;
- turf.js via dependency for lineSlice logic

##### Final Advice
- Be exhaustive: capture all 6 tool modules + 2 API modules + 2 UI components
- Keep labels concise but specific (e.g., “trajectory.js: compute time samples”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry & Build"
        HTML["index.html"]:::internal
        VITE["vite.config.js"]:::internal
        PKG["package.json"]:::internal
        LOCK["pnpm-lock.yaml"]:::internal
    end

    subgraph "Bootstrapping"
        MAIN["/src/main.js"]:::internal
        APP["/src/App.vue"]:::internal
    end

    subgraph "UI Components"
        POP["/src/components/Popup.vue"]:::internal
        POPC["/src/components/PopupCar.vue"]:::internal
        TWC["tailwind.config.js"]:::internal
        PCC["postcss.config.js"]:::internal
    end

    subgraph "API Layer"
        REQ["/src/api/request.js"]:::internal
        HAPI["/src/api/houseApi/index.js"]:::internal
        BAPI["/src/api/buildApi/index.js"]:::internal
    end

    subgraph "Cesium & Tools"
        BUB["/src/tool/bubbleCar.js"]:::internal
        TRANS["/src/tool/cesiumToZh.js"]:::internal
        DRAW["/src/tool/draw.js"]:::internal
        FILT["/src/tool/filterColor.js"]:::internal
        LOAD3D["/src/tool/load3D.js"]:::internal
        TRAJ["/src/tool/trajectory.js"]:::internal
        CESIUM["Cesium.Viewer"]:::internal
    end

    subgraph "Data Sources"
        MDL1["/src/assets/bus.gltf"]:::data
        MDL2["/src/assets/model.gltf"]:::data
        JSON["/src/assets/load.json"]:::data
        CSSF["/src/assets/tailwind.css"]:::data
        IMGS["/src/assets/img/"]:::data
    end

    EXTERNAL["AMap Tile Server"]:::external

    HTML -->|"bootstraps"| MAIN
    MAIN -->|"mounts"| APP
    APP -->|"uses component"| POP
    APP -->|"uses component"| POPC
    APP -->|"fetches data"| REQ
    REQ -->|"calls"| HAPI
    REQ -->|"calls"| BAPI
    APP -->|"initializes"| CESIUM
    CESIUM -->|"tiles from"| EXTERNAL
    CESIUM -->|"calls"| BUB
    CESIUM -->|"calls"| TRANS
    CESIUM -->|"calls"| DRAW
    CESIUM -->|"calls"| FILT
    CESIUM -->|"calls"| LOAD3D
    CESIUM -->|"calls"| TRAJ
    TRAJ -->|"renders polyline"| CESIUM
    LOAD3D -->|"adds models"| CESIUM
    TRAJ -->|"samples time"| CESIUM
    APP -->|"provides UI control"| POP
    APP -->|"provides UI control"| POPC
    JSON -->|"data for"| APP
    MDL1 -->|"model for"| LOAD3D
    MDL2 -->|"model for"| LOAD3D
    CSSF -->|"styles loaded"| MAIN
    IMGS -->|"icons used"| POP

    click HTML "https://github.com/harvey-andrew/trajectory-roaming/blob/master//index.html"
    click VITE "https://github.com/harvey-andrew/trajectory-roaming/blob/master//vite.config.js"
    click PKG "https://github.com/harvey-andrew/trajectory-roaming/blob/master//package.json"
    click LOCK "https://github.com/harvey-andrew/trajectory-roaming/blob/master//pnpm-lock.yaml"
    click MAIN "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/main.js"
    click APP "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/App.vue"
    click POP "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/components/Popup.vue"
    click POPC "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/components/PopupCar.vue"
    click TWC "https://github.com/harvey-andrew/trajectory-roaming/blob/master//tailwind.config.js"
    click PCC "https://github.com/harvey-andrew/trajectory-roaming/blob/master//postcss.config.js"
    click REQ "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/api/request.js"
    click HAPI "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/api/houseApi/index.js"
    click BAPI "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/api/buildApi/index.js"
    click BUB "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/bubbleCar.js"
    click TRANS "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/cesiumToZh.js"
    click DRAW "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/draw.js"
    click FILT "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/filterColor.js"
    click LOAD3D "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/load3D.js"
    click TRAJ "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/tool/trajectory.js"
    click MDL1 "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/assets/bus.gltf"
    click MDL2 "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/assets/model.gltf"
    click JSON "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/assets/load.json"
    click CSSF "https://github.com/harvey-andrew/trajectory-roaming/blob/master//src/assets/tailwind.css"
    click IMGS "https://github.com/harvey-andrew/trajectory-roaming/tree/master//src/assets/img/"

    classDef internal fill:#D6E9FF,stroke:#0000FF;
    classDef data fill:#DFFFE0,stroke:#00AA00;
    classDef external fill:#FFF4C1,stroke:#FF8000;
```
