# aaditya01sehgal/holospark architecture

> Architecture diagram of the GitHub repository aaditya01sehgal/holospark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aaditya01sehgal/holospark
- Repository: https://github.com/aaditya01sehgal/holospark

## Overview

#### Purpose and topology
HoloSpark converts a 2D image into a depth-informed, phase-only hologram. It is a three-tier system: React/Vite user interface, Spring Boot orchestration/API, and a Python/PyTorch image-processing and computational-holography engine.

#### Entry points
- React application bootstrap: `HoloSpark_Frontend/src/main.jsx`; root UI and routing/state composition: `HoloSpark_Frontend/src/App.jsx`.
- Spring Boot server bootstrap: `HoloSpark_Backend/src/main/java/com/holo/HoloApplication.java`.
- Python operational entry point: `HoloSpark_AI_Engine/inference.py`; model training/evaluation entry points are `HoloSpark_AI_Engine/train_ccnn.py` and `HoloSpark_AI_Engine/evaluate_div2k.py`.

#### User interaction and presentation
The frontend owns image submission, processing feedback, errors, and rendering of generated artifacts. The generation workflow is centered in `HoloSpark_Frontend/src/pages/GeneratePage.jsx`, with upload and output boundaries in `HoloSpark_Frontend/src/components/UploadSection.jsx` and `HoloSpark_Frontend/src/components/ResultsSection.jsx`. It runs on Node/Vite and communicates with the backend rather than directly invoking AI models.

#### API orchestration and file boundary
Spring Boot exposes the hologram workflow through `HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java`. `HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java` manages upload/result filesystem handling, while `HoloSpark_Backend/src/main/java/com/holo/service/PythonBridgeService.java` is the cross-runtime boundary that launches or coordinates Python inference. Application/CORS/static-server behavior is configured through `HoloSpark_Backend/src/main/resources/application.properties` and `HoloSpark_Backend/src/main/java/com/holo/config/WebConfig.java`.

#### AI pipeline: scene geometry and views
Python inference transforms the submitted source into depth and synthesized viewpoints. `HoloSpark_AI_Engine/src/depth_estimator.py` encapsulates monocular MiDaS-based depth prediction. `HoloSpark_AI_Engine/src/view_synth.py` performs depth-image-based rendering/parallax and occlusion handling. `HoloSpark_AI_Engine/src/holo_effect.py` and `HoloSpark_AI_Engine/src/holography.py` connect image/depth representations to hologram-oriented processing.

#### AI pipeline: optical encoding and refinement
The wave-optics stage performs phase encoding and angular-spectrum propagation, with FFT-oriented implementation in `HoloSpark_AI_Engine/src/asm_layer.py`. The learned enhancement path is defined by `HoloSpark_AI_Engine/src/ccnn_model.py`, supported by complex-valued operations in `HoloSpark_AI_Engine/src/complex_layers.py` and EDSR-based refinement in `HoloSpark_AI_Engine/src/edsr_module.py`. Checkpoint artifacts reside under `HoloSpark_AI_Engine/shared_data/checkpoints/`.

#### End-to-end control and outputs
Control flows from browser upload → Spring controller/storage → Python bridge/inference → depth, view, phase, and refined hologram artifacts → backend response/storage → frontend results display. The core runtime boundary is Java process/filesystem orchestration to Python; model execution depends on Python 3.10+, PyTorch, MiDaS, OpenCV, NumPy, and likely GPU acceleration. Backend metrics/results are materialized under `HoloSpark_Backend/shared_data/results/metrics.json`.

Main entry points: [`HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java`](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java) (Hologram API), [`HoloSpark_Frontend/src/pages/GeneratePage.jsx`](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/pages/GeneratePage.jsx) (Generation workflow), [`HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java`](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java) (File storage), [`HoloSpark_AI_Engine/src/ccnn_model.py`](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/ccnn_model.py) (Learned refinement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React/Vite frontend"]
  node_fe_bootstrap["Frontend bootstrap<br/>React entry<br/>[main.jsx]"]
  node_fe_app["App shell and state<br/>React composition<br/>[App.jsx]"]
  node_generate_page["Generation workflow<br/>React page<br/>[GeneratePage.jsx]"]
  node_upload_ui["Image upload<br/>React component<br/>[UploadSection.jsx]"]
  node_results_ui["Hologram results<br/>React component<br/>[ResultsSection.jsx]"]
end

subgraph group_backend["Spring Boot backend"]
  node_backend_bootstrap["Backend bootstrap<br/>Spring Boot entry"]
  node_controller["Hologram API<br/>Spring controller"]
  node_storage[("File storage<br/>filesystem service")]
  node_python_bridge{{"Python bridge<br/>cross-runtime service"}}
  node_metrics["Result metrics<br/>result artifact<br/>[metrics.json]"]
end

subgraph group_engine["Python AI engine"]
  node_inference["Inference pipeline<br/>Python entry<br/>[inference.py]"]
  node_depth["Monocular depth<br/>MiDaS estimator<br/>[depth_estimator.py]"]
  node_views["View synthesis<br/>DIBR pipeline<br/>[view_synth.py]"]
  node_holo_processing["Hologram processing<br/>image-depth conversion<br/>[holography.py]"]
  node_wave_optics["Phase encoding and propagation<br/>angular-spectrum optics<br/>[asm_layer.py]"]
  node_refinement["Learned refinement<br/>CCNN + EDSR<br/>[ccnn_model.py]"]
  node_checkpoints[("Model checkpoints<br/>model artifacts")]
  node_training["Training and evaluation<br/>Python offline workflow<br/>[train_ccnn.py]"]
end

node_fe_bootstrap -->|"mounts"| node_fe_app
node_fe_app -->|"composes"| node_generate_page
node_generate_page -->|"collects image"| node_upload_ui
node_generate_page -->|"submits workflow"| node_controller
node_controller -->|"stores input/results"| node_storage
node_controller -->|"starts inference"| node_python_bridge
node_python_bridge -->|"process/filesystem boundary"| node_inference
node_inference -->|"predicts depth"| node_depth
node_depth -->|"depth map"| node_views
node_views -->|"synthesized views"| node_holo_processing
node_holo_processing -->|"optical representation"| node_wave_optics
node_wave_optics -->|"phase hologram"| node_refinement
node_checkpoints -.->|"loads weights"| node_refinement
node_refinement -->|"generated artifacts"| node_storage
node_storage -->|"materializes"| node_metrics
node_controller -->|"returns artifacts"| node_results_ui
node_training -->|"writes checkpoints"| node_checkpoints

click node_fe_bootstrap "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/main.jsx"
click node_fe_app "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/App.jsx"
click node_generate_page "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/pages/GeneratePage.jsx"
click node_upload_ui "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/components/UploadSection.jsx"
click node_results_ui "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/components/ResultsSection.jsx"
click node_backend_bootstrap "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/HoloApplication.java"
click node_controller "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java"
click node_storage "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java"
click node_python_bridge "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/service/PythonBridgeService.java"
click node_metrics "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/shared_data/results/metrics.json"
click node_inference "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/inference.py"
click node_depth "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/depth_estimator.py"
click node_views "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/view_synth.py"
click node_holo_processing "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/holography.py"
click node_wave_optics "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/asm_layer.py"
click node_refinement "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/ccnn_model.py"
click node_training "https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/train_ccnn.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fe_bootstrap,node_fe_app,node_generate_page,node_upload_ui,node_results_ui toneBlue
class node_backend_bootstrap,node_controller,node_storage,node_python_bridge,node_metrics toneAmber
class node_inference,node_depth,node_views,node_holo_processing,node_wave_optics,node_refinement,node_checkpoints,node_training toneMint
```

## Components

### React/Vite frontend

- [Frontend bootstrap](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/main.jsx): React entry · `HoloSpark_Frontend/src/main.jsx`
- [App shell and state](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/App.jsx): React composition · `HoloSpark_Frontend/src/App.jsx`
- [Generation workflow](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/pages/GeneratePage.jsx): React page · Coordinates submission, progress, and errors. · `HoloSpark_Frontend/src/pages/GeneratePage.jsx`
- [Image upload](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/components/UploadSection.jsx): React component · `HoloSpark_Frontend/src/components/UploadSection.jsx`
- [Hologram results](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Frontend/src/components/ResultsSection.jsx): React component · `HoloSpark_Frontend/src/components/ResultsSection.jsx`

### Spring Boot backend

- [Backend bootstrap](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/HoloApplication.java): Spring Boot entry · `HoloSpark_Backend/src/main/java/com/holo/HoloApplication.java`
- [Hologram API](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java): Spring controller · Receives workflow requests and returns generated artifacts. · `HoloSpark_Backend/src/main/java/com/holo/controller/HologramController.java`
- [File storage](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java): filesystem service · Manages uploaded inputs and generated result files. · `HoloSpark_Backend/src/main/java/com/holo/service/FileStorageService.java`
- [Python bridge](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/src/main/java/com/holo/service/PythonBridgeService.java): cross-runtime service · Launches or coordinates Python inference. · `HoloSpark_Backend/src/main/java/com/holo/service/PythonBridgeService.java`
- [Result metrics](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_Backend/shared_data/results/metrics.json): result artifact · `HoloSpark_Backend/shared_data/results/metrics.json`

### Python AI engine

- [Inference pipeline](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/inference.py): Python entry · Orchestrates depth, view synthesis, phase encoding, and refinement. · `HoloSpark_AI_Engine/inference.py`
- [Monocular depth](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/depth_estimator.py): MiDaS estimator · `HoloSpark_AI_Engine/src/depth_estimator.py`
- [View synthesis](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/view_synth.py): DIBR pipeline · Creates parallax views with occlusion handling. · `HoloSpark_AI_Engine/src/view_synth.py`
- [Hologram processing](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/holography.py): image-depth conversion · `HoloSpark_AI_Engine/src/holography.py`
- [Phase encoding and propagation](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/asm_layer.py): angular-spectrum optics · FFT-based phase-only hologram computation. · `HoloSpark_AI_Engine/src/asm_layer.py`
- [Learned refinement](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/src/ccnn_model.py): CCNN + EDSR · Enhances computed holograms with complex-valued learned layers. · `HoloSpark_AI_Engine/src/ccnn_model.py`
- **Model checkpoints**: model artifacts
- [Training and evaluation](https://github.com/aaditya01sehgal/holospark/blob/main/HoloSpark_AI_Engine/train_ccnn.py): Python offline workflow · Trains CCNN and evaluates on DIV2K. · `HoloSpark_AI_Engine/train_ccnn.py`

## Connections

- Frontend bootstrap → App shell and state: mounts
- App shell and state → Generation workflow: composes
- Generation workflow → Image upload: collects image
- Generation workflow → Hologram API: submits workflow
- Hologram API → File storage: stores input/results
- Hologram API → Python bridge: starts inference
- Python bridge → Inference pipeline: process/filesystem boundary
- Inference pipeline → Monocular depth: predicts depth
- Monocular depth → View synthesis: depth map
- View synthesis → Hologram processing: synthesized views
- Hologram processing → Phase encoding and propagation: optical representation
- Phase encoding and propagation → Learned refinement: phase hologram
- Model checkpoints → Learned refinement: loads weights
- Learned refinement → File storage: generated artifacts
- File storage → Result metrics: materializes
- Hologram API → Hologram results: returns artifacts
- Training and evaluation → Model checkpoints: writes checkpoints
