Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 74 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# HPH

**Il lavoro, in armonia.** Una base riutilizzabile per un gestionale aziendale modulare, con frontend e backend scritti in Rust.
**Work, in harmony.** A reusable foundation for modular business management software, with a Rust frontend and backend.

HPH è attualmente una **demo locale eseguibile**, non un gestionale pronto per dati reali. Il primo incremento dimostra il design, la composizione dei moduli e un flusso di timbratura controllato dal server.
HPH is currently a **runnable local demo**, not a system ready for real company data. The first working slice demonstrates the design, module composition and a server-validated time-tracking workflow.

## Stack

| Parte | Scelta |
| Area | Choice |
| --- | --- |
| Interfaccia | Leptos 0.8, rendering server e hydration WebAssembly |
| Interface | Leptos 0.8, server-side rendering and WebAssembly hydration |
| Server | Axum 0.8 + Tokio |
| Regole condivise | Crate indipendente `hph-core` |
| Design | CSS responsive con token; temi sage e indigo, nessun font remoto |
| Build | cargo-leptos 0.3.11, Cargo.lock versionato |
| Persistenza attuale | PostgreSQL/SQLx per infrastruttura e repository; l'interfaccia usa ancora memoria demo |
| Persistenza prevista | Completare autenticazione e integrare i repository SQLx nelle schermate operative |
| Shared rules | Independent `hph-core` crate |
| Design | Responsive CSS with design tokens; sage and indigo themes, no remote fonts |
| Build | cargo-leptos 0.3.11, versioned Cargo.lock |
| Current persistence | PostgreSQL/SQLx infrastructure and repositories; the interface still uses demo memory |
| Next persistence step | Complete authentication and connect SQLx repositories to operational screens |

Il codice applicativo è Rust. Il browser usa anche CSS e il piccolo loader JavaScript generato da wasm-bindgen/Leptos: non serve mantenere una seconda applicazione React o TypeScript. Non sono richiesti Node o npm.
Application code is written in Rust. The browser also uses CSS and the small JavaScript loader generated by wasm-bindgen/Leptos: there is no separate React or TypeScript application to maintain. Node and npm are not required. English is the default language for the interface and repository documentation.

## Avvio locale
## Run locally

Prerequisiti: Git e Rust tramite [rustup](https://rustup.rs). Il file `rust-toolchain.toml` installa target WebAssembly e componenti richiesti.
Prerequisites: Git and Rust installed through [rustup](https://rustup.rs). The `rust-toolchain.toml` file installs the required WebAssembly target and components.

```bash
git clone https://github.com/Stcant/HPH.git
Expand All @@ -29,62 +29,63 @@ cargo install cargo-leptos --version 0.3.11 --locked
HPH_DEMO=true cargo leptos watch
```

In PowerShell, impostare prima `$env:HPH_DEMO = "true"`, poi eseguire `cargo leptos watch`.
In PowerShell, first set `$env:HPH_DEMO = "true"`, then run `cargo leptos watch`.

Aprire **http://127.0.0.1:3000**. La demo rifiuta l'avvio senza consenso esplicito `HPH_DEMO=true` o con un indirizzo di ascolto diverso da loopback. Non esporla tramite proxy, tunnel o rete pubblica: non è presente un sistema di autenticazione. L'integrazione PostgreSQL è facoltativa e limitata alla connessione, alle migrazioni e al health check; le schermate usano ancora dati in memoria. Vedi [docs/DATABASE.md](docs/DATABASE.md).
Open **http://127.0.0.1:3000**. The demo refuses to start without the explicit `HPH_DEMO=true` setting or on a non-loopback address. Do not expose it through a proxy, tunnel or public network: authentication is not available yet. PostgreSQL integration is optional and currently limited to connections, migrations and the health check; screens still use in-memory data. See [docs/DATABASE.md](docs/DATABASE.md).

## Provare il flusso
## Try the workflow

1. Dalla dashboard, registrare **Entrata** per il profilo demo Elena Conti.
2. Aprire **Presenze**: registrare **Inizio pausa**, **Fine pausa**, **Uscita**. Gli eventi arrivano al server e sono visibili dopo un aggiornamento pagina.
3. Aprire **Il tuo workspace**, attivare **Report** e consultare il tempo degli intervalli chiusi. Gli intervalli ancora aperti non sono inclusi.
4. Provare a disattivare **Presenze** mentre Report è attivo: il server rifiuta la modifica perché Reports dipende da Attendance. Con una sessione aperta, le presenze non possono essere disattivate.
5. Disattivare Report, chiudere eventuali sessioni e disattivare Presenze. Il menu si aggiorna; riattivandolo, gli eventi della sessione rimangono.
1. From the dashboard, select **Clock in** for the demo profile, Elena Conti.
2. Open **Attendance** and select **Start break**, **End break**, then **Clock out**. Events reach the server and remain visible after refreshing the page.
3. Open **Your workspace**, enable **Reports** and inspect the recorded time for closed work intervals. Open intervals are excluded.
4. Try disabling **Time and attendance** while Reports is enabled: the server rejects the change because Reports depends on Attendance. Open work sessions also prevent Attendance from being disabled.
5. Disable Reports, close any open work sessions, then disable Attendance. The menu updates; enabling Attendance again restores access to the session's existing events.

Tutti i profili sono inventati. L'unico attore della demo è un'amministratrice fissa scelta dal server, non dal browser. Le modifiche ai moduli e gli eventi sono condivisi tra le schede della stessa istanza e **si perdono al riavvio del processo**. L'interfaccia non aggiorna in tempo reale altre schede: usare il pulsante di aggiornamento.
All profiles are fictional. The demo's only actor is a fixed administrator selected by the server, not the browser. Module changes and events are shared between tabs using the same server instance and **are lost when the process restarts**. Other tabs do not update in real time: use the refresh button.

## Personalizzare il template
## Customize the template

Modificare `hph.toml` e riavviare il server:
Edit `hph.toml` and restart the server:

```toml
organization = "La tua azienda"
organization = "Your company"
theme = "sage" # sage | indigo
preset = "team" # essential | team | complete
# modules = ["people", "attendance"] # opzionale: sovrascrive preset
# modules = ["people", "attendance"] # optional: overrides preset
```

`modules` è facoltativo e accetta gli ID `people`, `attendance` e `reports`. I moduli devono includere le proprie dipendenze; HPH rifiuta una configurazione non valida all'avvio. Se `modules` è omesso, usa il preset. Le scelte iniziali in `hph.toml` restano salvate; le attivazioni fatte dall'interfaccia demo valgono solo fino al riavvio.
The optional `modules` setting accepts the IDs `people`, `attendance` and `reports`. Modules must include their dependencies; HPH rejects invalid configurations at startup. When `modules` is omitted, the preset applies. Initial choices in `hph.toml` persist across restarts; changes made in the demo interface last only until the server restarts.

| Preset | Moduli |
| Preset | Modules |
| --- | --- |
| essential | Persone |
| team | Persone + Timbrature e presenze |
| complete | Persone + Timbrature e presenze + Report |
| essential | People |
| team | People + Time and attendance |
| complete | People + Time and attendance + Reports |

I moduli sono composizioni del codice Rust compilato. L'amministratore può abilitarli o disabilitarli nell'interfaccia; aggiungere una nuova funzione richiede codice e una nuova build. Non è un marketplace di plugin caricati da terze parti.
Modules are compiled Rust components. Company administrators can enable or disable them in the interface; adding a new feature requires code and a new build. This is not a marketplace of third-party plugins loaded at runtime.

La configurazione dei moduli appartiene all'azienda: ogni workspace compone HPH scegliendo ciò che serve ai propri processi. Nella demo le attivazioni restano in memoria e si azzerano al riavvio; la configurazione persistente per azienda è parte del prossimo incremento PostgreSQL.
Module configuration belongs to the company: each workspace is composed around its own processes. The demo keeps changes in memory; a PostgreSQL repository for company configuration exists, but it still needs to be connected to authenticated requests.

La base può essere clonata/forkata e personalizzata. La creazione del codice riutilizzabile non imposta automaticamente il flag **Template repository** nelle impostazioni GitHub.
The foundation can be cloned or forked and customized. Reusable code does not automatically enable GitHub's **Template repository** setting.

## Cosa funziona oggi
## What works today

| Funzione | Stato |
| Feature | Status |
| --- | --- |
| Dashboard responsive, schermate e temi | Implementati; QA browser ancora da eseguire |
| Elenco persone | Profili demo in sola lettura |
| Moduli e dipendenze | Configurazione eseguita e verificata sul server |
| Entrata / pausa / rientro / uscita | Controllo sequenza e orario sul server |
| Riepilogo del tempo | Intervalli chiusi, pause escluse, precisione al secondo |
| Ruoli e confine aziendale | Regole di dominio testate; nessuna autenticazione reale |
| Aziende multiple, database, utenti reali | Non implementati |
| Ferie, turni, rettifiche, audit, esportazioni | Non implementati |
| Paghe, contabilità, magazzino | Fuori dalla prima versione |
| Responsive dashboard, screens and themes | Implemented; browser QA still pending |
| People directory | Read-only demo profiles |
| Modules and dependencies | Configuration enforced and verified on the server |
| Clock in / start break / end break / clock out | Sequence and timestamp validation on the server |
| Recorded-time summary | Closed intervals, excluding breaks, with second-level precision |
| Roles and company boundaries | Tested domain rules; no real authentication yet |
| PostgreSQL schema, module and membership repositories | Tested under RLS in CI; not connected to the screens |
| Multiple companies and real accounts in the application | Not implemented |
| Leave, shifts, corrections, audit and exports | Not implemented |
| Payroll, accounting and inventory | Outside the first version |

Gli eventi usano timestamp UTC; i riepiloghi coprono la sessione della demo, non una giornata contrattuale. Nessun calcolo automatico di straordinari, ferie maturate o busta paga.
Events use UTC timestamps displayed as `YYYY-MM-DD`. Summaries cover the demo session, not a contractual working day. There is no automatic calculation of overtime, accrued leave or payroll.

## Verifiche
## Verification

```bash
cargo fmt --all --check
Expand All @@ -93,17 +94,33 @@ cargo check --target wasm32-unknown-unknown --features hydrate --lib --locked
cargo leptos build
```

I test del dominio coprono dipendenze, permessi, azienda errata, doppia entrata, orario retrogrado, pause, disattivazione e conservazione degli eventi. I test HTTP esercitano le vere server function attraverso il router Axum e controllano il rendering SSR. Il job PostgreSQL della CI applica le policy RLS e prova pool SQLx, migrazioni e contesto tenant contro PostgreSQL reale. Non sono test browser né provano operazioni aziendali persistite.
Domain tests cover dependencies, permissions, foreign companies, duplicate clock-ins, reversed timestamps, breaks, disabling modules and data retention. HTTP tests exercise the real server functions through the Axum router and check SSR output. The PostgreSQL CI job applies RLS policies and tests SQLx pools, migrations, tenant context, module configuration and active membership lookup against a real PostgreSQL instance using a restricted runtime role. These are not browser tests and do not establish persistent business operations through the interface.

## Struttura
## Structure

- `crates/hph-core/`: moduli, ruoli, regole di timbratura, contratti serializzati e test.
- `src/app.rs`: componenti e schermate Leptos.
- `src/api.rs`: server function, senza accettare l'identità aziendale dal client.
- `src/server.rs`: configurazione e stato della demo, router e test HTTP.
- `src/database.rs`: pool PostgreSQL SQLx, migrazioni, ping e transazioni scoped per tenant.
- `style/main.css`: layout, token, temi e adattamento mobile.
- `docs/MODULES.md`: contratto per estendere il template.
- `harness/PROJECT_MAP.md` e `harness/PROJECT_STATE.md`: architettura e checkpoint.
- `crates/hph-core/`: modules, roles, time-tracking rules, serialized contracts and tests.
- `src/app.rs`: Leptos components and screens.
- `src/api.rs`: server functions; the client does not supply the acting identity.
- `src/server.rs`: demo configuration and state, router and HTTP tests.
- `src/database.rs`: SQLx PostgreSQL pool, migrations, health check and tenant-scoped transactions.
- `src/module_repository.rs` and `src/membership_repository.rs`: company module configuration and active membership lookup.
- `style/main.css`: layout, tokens, themes and mobile styles.
- `docs/MODULES.md`: the module extension contract.
- `harness/PROJECT_MAP.md` and `harness/PROJECT_STATE.md`: architecture and project checkpoint.

Il prossimo incremento è **autenticazione e sessioni**: il repository SQLx risolve già la membership attiva dell'utente nell'azienda selezionata, ma le schermate non lo usano ancora. Fino all'integrazione di autenticazione, autorizzazione e persistenza applicativa, HPH resta una demo locale e non deve ospitare dati aziendali reali.
The next functional increment is **authentication and sessions**. The SQLx repository can already resolve an active membership for a selected company, but the screens do not use it yet. Until authentication, authorization and application persistence are integrated, HPH remains a local demo and must not host real company data.

---

<details>
<summary>🦀 Recruiter side quest: you found the Easter egg</summary>

If you made it this far, you probably followed the link on my CV—or took a very productive wrong turn on GitHub. Either way, thanks for looking beyond the bullet points.

I'm Stefano. HPH is where I turn architecture decisions into working code, tests and the occasional conversation with the Rust compiler.

Curious about the choices behind the project? [Let's talk](https://www.linkedin.com/in/stefano-contini-464933127/). Bonus points if you mention this Easter egg.

*Achievement unlocked: actually read the README.*

</details>
Loading
Loading