# marcomanfrin/gestionalelavori architecture

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

- Interactive diagram: https://gitdiagram.com/marcomanfrin/gestionalelavori
- Repository: https://github.com/marcomanfrin/gestionalelavori

## Overview

##### Project Type and Purpose
- This is a lightweight full-stack web application (“Gestionale Impianti”) whose front end consists of static HTML/CSS/JavaScript pages and whose back end is a mock REST API served by JSON Server. PM2 is used to manage both processes.

##### File-Structure Analysis
- Top level:
- index.html, dashboard.html, detail.html – entry-point pages and views
- style.css, script.js, detail.js – styling and client-side logic
- server/ – mock-API service
◦ server/db.json – in-memory data store
◦ server/package.json, package-lock.json – JSON Server dependencies
- No dedicated “frontend” folder, static pages live at project root
- Build/deployment configured via PM2 and http-server

##### Key Architecture Insights from README
- Front end served by `http‐server` on port 8888
- Back end implemented with JSON Server (port 3000) mocking CRUD operations on db.json
- Client consumes REST endpoints (impianti, tecnici, commesse, etc.) via fetch/XHR
- Chart.js is embedded in dashboard.html for bar and pie charts
- Bootstrap classes are used for layout; toast notifications for status messages
- PM2 orchestrates both processes in production

##### Main Components
a. User / Web Browser
b. HTTP Server (http-server) – serves static assets (HTML, CSS, JS)
c. JSON Server – provides REST API over db.json
d. db.json – the mock database
e. PM2 Process Manager – oversees both the static server and the JSON Server
f. External Libraries – Chart.js, Bootstrap (indicate these as client-side dependencies)

##### Relationships and Data Flows
- Browser → HTTP Server:
- Requests index.html, dashboard.html, detail.html, and associated CSS/JS files
- Receives static responses
- Browser → JSON Server (REST API):
- GET/POST/PUT/DELETE to endpoints (e.g., /impianti, /tecnici, /commesse)
- Receives JSON responses based on db.json
- HTTP Server & JSON Server ← PM2:
- PM2 launches and monitors both processes
- Chart.js embedded in HTML reads data fetched from JSON Server to render graphs

##### Architectural Patterns and Design Principles
- Client–Server separation: clear front-end versus back-end responsibilities
- RESTful API design (even if mocked) for CRUD operations
- Single-page–style interactions within each HTML page using vanilla JS
- Process management abstraction via PM2

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["User Browser"]:::browser
        subgraph "Client Libraries"
            ChartJS["Chart.js"]:::lib
            Bootstrap["Bootstrap"]:::lib
        end
        subgraph "Static Assets"
            idx["index.html"]:::static
            dash["dashboard.html"]:::static
            det["detail.html"]:::static
            css["style.css"]:::static
            js["script.js"]:::static
            detjs["detail.js"]:::static
        end
    end

    %% Service Layer
    subgraph "Service Layer"
        PM2["PM2 Process Manager"]:::pm2
        HTTP["HTTP Server\n(port 8888)"]:::server
        API["JSON Server\n(port 3000)"]:::server
        DB[(db.json)]:::db
    end

    %% Connections
    Browser -->|Requests HTML/CSS/JS| HTTP
    HTTP -->|Serves static files| Browser

    Browser -->|GET/POST/PUT/DELETE| API
    API -->|Reads/Writes JSON| DB
    DB -->|Returns JSON| API

    Browser -->|Loads library| ChartJS
    Browser -->|Loads library| Bootstrap

    PM2 -->|Manages process| HTTP
    PM2 -->|Manages process| API

    HTTP -->|Serves| idx
    HTTP -->|Serves| dash
    HTTP -->|Serves| det
    HTTP -->|Serves| css
    HTTP -->|Serves| js
    HTTP -->|Serves| detjs

    %% Click Events
    click idx "https://github.com/marcomanfrin/gestionalelavori/blob/main/index.html"
    click dash "https://github.com/marcomanfrin/gestionalelavori/blob/main/dashboard.html"
    click det "https://github.com/marcomanfrin/gestionalelavori/blob/main/detail.html"
    click css "https://github.com/marcomanfrin/gestionalelavori/blob/main/style.css"
    click js "https://github.com/marcomanfrin/gestionalelavori/blob/main/script.js"
    click detjs "https://github.com/marcomanfrin/gestionalelavori/blob/main/detail.js"
    click API "https://github.com/marcomanfrin/gestionalelavori/blob/main/server/package.json"
    click DB "https://github.com/marcomanfrin/gestionalelavori/blob/main/server/db.json"
    click ChartJS "https://github.com/marcomanfrin/gestionalelavori/blob/main/dashboard.html"
    click Bootstrap "https://github.com/marcomanfrin/gestionalelavori/blob/main/index.html"

    %% Styles
    classDef browser fill:#dddddd,stroke:#333,stroke-width:1px
    classDef server fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef db fill:#d4edda,stroke:#155724,stroke-width:1px,shape:cylinder
    classDef pm2 fill:#ffe5b4,stroke:#c67900,stroke-width:1px
    classDef lib fill:#f8d7da,stroke:#721c24,stroke-width:1px,stroke-dasharray: 5 5
    classDef static fill:#e2e3e5,stroke:#6c757d,stroke-width:1px,stroke-dasharray: 2 2
```
