# luiz-lombardi/hiring-coders-desafio-2 architecture

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

- Interactive diagram: https://gitdiagram.com/luiz-lombardi/hiring-coders-desafio-2
- Repository: https://github.com/luiz-lombardi/hiring-coders-desafio-2

## Overview

##### Project type and purpose
- This is a front-end only, static e-commerce inventory system (no backend server).
- Purpose: allow users to add, view, and persist customer and product records in the browser’s LocalStorage.

##### Main components
a. UI layer
- index.html – landing page
- produto.html – product inventory page
- cliente.html – client information page
- css/estilo.css – global styling
b. Behavior layer
- js/scriptproduto.js – product CRUD logic against LocalStorage
- js/scriptcliente.js – client CRUD logic against LocalStorage
c. Persistence layer
- Browser LocalStorage (key/value store for products and clients)

##### Relationships and data flows
- User → HTML pages (entry points)
- HTML pages load their respective JS modules → perform read/write to LocalStorage
- JS modules update the DOM dynamically to reflect CRUD operations
- Data persists across sessions via LocalStorage

##### Architectural patterns & principles
- Separation of concerns:
- HTML defines structure
- CSS handles presentation
- JS modules handle data and logic
- Each HTML page is paired with a dedicated script (module) for its domain (clients vs. products)
- Use of browser storage as a “local database”

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction LR
        Index["index.html"]:::html
        Produto["produto.html"]:::html
        Cliente["cliente.html"]:::html
    end

    %% Behavior Layer
    subgraph "Behavior Layer"
        direction LR
        ScriptProd["js/scriptproduto.js"]:::script
        ScriptCli["js/scriptcliente.js"]:::script
    end

    %% Shared Resources
    subgraph "Shared Resources"
        direction TB
        CSS["css/estilo.css"]:::assets
        IMG["img/"]:::assets
    end

    %% Persistence
    Storage[(LocalStorage)]:::storage

    %% Connections: Page to Scripts
    Produto -->|"load script"| ScriptProd
    Cliente -->|"load script"| ScriptCli

    %% Connections: Scripts to Storage
    ScriptProd -->|"read/write products"| Storage
    ScriptCli -->|"read/write clients"| Storage

    %% Connections: Scripts to Pages (DOM updates)
    ScriptProd -->|"update DOM"| Produto
    ScriptCli -->|"update DOM"| Cliente

    %% Shared resources to pages
    CSS -.-> Index
    CSS -.-> Produto
    CSS -.-> Cliente
    IMG -.-> Index
    IMG -.-> Produto
    IMG -.-> Cliente

    %% Click Events
    click Index "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/index.html"
    click Produto "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/produto.html"
    click Cliente "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/cliente.html"
    click CSS "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/css/estilo.css"
    click IMG "https://github.com/luiz-lombardi/hiring-coders-desafio-2/tree/main/img/"
    click ScriptProd "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/js/scriptproduto.js"
    click ScriptCli "https://github.com/luiz-lombardi/hiring-coders-desafio-2/blob/main/js/scriptcliente.js"

    %% Styles
    classDef html fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef script fill:#FFA500,stroke:#333,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:1px
    classDef assets fill:#D3D3D3,stroke:#333,stroke-width:1px
```
