How marcomanfrin/gestionalelavori works
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