From 28d167f11fcd24fa95076a43caaef8199ce58e3f Mon Sep 17 00:00:00 2001 From: Stan Date: Sun, 19 Apr 2026 21:14:16 +0200 Subject: [PATCH] stage 1 --- PROJECT_FILES_GUIDE.md | 676 +++++++++++++++++++++++++++ README.md | 173 +++++-- public/admin.html | 196 ++++++++ public/app.js | 780 +++++++++++++++++++++++++++++++ public/icon.svg | 10 + public/index.html | 347 ++++++++++++++ public/js/api.js | 50 ++ public/js/constants.js | 30 ++ public/js/db.js | 133 ++++++ public/js/export.js | 100 ++++ public/js/forms.js | 239 ++++++++++ public/js/i18n.js | 121 +++++ public/js/image-worker.js | 58 +++ public/js/images.js | 134 ++++++ public/js/renderer.js | 389 +++++++++++++++ public/js/state.js | 58 +++ public/js/utils.js | 150 ++++++ public/js/validation.js | 100 ++++ public/manifest.webmanifest | 17 + public/portal.html | 48 ++ public/styles.css | 638 +++++++++++++++++++++++++ public/sw.js | 118 +++++ public/user.html | 194 ++++++++ scripts/test-environment.js | 4 +- sql/schema.sql | 60 +++ sql/seed.sql | 14 + src/app.js | 61 ++- src/config/env.js | 11 + src/db/pool.js | 10 + src/middleware/validateParams.js | 35 ++ src/routes/configRoutes.js | 115 ++++- src/routes/healthRoutes.js | 5 + src/routes/lookupRoutes.js | 31 +- src/routes/reportRoutes.js | 75 +++ src/routes/templateRoutes.js | 103 +++- src/server.js | 14 + src/services/auditService.js | 75 +++ src/services/cacheService.js | 70 +++ src/services/configService.js | 54 +++ src/services/lookupService.js | 14 + src/services/reportService.js | 108 +++++ src/services/templateService.js | 118 +++++ 42 files changed, 5681 insertions(+), 55 deletions(-) create mode 100644 PROJECT_FILES_GUIDE.md create mode 100644 public/admin.html create mode 100644 public/app.js create mode 100644 public/icon.svg create mode 100644 public/index.html create mode 100644 public/js/api.js create mode 100644 public/js/constants.js create mode 100644 public/js/db.js create mode 100644 public/js/export.js create mode 100644 public/js/forms.js create mode 100644 public/js/i18n.js create mode 100644 public/js/image-worker.js create mode 100644 public/js/images.js create mode 100644 public/js/renderer.js create mode 100644 public/js/state.js create mode 100644 public/js/utils.js create mode 100644 public/js/validation.js create mode 100644 public/manifest.webmanifest create mode 100644 public/portal.html create mode 100644 public/styles.css create mode 100644 public/sw.js create mode 100644 public/user.html create mode 100644 src/middleware/validateParams.js create mode 100644 src/routes/reportRoutes.js create mode 100644 src/services/auditService.js create mode 100644 src/services/cacheService.js create mode 100644 src/services/reportService.js diff --git a/PROJECT_FILES_GUIDE.md b/PROJECT_FILES_GUIDE.md new file mode 100644 index 0000000..ba2c110 --- /dev/null +++ b/PROJECT_FILES_GUIDE.md @@ -0,0 +1,676 @@ +# Project Files Guide + +This document explains the role of the main files in this project in a way that should be easy to follow for a junior developer. + +The project is split into a few clear parts: +- server code in [src/app.js](src/app.js) and the rest of [src](src) +- browser frontend files in [public](public) +- database structure and example data in [sql](sql) +- environment and local development helpers in the root folder and [scripts](scripts) + +## How The Application Works At A High Level + +The project has two big sides: +- the backend, which provides templates, lookups, configuration, report storage, and audit logging through REST API endpoints +- the frontend, which runs in the browser, stores drafts locally, and uses the backend for centrally managed configuration and report submission + +In simple terms: +1. Express starts the server. +2. The server exposes API endpoints under `/api/v1/...`. +3. The server also serves the frontend files from the [public](public) folder. +4. The browser loads the frontend entry point [public/app.js](public/app.js) which imports modules from [public/js/](public/js). +5. The frontend downloads templates and config from the API using a single batch request. +6. The frontend stores reports and images locally in IndexedDB. +7. Reports can be submitted to the server via `POST /api/v1/reports`. + +## Root Files + +### [package.json](package.json) + +Role: +Defines the Node.js project itself. + +What it contains: +- project name and version +- npm scripts such as `start`, `dev`, and `test:environment` +- dependency list such as `express`, `mariadb`, and `dotenv` + +Why it matters: +When you run `npm install` or `npm start`, Node uses this file to know how the project should behave. + +### [README.md](README.md) + +Role: +Main entry document for developers. + +What it contains: +- project purpose +- setup steps +- available endpoints +- development notes + +Why it matters: +This is the first file a new developer should read before touching the code. + +### [docker-compose.yml](docker-compose.yml) + +Role: +Starts the full local development environment. + +What it contains: +- the application container +- the MariaDB container +- the phpMyAdmin container +- port mappings and volume configuration + +Why it matters: +Instead of installing and configuring everything manually, you can start the full stack with one command. + +### [.env.example](.env.example) + +Role: +Example environment configuration. + +What it contains: +- default port values +- database host, name, user, and password placeholders + +Why it matters: +It shows which environment variables the application expects. + +### [.env](.env) + +Role: +Real environment file used on the current machine. + +What it contains: +- actual local values for ports and database credentials + +Why it matters: +The backend reads this file during startup through `dotenv`. + +## Public Folder + +The [public](public) folder contains files that are sent directly to the browser. + +### [public/user.html](public/user.html) + +Role: +Operator workspace HTML shell. + +What it contains: +- shared sidebar with template selector, sync button, report list, and search/filter +- report editor main area with hero, summary cards, form, inspector panel +- report list item `