# docampo16/frayjorge architecture

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

- Interactive diagram: https://gitdiagram.com/docampo16/frayjorge
- Repository: https://github.com/docampo16/frayjorge

## Overview

##### Project type and purpose
- This is not a traditional multi-tier web app but a data-science workflow implemented entirely as Jupyter notebooks. The goal is to perform land-use and land-cover (LULC) classification for Fray Jorge National Park, using Sentinel-2 (s2) imagery and clustering/classification techniques.

##### File structure
- Top-level files are all notebooks (.ipynb), each covering a stage or variant of the LULC pipeline:
- s2workflow.ipynb – likely ingestion and preprocessing of Sentinel-2 data
- NSClustering_clean.ipynb / NonSupervisedClustering.ipynb – unsupervised clustering experiments
- LULC.ipynb / FJ_LULC.ipynb – supervised classification or final mapping
- No separate ‘src’ or ‘backend’ directories: the logic lives in notebooks.
- Standard .gitignore and README.md show this is a research/code-prototype repo.

##### Extract insights from the README
- Project name: FrayJorge.
- Purpose: Land Use and Land Classification for Fray Jorge National Park.
- No prescribed architecture is described, so we must infer a pipeline workflow.

##### Main components and their interactions
a. Data Ingestion
- External data source: Sentinel-2 satellite imagery (and any ancillary shapefiles or DEMs).
- Notebook: s2workflow.ipynb reads raw raster tiles.
b. Data Preprocessing
- Tasks: atmospheric correction, cloud masking, band stacking, cropping to park boundary.
- Output: clean, analysis-ready raster layers.
c. Feature Extraction
- Compute indices (NDVI, EVI, etc.), dimensionality reduction if any.
- Could happen in the same or a separate notebook.
d. Unsupervised Clustering
- Notebooks: NonSupervisedClustering.ipynb / NSClustering_clean.ipynb.
- Apply k-means, DBSCAN, etc., to segment land cover.
- Output: cluster maps.
e. Supervised Classification
- Notebooks: LULC.ipynb / FJ_LULC.ipynb.
- Train ML models (Random Forest, SVM) using ground-truth labels.
- Produce final classified map.
f. Validation & Visualization
- Generate accuracy metrics, confusion matrices, and final map overlays.
g. Reporting / Export
- Export GeoTIFFs, PNGs, or interactive maps for sharing.

##### Architectural patterns and design principles
- Linear data-pipeline pattern: each notebook represents a stage.
- Reproducibility: notebooks + fixed environment (requirements.txt or conda env).
- Modular: if scaled up later, you could turn notebooks into Python modules/services.

##### Technologies & libraries
- Jupyter Notebook (presentation & orchestration)
- Python geospatial stack: rasterio/GDAL, numpy/pandas, scikit-learn, possibly geopandas, matplotlib/folium
- Sentinel-2 data access via API (e.g., Copernicus Open Access Hub)
- Optional: conda or virtualenv for environment management

##### Diagrammatic conventions
- Keep it to a single A4/slide-size view but allow zoom-in on complex steps (e.g., a zoom-callout for clustering).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Sources
    Data["Sentinel-2 & Ancillary Data"]:::data

    %% Processing Stages
    Ingest["Ingestion & Preprocessing\n(s2workflow.ipynb)"]:::processing
    Feature["Feature Extraction"]:::processing

    %% Unsupervised Clustering
    subgraph "Unsupervised Clustering"
        ClustRaw["Raw Variant\n(NonSupervisedClustering.ipynb)"]:::modeling
        ClustClean["Clean Variant\n(NSClustering_clean.ipynb)"]:::modeling
    end

    %% Supervised Classification
    subgraph "Supervised Classification"
        Sup1["Core Workflow\n(LULC.ipynb)"]:::modeling
        Sup2["Alternate/Final\n(FJ_LULC.ipynb)"]:::modeling
    end

    %% Validation & Output
    Val["Validation & Visualization"]:::output
    Out["Reporting & Export"]:::output

    %% Documentation & Config
    DocReadme["Project Overview & Instructions\n(README.md)"]:::doc
    GitIgnore["Version Control Exclusions\n(.gitignore)"]:::doc

    %% Execution Environment
    subgraph "Execution Environment"
        Env["Python\nrasterio, numpy, pandas,\nscikit-learn, geopandas, matplotlib"]:::env
    end

    %% Data Flow
    Data -->|"raw raster tiles"| Ingest
    Ingest -->|"cleaned raster"| Feature
    Feature -->|"feature vectors"| ClustRaw
    Feature -->|"feature vectors"| ClustClean
    ClustRaw -->|"cluster maps"| Sup1
    ClustClean -->|"cluster maps"| Sup1
    Sup1 -->|"classified map"| Val
    Sup2 -->|"classified map"| Val
    Val -->|"reports & maps"| Out

    %% Documentation Links
    DocReadme --- Data
    GitIgnore --- Ingest

    %% Click Events
    click Ingest "https://github.com/docampo16/frayjorge/blob/main/s2workflow.ipynb"
    click ClustRaw "https://github.com/docampo16/frayjorge/blob/main/NonSupervisedClustering.ipynb"
    click ClustClean "https://github.com/docampo16/frayjorge/blob/main/NSClustering_clean.ipynb"
    click Sup1 "https://github.com/docampo16/frayjorge/blob/main/LULC.ipynb"
    click Sup2 "https://github.com/docampo16/frayjorge/blob/main/FJ_LULC.ipynb"
    click DocReadme "https://github.com/docampo16/frayjorge/blob/main/README.md"
    click GitIgnore "https://github.com/docampo16/frayjorge/blob/main/.gitignore"

    %% Styles
    classDef data fill:#cce5ff,stroke:#004085,color:#004085;
    classDef processing fill:#d4edda,stroke:#155724,color:#155724;
    classDef modeling fill:#fff3cd,stroke:#856404,color:#856404;
    classDef output fill:#e2d4f0,stroke:#4a006e,color:#4a006e;
    classDef doc fill:#f8f9fa,stroke:#6c757d,color:#6c757d;
    classDef env fill:#ffe5b4,stroke:#cc7a00,color:#cc7a00;
```
