# zhongjianghan/3dct architecture

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

- Interactive diagram: https://gitdiagram.com/zhongjianghan/3dct
- Repository: https://github.com/zhongjianghan/3dct

## Overview

##### Project type and purpose
- From the file tree we see only static files (HTML, JavaScript, data) and no server‐side code.
- The README is minimal (“# 3DCT”), but the presence of NRRDLoader.js, Volume.js, VolumeShader.js, WebGL.js, and three.js suggests that this is a browser-based 3D volume-rendering tool.
- index.html loads a CT scan volume (stent.nrrd) from the data folder and visualizes it in WebGL using three.js.

##### File structure
- Top-level:
- index.html – entry point
- js/ – source modules
- js/build/three.js – the three.js library
- data/ – sample volume data (stent.nrrd)
- The js/ directory holds components corresponding to distinct responsibilities:
- NRRDLoader.js – parsing NRRD files
- Volume.js & VolumeShader.js – representing the 3D volume and its GPU shader
- WebGL.js – WebGL context setup
- OrbitControls.js – user interaction (rotate, zoom)
- There are no backend services, build scripts, or deployment manifests; this is a pure front-end static site.

##### README for additional insights
- The README only names the project (“3DCT”).

##### Final advice
- How data transitions from disk (stent.nrrd) to memory (JavaScript objects) to GPU (shader programs).
- Don’t overthink—separate into as many components as you have files, then group related ones (e.g., loader vs. renderer).
- Critical interactions (e.g., NRRD parsing, shader compilation).
- This will give stakeholders and new developers an immediate, accurate picture of the 3DCT architecture in the browser.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Server
    StaticServer["Static File Server"]:::server
    StaticServer -->|serves| HTML
    StaticServer -->|serves| JSDir
    StaticServer -->|serves| DataDir

    %% Client Browser
    subgraph "Browser (Client)" 
        direction TB
        HTML["index.html"]:::asset
        three["three.js"]:::library
        loader["NRRDLoader.js"]:::module
        vol["Volume.js"]:::module
        shader["VolumeShader.js"]:::module
        webgl["WebGL.js"]:::module
        orbit["OrbitControls.js"]:::module
        render["Render Loop"]:::runtime
        canvas["WebGL Canvas"]:::gpu
    end

    %% Data Store
    DataDir["data/"]:::data
    DataDir -->|contains| DataStore
    DataStore["stent.nrrd"]:::data

    %% Data flow and interactions
    HTML -->|imports| three
    HTML -->|imports| webgl
    HTML -->|imports| orbit
    loader -->|parses| vol
    vol -->|supplies volume to| shader
    shader -->|compiled in| webgl
    three -->|initializes context in| webgl
    webgl -->|renders to| canvas
    render -->|draws| canvas
    orbit -->|controls camera in| render
    DataStore -->|loaded by| loader

    %% Click Events
    click HTML "https://github.com/zhongjianghan/3dct/blob/master/index.html"
    click three "https://github.com/zhongjianghan/3dct/blob/master/js/build/three.js"
    click loader "https://github.com/zhongjianghan/3dct/blob/master/js/NRRDLoader.js"
    click vol "https://github.com/zhongjianghan/3dct/blob/master/js/Volume.js"
    click shader "https://github.com/zhongjianghan/3dct/blob/master/js/VolumeShader.js"
    click webgl "https://github.com/zhongjianghan/3dct/blob/master/js/WebGL.js"
    click orbit "https://github.com/zhongjianghan/3dct/blob/master/js/OrbitControls.js"
    click DataStore "https://github.com/zhongjianghan/3dct/blob/master/data/stent.nrrd"
    click DataDir "https://github.com/zhongjianghan/3dct/tree/master/data/"

    %% Styles
    classDef server fill:#f9f,stroke:#333,stroke-width:2px
    classDef asset fill:#bbf,stroke:#333,stroke-width:1px
    classDef library fill:#f96,stroke:#333,stroke-width:1px
    classDef module fill:#9f6,stroke:#333,stroke-width:1px
    classDef data fill:#ffeb3b,stroke:#333,stroke-width:1px
    classDef gpu fill:#f48fb1,stroke:#333,stroke-width:1px
    classDef runtime fill:#ccc,stroke:#333,stroke-width:1px
```
