# domumdigital/ocaf architecture

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

- Interactive diagram: https://gitdiagram.com/domumdigital/ocaf
- Repository: https://github.com/domumdigital/ocaf

## Overview

##### Project type and purpose
- This is a lightweight, static, single-page web application (“OCAF Worksheet Calculator”) whose sole purpose is to let a user quickly calculate their property’s OCAF.
- There is no traditional backend service: all logic and data live in the browser as HTML, CSS, JS, and a local JSON file with OCAF factors.

##### File structure
- index.html, ocaf-worksheet-faq.html, ocaf-worksheet-guide.html, etc. → the site’s entry points/view templates.
- css/ → styles for different pages (faq-styles.css, guide-styles.css, etc.) and a global styles.css.
- js/ → application logic split into app.js, config.js, faq.js, and general-purpose code in config.js.
- data/ocaf-factors.json → the static data source for calculation factors.
- wrangler.jsonc → deployment configuration (likely for Cloudflare Workers or Pages).

##### Extract key insights from the README
- The HTML files reference the JS and CSS assets and call out where interactivity is hooked in (e.g., a clickable image).
- The README mentions style.css and script.js generically, but your real files are more granular (styles per page, JS modules per functionality).

##### Main components
a. Web Browser (Client)
b. Static Asset Host / CDN / Cloudflare (Deployment target via wrangler.jsonc)
c. HTML Views (index.html, FAQ, Guide, etc.)
d. CSS Modules (global styles + page-specific styles)
e. JavaScript Modules (app.js, faq.js, config.js)
f. Data Store (local JSON file with OCAF factors)

##### Relationships & data flow
1) Browser requests index.html from the static host.
2) index.html includes <link> tags pulling in the CSS bundle(s).
3) index.html includes <script> tags loading JS modules in order: config.js → app.js → page-specific JS (faq.js or none).
4) app.js (or a dedicated fetch routine) issues a fetch() call to retrieve data/ocaf-factors.json.
5) JSON is parsed in JS, the calculation logic uses those factors to update the DOM (user input → computed OCAF → rendered output).

##### Architectural patterns & design principles
- Separation of concerns – HTML for structure, CSS for style, JS for logic, JSON for data.
- Modularity in JS – distinct files for configuration (config.js), core app logic (app.js), and page-specific code (faq.js).
- Static site deployment via a serverless platform (inferred from wrangler.jsonc).

##### Technologies/frameworks/libraries
- Pure HTML/CSS/vanilla JavaScript (no front-end framework).
- Cloudflare Wrangler for deployment (wrangler.jsonc).

##### Detail

– It’ll reveal the separation of concerns,
– Highlight runtime interactions (fetching JSON data),
– And show how assets are served/deployed,

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Host
    host["Static Asset Host/CDN"]:::host
    JSON["OCAF Factors JSON"]:::data

    %% Client
    Browser["Web Browser (Client)"]:::browser

    %% Structure Layer
    subgraph "Structure Layer (HTML Views)"
        index["index.html"]:::html
        faqView["ocaf-worksheet-faq.html"]:::html
        guideView["ocaf-worksheet-guide.html"]:::html
        resourcesView["rent-calculation-resources.html"]:::html
        understandingView["understanding-hud-ocaf.html"]:::html
    end

    %% Presentation Layer
    subgraph "Presentation Layer (CSS Stylesheets)"
        stylesCSS["styles.css"]:::css
        faqCSS["faq-styles.css"]:::css
        guideCSS["guide-styles.css"]:::css
        resourcesCSS["resources-styles.css"]:::css
        seoCSS["seo-styles.css"]:::css
    end

    %% Logic Layer
    subgraph "Logic Layer (JavaScript Modules)"
        configJS["config.js"]:::js
        appJS["app.js"]:::js
        faqJS["faq.js"]:::js
    end

    %% Asset Delivery
    host --> Browser

    %% Initial HTML Requests
    Browser --> index
    Browser --> faqView
    Browser --> guideView
    Browser --> resourcesView
    Browser --> understandingView

    %% CSS Loading
    index --> stylesCSS
    faqView --> faqCSS
    guideView --> guideCSS
    resourcesView --> resourcesCSS
    understandingView --> seoCSS

    %% JS Loading
    index --> configJS
    index --> appJS
    faqView --> configJS
    faqView --> appJS
    faqView --> faqJS
    guideView --> configJS
    guideView --> appJS
    resourcesView --> configJS
    resourcesView --> appJS
    understandingView --> configJS
    understandingView --> appJS

    %% Data Fetching & DOM Updates
    appJS -->|"fetch() get factors"| JSON
    appJS -->|"manipulates DOM"| index

    %% Click Events
    click host "https://github.com/domumdigital/ocaf/blob/main/wrangler.jsonc"
    click index "https://github.com/domumdigital/ocaf/blob/main/index.html"
    click faqView "https://github.com/domumdigital/ocaf/blob/main/ocaf-worksheet-faq.html"
    click guideView "https://github.com/domumdigital/ocaf/blob/main/ocaf-worksheet-guide.html"
    click resourcesView "https://github.com/domumdigital/ocaf/blob/main/rent-calculation-resources.html"
    click understandingView "https://github.com/domumdigital/ocaf/blob/main/understanding-hud-ocaf.html"
    click stylesCSS "https://github.com/domumdigital/ocaf/blob/main/css/styles.css"
    click faqCSS "https://github.com/domumdigital/ocaf/blob/main/css/faq-styles.css"
    click guideCSS "https://github.com/domumdigital/ocaf/blob/main/css/guide-styles.css"
    click resourcesCSS "https://github.com/domumdigital/ocaf/blob/main/css/resources-styles.css"
    click seoCSS "https://github.com/domumdigital/ocaf/blob/main/css/seo-styles.css"
    click configJS "https://github.com/domumdigital/ocaf/blob/main/js/config.js"
    click appJS "https://github.com/domumdigital/ocaf/blob/main/js/app.js"
    click faqJS "https://github.com/domumdigital/ocaf/blob/main/js/faq.js"
    click JSON "https://github.com/domumdigital/ocaf/blob/main/data/ocaf-factors.json"

    %% Styles
    classDef host fill:#89CFF0,stroke:#0366d6,color:#000;
    classDef browser fill:#FFFACD,stroke:#f0ad4e,color:#000;
    classDef html fill:#FFB6C1,stroke:#d9534f,color:#000;
    classDef css fill:#ADD8E6,stroke:#5bc0de,color:#000;
    classDef js fill:#D3D3D3,stroke:#292b2c,color:#000;
    classDef data fill:#98FB98,stroke:#5cb85c,color:#000;
```
