# andresrojas0/contenido-dinamico-api-fetch architecture

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

- Interactive diagram: https://gitdiagram.com/andresrojas0/contenido-dinamico-api-fetch
- Repository: https://github.com/andresrojas0/contenido-dinamico-api-fetch

## Overview

##### Project Type and Purpose
- This project is a simple front-end application created as a class practice exercise (Python Fullstack - Clase 27) to demonstrate how to use the API Fetch method for accessing remote resources and dynamically injecting them into a web document.
- The focus is entirely on the client side using HTML, CSS, and JavaScript, without a dedicated backend or database layer.

##### Analyzing the File Structure
- Top-level files and directories include:
- README.md (project documentation)
- index.html (main landing page)
- css/estilos.css (styling information)
- js/ (contains JavaScript modules, including:
- api-fetch-asincro.js (async API fetch implementation)
- api-fetch-sincro.js (sync API fetch implementation)
- ruteo.js (handles routing/navigational logic)
)
- sitio/ (contains additional HTML pages for other sections, such as datos.html and inicio.html)
- The file organization suggests a clear separation between presentation (HTML), styling (CSS), and behavior (JavaScript), with possible routing between different sections of the site.

a. Presentation Layer:
- Main HTML Files: index.html and the pages under sitio/ (inicio.html, datos.html)
- Styling: css/estilos.css, which applies design rules across the pages.
b. Behavior Layer:
- JavaScript files:
- api-fetch-asincro.js: Handles asynchronous API calls.
- api-fetch-sincro.js: Handles synchronous API calls (if applicable in a demo context).
- ruteo.js: Manages routing between different HTML views/pages.
c. Data Access:
- API Calls: Illustrate how the JavaScript files interact with external resources via the fetch API.
d. Hosting Environment:
- Although the project is client-centric, include an element that represents the web server (or static web hosting environment such as Netlify, as mentioned in the README) from which the pages are served.

##### Relationships and Interactions
- That the JavaScript API fetch modules are responsible for retrieving external data and updating the DOM accordingly.
- The CSS file connects to all HTML pages to provide consistent styling.
- Routing mechanism managed by ruteo.js, enabling navigation between index.html and the additional pages in the sitio/ folder.

##### Architectural Patterns and Technologies
- The project follows a clear separation of concerns:
- Structure (HTML),
- Presentation (CSS), and
- Behavior (JS modules for API calls and client-side routing).
- For API fetches: from the client-side JavaScript to "External API."
- For navigation: showing how ruteo.js handles transitions between different site sections.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Hosting Environment"
        WS["Web Server"]:::server
    end

    subgraph "Presentation Layer"
        HTML1["index.html"]:::html
        HTML2["sitio/inicio.html"]:::html
        HTML3["sitio/datos.html"]:::html
        CSS["estilos.css"]:::css
    end

    subgraph "Behavior Layer"
        JS1["api-fetch-asincro.js"]:::js
        JS2["api-fetch-sincro.js"]:::js
        JS3["ruteo.js"]:::js
    end

    External["External API"]:::external

    %% Hosting Environment serves static assets
    WS --> HTML1
    WS --> HTML2
    WS --> HTML3
    WS --> CSS

    %% Presentation Layer linking styling
    HTML1 -->|"styled"| CSS
    HTML2 -->|"styled"| CSS
    HTML3 -->|"styled"| CSS

    %% HTML pages triggering JS behavior
    HTML1 -->|"callsAsync"| JS1
    HTML1 -->|"callsSync"| JS2
    HTML1 -->|"routes"| JS3

    %% JS API modules fetch external data
    JS1 -->|"fetches"| External
    JS2 -->|"fetches"| External

    %% Routing mechanism: navigating to additional pages
    JS3 -->|"navigates"| HTML2
    JS3 -->|"navigates"| HTML3

    %% Click Events
    click HTML1 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//index.html"
    click HTML2 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//sitio/inicio.html"
    click HTML3 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//sitio/datos.html"
    click CSS "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//css/estilos.css"
    click JS1 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//js/api-fetch-asincro.js"
    click JS2 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//js/api-fetch-sincro.js"
    click JS3 "https://github.com/andresrojas0/contenido-dinamico-api-fetch/blob/master//js/ruteo.js"

    %% Styles
    classDef html fill:#FFCCBC,stroke:#BF360C,stroke-width:2px;
    classDef css fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px;
    classDef js fill:#C8E6C9,stroke:#1B5E20,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#6A1B9A,stroke-width:2px;
    classDef server fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
```
