# rack09/progetto-javascript architecture

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

- Interactive diagram: https://gitdiagram.com/rack09/progetto-javascript
- Repository: https://github.com/rack09/progetto-javascript

## Overview

##### Main Components
- Entry Point: The index.html file which only includes the minimal HTML markup and references to external JS and CSS assets.
- JavaScript Modules:
– assets/js/navbar.js: Responsible for building the navigation bar dynamically.
– assets/js/ap.js: Generates the core layout for the counter (referred to in the README as the “contatore”) using DOM API methods.
– assets/js/class.js: Adds dynamic Bootstrap and custom CSS classes to the created elements.
– assets/js/function.js: Manages event handling and logic (such as increment/decrement operations of the counter and responsive behavior for the navbar using event delegation).
- Styling:
– assets/scss/main.scss and assets/styles/main.css: Define the visual styling rules (including customizations to the Bootstrap defaults) that are applied to the dynamically-generated elements.

##### Relationships and Interactions
- The index.html loads the external JavaScript and CSS assets.
- As the page loads, the JavaScript modules are executed:
– navbar.js dynamically builds the entire navigation bar and attaches it to the DOM.
– ap.js (or “app.js” as referenced in the README but actually named ap.js in the tree) creates the counter section with nested divs, buttons, and input.
– class.js enriches these elements by adding the appropriate Bootstrap classes and/or custom styles.
– function.js wires up the interactive behavior by setting event listeners – for instance, using event delegation on the container housing the counter buttons to update the counter’s value.
- The assets for styling (SCSS/CSS) are applied to the generated DOM structure to achieve a responsive, visually consistent design.

##### Architectural Patterns and Design Principles
- Emphasis on dynamic, client-side rendering: All visible elements are created at runtime via DOM API functions (like createElement and appendChild).
- Modular and separation of concerns: Different functionalities are split into distinct JavaScript files (e.g., one for layout, one for styling, one for behavior).
- Event Delegation: A single event listener handles events on a container element (e.g., the div containing the counter buttons), improving performance and maintainability.
- Custom naming conventions: Use of prefixed IDs (e.g., NAV- for navbar elements, SP- for the counter section, D- for dynamic DOM elements) helps in tracking element responsibilities and origins.

– Presentation Layer: The dynamic DOM rendered view.
– Logic Layer: JavaScript modules (creation, styling, and events).
– Styling Layer: Custom CSS/SCSS along with Bootstrap integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point and Styling Sources
    subgraph "Static Layer"
        idx("index.html"):::static
    end

    subgraph "Styling Sources"
        scss("main.scss"):::css
        css("main.css"):::css
    end

    %% Logic Layer - JavaScript Modules
    subgraph "Logic Layer"
        navbar("Navbar Module"):::js
        counter("Counter Module"):::js
        classMgr("Class Management"):::js
        eventHandling("Event Handling"):::js
    end

    %% Presentation Layer - Dynamic DOM
    subgraph "Presentation Layer"
        dynamicDOM("Dynamic DOM"):::dynamic
    end

    %% Relationships
    idx -->|"loads"| navbar
    idx -->|"loads"| counter
    idx -->|"loads"| classMgr
    idx -->|"loads"| eventHandling
    idx -->|"loadsStyles"| scss
    idx -->|"loadsStyles"| css

    navbar -->|"buildsNavbar"| dynamicDOM
    counter -->|"buildsCounter"| dynamicDOM
    classMgr -->|"appliesStyles"| dynamicDOM
    eventHandling -->|"handlesEvents"| dynamicDOM
    scss -->|"styles"| dynamicDOM
    css -->|"styles"| dynamicDOM

    %% Click Events
    click idx "https://github.com/rack09/progetto-javascript/blob/main/index.html"
    click navbar "https://github.com/rack09/progetto-javascript/blob/main/assets/js/navbar.js"
    click counter "https://github.com/rack09/progetto-javascript/blob/main/assets/js/ap.js"
    click classMgr "https://github.com/rack09/progetto-javascript/blob/main/assets/js/class.js"
    click eventHandling "https://github.com/rack09/progetto-javascript/blob/main/assets/js/function.js"
    click scss "https://github.com/rack09/progetto-javascript/blob/main/assets/scss/main.scss"
    click css "https://github.com/rack09/progetto-javascript/blob/main/assets/styles/main.css"

    %% Styles
    classDef static fill:#f6f6f6,stroke:#333,stroke-width:2px;
    classDef js fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef css fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef dynamic fill:#fff3cd,stroke:#333,stroke-width:2px;
```
