# johnson-natanael/floodanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/johnson-natanael/floodanalysis
- Repository: https://github.com/johnson-natanael/floodanalysis

## Overview

1. **Repository purpose**
   - This is a geospatial flood/coastal-change analysis project, not just a generic web app.
   - The codebase combines offline raster prediction pipelines with a Python-based presentation layer for browsing results.

2. **Core data products**
   - The main outputs are GeoTIFF rasters under `modules/LANDSAT8/` and `modules/SENTINEL2/`.
   - These files represent time-sliced predictions, e.g. Landsat 8 half-year intervals and Sentinel-2 quarterly intervals from 2013–2024.
   - A derived CSV, `web_app/hasil_akresi_abrasi_per_tahun.csv`, suggests yearly summary metrics for shoreline change or similar environmental change.

3. **Modeling / inference subsystem**
   - `modules/landsat_model.py` and `modules/sentinel_model.py` are the two model pipelines, each tied to a different satellite source.
   - Their output artifacts are precomputed rasters, which means model execution is likely batch/offline rather than interactive.
   - The naming pattern indicates separate temporal cadences and possibly separate preprocessing/model parameters per sensor.

4. **Geospatial post-processing subsystem**
   - `modules/coastline.py` likely extracts or transforms coastline geometry/metrics from raster predictions.
   - `modules/combine_hasil.py` appears to merge multiple model outputs into consolidated results, likely producing the yearly CSV consumed by the app.
   - These scripts are the main boundary between raw prediction rasters and human-readable analytical summaries.

5. **Satellite-source separation**
   - The repository explicitly splits Landsat 8 and Sentinel-2 into distinct pipelines and artifact directories.
   - That suggests different input characteristics, resolutions, or time windows are handled independently before any comparison or aggregation.
   - An architecture diagram should show these as parallel upstream sources feeding into shared post-processing.

6. **Web presentation layer**
   - `web_app/` contains the user-facing application with `app.py`, HTML templates, and CSS assets.
   - The template set (`dashboard.html`, `detail.html`, `predict.html`, `comparison.html`) indicates multiple views: overview, drill-down detail, prediction visualization, and side-by-side comparison.
   - This layer is primarily read-only and visualizes precomputed data rather than running the geospatial models live.

7. **Static asset boundary**
   - `web_app/static/assets/` stores map imagery and derived files used by the UI.
   - Subfolders like `predictions`, `predictions_old`, `compare`, `coastlines`, and `custom_model` suggest the UI consumes multiple asset categories: current predictions, historical comparisons, coastline overlays, and custom inputs.
   - `raw_data.tif` under `custom_model` implies the app may support user-supplied geospatial input or a custom analysis mode.

8. **Data flow through the system**
   - Satellite-derived inputs are processed by the model scripts in `modules/`.
   - The resulting GeoTIFFs are stored as versioned artifacts by sensor and time period.
   - Post-processing scripts combine those rasters into summary outputs such as the yearly CSV.
   - The web app then reads the static rasters and tabular summaries to render dashboards and comparison pages.

9. **Technology profile**
   - The project is Python-based end to end.
   - The presence of `templates/` and `static/` strongly implies a Flask-style server architecture, even though the framework isn’t explicitly shown in the tree.
   - The heavy use of `.tif` files indicates geospatial raster tooling is a central dependency of the offline pipeline.

10. **Operational shape**
   - This is a file-backed analytics system: the “database” is effectively a set of raster artifacts plus a CSV summary.
   - There is no sign of a separate backend service, queue, or external storage layer in the tree.
   - The important architectural boundary is between offline geoprocessing and online visualization.

11. **What to draw in an architecture diagram**
   - Show two independent upstream pipelines: Landsat 8 and Sentinel-2.
   - Show their outputs landing as GeoTIFF prediction artifacts.
   - Show a post-processing/aggregation step producing yearly summary data.
   - Show the web app reading those static outputs and rendering dashboard, detail, prediction, and comparison views.

12. **Notable repo characteristic**
   - The repository is artifact-heavy and code-light: many outputs are already committed.
   - That makes the system closer to a packaged analysis product than a purely source-driven application.

Main entry points: [`web_app/app.py`](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/app.py) (Web app), [`modules/LANDSAT8`](https://github.com/johnson-natanael/floodanalysis/tree/main/modules/LANDSAT8) (Landsat rasters), [`modules/SENTINEL2`](https://github.com/johnson-natanael/floodanalysis/tree/main/modules/SENTINEL2) (Sentinel rasters), [`modules/combine_hasil.py`](https://github.com/johnson-natanael/floodanalysis/blob/main/modules/combine_hasil.py) (Combine results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline geoprocessing"]
  node_landsat_model["Landsat model<br/>Python inference<br/>[landsat_model.py]"]
  node_sentinel_model["Sentinel model<br/>Python inference<br/>[sentinel_model.py]"]
  node_landsat_rasters[("Landsat rasters<br/>GeoTIFF outputs")]
  node_sentinel_rasters[("Sentinel rasters<br/>GeoTIFF outputs")]
  node_coastline["Coastline processing<br/>Geo spatial transform<br/>[coastline.py]"]
  node_combine_hasil["Combine results<br/>Aggregation script<br/>[combine_hasil.py]"]
end

subgraph group_presentation["Presentation layer"]
  node_yearly_csv["Yearly summary<br/>CSV summary"]
  node_web_app["Web app<br/>Python UI<br/>[app.py]"]
  node_dashboard_view["Dashboard<br/>Template view<br/>[dashboard.html]"]
  node_detail_view["Detail view<br/>Template view<br/>[detail.html]"]
  node_predict_view["Prediction view<br/>Template view<br/>[predict.html]"]
  node_comparison_view["Comparison view<br/>Template view<br/>[comparison.html]"]
  node_pred_assets[("Predictions<br/>Static assets")]
  node_pred_old_assets[("Old predictions<br/>Static assets")]
  node_compare_assets[("Compare assets<br/>Static assets")]
  node_coast_assets[("Coastline assets<br/>Static assets")]
  node_custom_model["Custom input<br/>Static asset<br/>[raw_data.tif]"]
end

node_landsat_model -->|"writes"| node_landsat_rasters
node_sentinel_model -->|"writes"| node_sentinel_rasters
node_landsat_rasters -->|"feeds"| node_coastline
node_sentinel_rasters -->|"feeds"| node_coastline
node_landsat_rasters -->|"feeds"| node_combine_hasil
node_sentinel_rasters -->|"feeds"| node_combine_hasil
node_combine_hasil -->|"produces"| node_yearly_csv
node_yearly_csv -->|"consumed by"| node_web_app
node_pred_assets -->|"served to"| node_web_app
node_pred_old_assets -->|"supports"| node_comparison_view
node_compare_assets -->|"supports"| node_comparison_view
node_coast_assets -->|"supports"| node_detail_view
node_custom_model -->|"supports"| node_predict_view
node_web_app -->|"renders"| node_dashboard_view
node_web_app -->|"renders"| node_detail_view
node_web_app -->|"renders"| node_predict_view
node_web_app -->|"renders"| node_comparison_view

click node_landsat_model "https://github.com/johnson-natanael/floodanalysis/blob/main/modules/landsat_model.py"
click node_sentinel_model "https://github.com/johnson-natanael/floodanalysis/blob/main/modules/sentinel_model.py"
click node_landsat_rasters "https://github.com/johnson-natanael/floodanalysis/tree/main/modules/LANDSAT8"
click node_sentinel_rasters "https://github.com/johnson-natanael/floodanalysis/tree/main/modules/SENTINEL2"
click node_coastline "https://github.com/johnson-natanael/floodanalysis/blob/main/modules/coastline.py"
click node_combine_hasil "https://github.com/johnson-natanael/floodanalysis/blob/main/modules/combine_hasil.py"
click node_yearly_csv "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/hasil_akresi_abrasi_per_tahun.csv"
click node_web_app "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/app.py"
click node_dashboard_view "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/dashboard.html"
click node_detail_view "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/detail.html"
click node_predict_view "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/predict.html"
click node_comparison_view "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/comparison.html"
click node_pred_assets "https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/predictions"
click node_pred_old_assets "https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/predictions_old"
click node_compare_assets "https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/compare"
click node_coast_assets "https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/coastlines"
click node_custom_model "https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/static/assets/custom_model/raw_data.tif"

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_landsat_model,node_sentinel_model,node_landsat_rasters,node_sentinel_rasters,node_coastline,node_combine_hasil toneBlue
class node_yearly_csv,node_web_app,node_dashboard_view,node_detail_view,node_predict_view,node_comparison_view,node_pred_assets,node_pred_old_assets,node_compare_assets,node_coast_assets,node_custom_model toneAmber
```

## Components

### Offline geoprocessing

Batch satellite model pipelines and raster post-processing.

- [Landsat model](https://github.com/johnson-natanael/floodanalysis/blob/main/modules/landsat_model.py): Python inference · Offline Landsat 8 prediction pipeline. · `modules/landsat_model.py`
- [Sentinel model](https://github.com/johnson-natanael/floodanalysis/blob/main/modules/sentinel_model.py): Python inference · Offline Sentinel-2 prediction pipeline. · `modules/sentinel_model.py`
- [Landsat rasters](https://github.com/johnson-natanael/floodanalysis/tree/main/modules/LANDSAT8): GeoTIFF outputs · Versioned half-year prediction artifacts for Landsat 8. · `modules/LANDSAT8`
- [Sentinel rasters](https://github.com/johnson-natanael/floodanalysis/tree/main/modules/SENTINEL2): GeoTIFF outputs · Versioned quarterly prediction artifacts for Sentinel-2. · `modules/SENTINEL2`
- [Coastline processing](https://github.com/johnson-natanael/floodanalysis/blob/main/modules/coastline.py): Geo spatial transform · Derives coastline metrics or geometry from prediction rasters. · `modules/coastline.py`
- [Combine results](https://github.com/johnson-natanael/floodanalysis/blob/main/modules/combine_hasil.py): Aggregation script · Merges model outputs into consolidated analytical results. · `modules/combine_hasil.py`

### Presentation layer

Web app that reads committed rasters and summary data.

- [Yearly summary](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/hasil_akresi_abrasi_per_tahun.csv): CSV summary · Annual akresi/abrasi metric used by the web app. · `web_app/hasil_akresi_abrasi_per_tahun.csv`
- [Web app](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/app.py): Python UI · Presentation layer for browsing predictions and summaries. · `web_app/app.py`
- [Dashboard](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/dashboard.html): Template view · Overview page for system-wide results. · `web_app/templates/dashboard.html`
- [Detail view](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/detail.html): Template view · Drill-down page for a specific result or area. · `web_app/templates/detail.html`
- [Prediction view](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/predict.html): Template view · Page for viewing prediction rasters and related outputs. · `web_app/templates/predict.html`
- [Comparison view](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/templates/comparison.html): Template view · Side-by-side comparison page for different periods or sources. · `web_app/templates/comparison.html`
- [Predictions](https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/predictions): Static assets · Current raster imagery and derived files served to the UI. · `web_app/static/assets/predictions`
- [Old predictions](https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/predictions_old): Static assets · Historical or legacy prediction imagery used for comparison. · `web_app/static/assets/predictions_old`
- [Compare assets](https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/compare): Static assets · Comparison imagery and overlays for multi-period viewing. · `web_app/static/assets/compare`
- [Coastline assets](https://github.com/johnson-natanael/floodanalysis/tree/main/web_app/static/assets/coastlines): Static assets · Rendered coastline overlays and related map artifacts. · `web_app/static/assets/coastlines`
- [Custom input](https://github.com/johnson-natanael/floodanalysis/blob/main/web_app/static/assets/custom_model/raw_data.tif): Static asset · User-supplied geospatial input for custom analysis mode. · `web_app/static/assets/custom_model/raw_data.tif`

## Connections

- Landsat model → Landsat rasters: writes · Produces Landsat 8 GeoTIFF prediction artifacts.
- Sentinel model → Sentinel rasters: writes · Produces Sentinel-2 GeoTIFF prediction artifacts.
- Landsat rasters → Coastline processing: feeds · Raster outputs are transformed into coastline metrics.
- Sentinel rasters → Coastline processing: feeds · Raster outputs are transformed into coastline metrics.
- Landsat rasters → Combine results: feeds · Landsat rasters contribute to consolidated summaries.
- Sentinel rasters → Combine results: feeds · Sentinel rasters contribute to consolidated summaries.
- Combine results → Yearly summary: produces · Creates annual shoreline-change summary data.
- Yearly summary → Web app: consumed by · Tabular annual metrics are read by the presentation layer.
- Predictions → Web app: served to · Primary prediction imagery consumed by the UI.
- Old predictions → Comparison view: supports · Historical predictions used in comparison workflows.
- Compare assets → Comparison view: supports · Comparison assets drive side-by-side visualizations.
- Coastline assets → Detail view: supports · Coastline overlays are shown in detail pages.
- Custom input → Prediction view: supports · Custom raster input enables user-driven prediction viewing.
- Web app → Dashboard: renders · Main overview page.
- Web app → Detail view: renders · Drill-down page.
- Web app → Prediction view: renders · Prediction visualization page.
- Web app → Comparison view: renders · Comparison page.
