# gustaavoevangelista/real-estate architecture

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

- Interactive diagram: https://gitdiagram.com/gustaavoevangelista/real-estate
- Repository: https://github.com/gustaavoevangelista/real-estate

## Overview

##### Project type and purpose
- This is a static, client-side web application (real-estate search) built with plain HTML, CSS and JavaScript.
- Its sole responsibility is to present a search form, fetch property data from a third-party real-estate API, and render dynamic “property cards” on the page.

##### File structure
- Top-level files:
- index.html – main entry point with search form and results container
- rent.html – variant of index.html preset to “rent” mode
- style/style.css – styling for the UI
- js/index.js – handles “buy” searches and form events
- js/rent.js – handles “rent” searches and form events
- js/utils.js – shared helper functions (API call wrapper, card-templating logic)
- No backend code or database; external API is the only data source.
- Hosted on a static-hosting platform (e.g. Netlify).

##### README for additional insights
- Purpose: search by state code + city for sale or rent.
- Challenge: dynamic card generation after fetch.
- No mention of authentication, caching, or offline support.

a. Main components:
- User’s Browser (UI Layer)
- Static Host (e.g. Netlify) serving HTML/CSS/JS assets
- JavaScript Modules (index.js, rent.js, utils.js)
- External Real-Estate API Service (third-party)
b. Relationships / Interactions:
- User inputs state & city in form → browser JS captures event
- JS (utils.js) constructs API request → sends HTTPS GET to external API
- API responds with JSON property data → utils.js processes it
- JS dynamically generates HTML “cards” → updates DOM → browser renders
c. Architectural patterns / principles:
- Single Page Application (SPA) style (two HTML entry points, but identical flow)
- Separation of concerns: utils.js for data fetching & templating, index.js/rent.js for event handling
- No server-side logic; client-only MV* (very light Model = API JSON, View = HTML/CSS, Controller = JS handlers)
d. Key technologies / libraries:
- Vanilla JS (ES6 modules or simple script tags)
- Fetch API (built-in browser)
- CSS for styling, no frameworks

##### Diagramming recommendations
- Components & labels:
- Rectangle for Static Host
- Browser as another rectangle containing sub-components: Form Handler, API Client, Card Generator, DOM Renderer
- From User → Form Handler → API Client → External API → API Client → Card Generator → DOM Renderer → Browser View → User
- Blue rectangles: internal components (Form Handler, Card Generator)
- Green rectangle: Static Host
- Orange cloud: External API
- Request direction (+ parameters) and response direction (+ JSON data)

##### Detail
- Error-handling path (e.g., “onFetchError → display error message”)
- Performance considerations (e.g., “API rate limits”)

- Shows all moving parts (static host, browser modules, external API)
- Illustrates data flow from user input through API to dynamic UI rendering
- Is tailored specifically to this front-end real-estate search application

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user
    StaticHost["Static Host\n(Netlify)"]:::host
    subgraph "Browser (Client)" 
        direction TB
        BrowserView["Browser View"]:::client
        subgraph "Assets"
            direction TB
            HTMLBuy["index.html"]:::asset
            HTMLRent["rent.html"]:::asset
            Styles["style/style.css"]:::asset
            Images["img/"]:::asset
        end
        subgraph "JS Modules"
            direction TB
            BuyHandler["Buy Form Handler\n(js/index.js)"]:::module
            RentHandler["Rent Form Handler\n(js/rent.js)"]:::module
            APIUtil["API Client\n(js/utils.js)"]:::module
            CardGen["Card Generator\n(js/utils.js)"]:::module
            DOMRender["DOM Renderer"]:::module
        end
    end
    ExternalAPI["External Real-Estate API"]:::external

    User -->|loads| StaticHost
    StaticHost -->|serves assets| BrowserView
    User -->|interacts| BrowserView
    BrowserView -->|submit buy form| BuyHandler
    BrowserView -->|submit rent form| RentHandler
    BuyHandler -->|"construct GET /properties?state=&city="| APIUtil
    RentHandler -->|"construct GET /properties?state=&city="| APIUtil
    APIUtil -->|GET Request| ExternalAPI
    ExternalAPI -->|JSON Response| APIUtil
    APIUtil -->|raw data| CardGen
    CardGen -->|HTML cards| DOMRender
    DOMRender -->|update DOM| BrowserView

    subgraph "Documentation & Metadata"
        Pkg["package.json"]:::doc
        PkgLock["package-lock.json"]:::doc
        Readme["README.md"]:::doc
    end

    click HTMLBuy "https://github.com/gustaavoevangelista/real-estate/blob/master/index.html"
    click HTMLRent "https://github.com/gustaavoevangelista/real-estate/blob/master/rent.html"
    click BuyHandler "https://github.com/gustaavoevangelista/real-estate/blob/master/js/index.js"
    click RentHandler "https://github.com/gustaavoevangelista/real-estate/blob/master/js/rent.js"
    click APIUtil "https://github.com/gustaavoevangelista/real-estate/blob/master/js/utils.js"
    click CardGen "https://github.com/gustaavoevangelista/real-estate/blob/master/js/utils.js"
    click Styles "https://github.com/gustaavoevangelista/real-estate/blob/master/style/style.css"
    click Images "https://github.com/gustaavoevangelista/real-estate/tree/master/img/"
    click Pkg "https://github.com/gustaavoevangelista/real-estate/blob/master/package.json"
    click PkgLock "https://github.com/gustaavoevangelista/real-estate/blob/master/package-lock.json"
    click Readme "https://github.com/gustaavoevangelista/real-estate/blob/master/README.md"

    classDef host fill:#8fd175,stroke:#333,stroke-width:1px
    classDef client fill:#d0ebff,stroke:#333,stroke-width:1px
    classDef module fill:#8ecae6,stroke:#333,stroke-width:1px
    classDef asset fill:#a0c4ff,stroke:#333,stroke-width:1px
    classDef external fill:#ffb703,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef user fill:#ffadad,stroke:#333,stroke-width:1px
    classDef doc fill:#eeeeee,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
```
