# mitchleahy/roofrate architecture

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

- Interactive diagram: https://gitdiagram.com/mitchleahy/roofrate
- Repository: https://github.com/mitchleahy/roofrate

## Overview

##### Project Type and Purpose
- This is a Python‐based demo application (“RoofRate”) whose primary goal is to showcase roof‐rating models and, secondarily, to collect new roof image data for annotation.
- It is not a full multi‐service microservice deployment; rather, it is a single‐process Python app (invoked via `app.py`), augmented by modules for model inference, image/data processing, and cloud storage setup.

##### Top‐Level Components
- **Application Entrypoint**:
- app.py – the “main” script.
- prompt.txt – auxiliary prompt used by the app (e.g., for CLI interactions or model prompting).
- **Core Modules (src/app)**:
- src/app/roof_processing/processing.py – routines for processing roof images (pre/post-processing).
- src/app/utils.py – shared utilities (I/O, logging, configuration).
- **Data & Model Templates (templates)**:
- demo_data.py – example data loader or stubs.
- demo_model.py – a stub/model wrapper for the RoofRate model.
- **Storage Setup (src/db)**:
- azure_blob_csv_setup.py – scripts to configure and write results (predictions, metadata) to Azure Blob Storage as CSV.
- **Supporting Artifacts**:
- scratch.ipynb – experimentation notebook.
- requirements.txt – Python dependencies.
- .GitHub/workflows/added-app_roofrate.yml – CI workflow to install, lint/test, or deploy.

##### External Services
- **Azure Blob Storage** for persisting processed outputs & CSV files.
- (Optional) CLI or interactive prompt for the user to supply new roof images.

##### Architectural Patterns & Design Principles
- **Modular layering**: Entry → Data/Model Templates → Processing → Storage.
- **Separation of concerns**:
- “templates” folder holds plug-and-play data/model stubs, so swapping in a new model is straightforward.
- “src/db” isolates all cloud‐storage logic.
- **Single‐process orchestration** with clear dataflow between modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Invocation
    User(["User/CLI"]):::external
    User -->|"invokes"| App

    %% Application Entrypoint
    App["app.py (Orchestrator)"]:::repo
    click App "https://github.com/mitchleahy/roofrate/blob/main/app.py"

    %% Prompt Template
    Prompt["prompt.txt"]:::repo
    click Prompt "https://github.com/mitchleahy/roofrate/blob/main/prompt.txt"
    App -->|"loads prompt"| Prompt

    %% Core Modules Group
    subgraph "Core Modules (src/app)" 
        direction TB
        Proc["processing.py"]:::repo
        click Proc "https://github.com/mitchleahy/roofrate/blob/main/src/app/roof_processing/processing.py"
        Utils["utils.py"]:::repo
        click Utils "https://github.com/mitchleahy/roofrate/blob/main/src/app/utils.py"
        Proc -->|"uses utilities"| Utils
    end
    App -->|"calls processing"| Proc

    %% Data & Model Templates Group
    subgraph "Data & Model Templates (templates)"
        direction TB
        DataStub["demo_data.py"]:::template
        click DataStub "https://github.com/mitchleahy/roofrate/blob/main/templates/demo_data.py"
        ModelStub["demo_model.py"]:::template
        click ModelStub "https://github.com/mitchleahy/roofrate/blob/main/templates/demo_model.py"
    end
    App -->|"loads data stub"| DataStub
    App -->|"loads model stub"| ModelStub

    %% Storage Setup
    subgraph "Storage Setup (src/db)"
        direction TB
        StorageSetup["azure_blob_csv_setup.py"]:::repo
        click StorageSetup "https://github.com/mitchleahy/roofrate/blob/main/src/db/azure_blob_csv_setup.py"
    end
    App -->|"invokes storage setup"| StorageSetup

    %% External Service
    Azure["Azure Blob Storage"]:::external
    StorageSetup -->|"writes CSV"| Azure

    %% CI Pipeline
    CI["GitHub Actions\n(added-app_roofrate.yml)"]:::ci
    click CI "https://github.com/mitchleahy/roofrate/blob/main/.github/workflows/added-app_roofrate.yml"
    CI -->|"build/test/deploy"| App

    %% Experimentation Notebook
    Notebook["scratch.ipynb"]:::notebook
    click Notebook "https://github.com/mitchleahy/roofrate/blob/main/scratch.ipynb"
    Notebook -.->|"sandbox experiments"| Proc

    %% Dependency Spec
    Req["requirements.txt"]:::repo
    click Req "https://github.com/mitchleahy/roofrate/blob/main/requirements.txt"

    %% Styles
    classDef repo fill:#E8F1FF,stroke:#0366D6,stroke-width:1px;
    classDef external fill:#FFF5B1,stroke:#DAA520,stroke-width:1px;
    classDef ci fill:#E6FFEA,stroke:#28A745,stroke-width:1px,stroke-dasharray: 5 5;
    classDef notebook fill:#FFE8E8,stroke:#D73A49,stroke-width:1px;
    classDef template fill:#E8FFE8,stroke:#22863A,stroke-width:1px;
```
