Skip to main content

Libraries & Modules

Every app in the monorepo (see Applications) is built from a shared set of libraries under libs/. This page is the inventory: what each library is, who uses it, and the rules that (mostly) govern how they depend on each other.


The import naming scope

All libraries are imported through the @aquagen-mf-webapp/<name> path alias, declared in the root tsconfig.base.json:

import { AppStoreContext } from '@aquagen-mf-webapp/shared/store/AppStore';
import { MainLayout } from '@aquagen-mf-webapp/components/pages/layouts/MainLayout';

The mf in the scope stands for Module Federation, which the project was originally built around but no longer uses. The name stuck.

Aliases live in two places

The root tsconfig.base.json is the authoritative alias list, but each app also declares aliases in its own rspack.config.js and tsconfig.json. A few libraries (notably aquaAi) resolve only through the per-app configs and are missing from the root file.


Categories

Libraries fall into three groups.

  • Foundation — used by everything: shared, components, uilib (stub).
  • Sustainability indices — the water indices: rwi, uwi, gwi, waterRisk.
  • Feature libraries — one product feature each: dashboard, monitoring, energy, and so on.

The intended rule is a one-way flow: shared → components → features. In practice there are some violations — see Dependency rules.


Master inventory

Legend for Status: ✅ active · 🟡 superseded-but-used · 🟠 orphaned · 🔴 dead. Orphaned/dead libraries are explained in Legacy & Deprecated.

Foundation

LibraryImport aliasPurposeUsed byStatus
shared@aquagen-mf-webapp/sharedCore services, store, hooks, utils, constantsEverything
components@aquagen-mf-webapp/componentsShared UI component library (buttons, graphs, layouts, nav)Everything
uilib@aquagen-mf-webapp/uilibNx-generated placeholderNobody🟠

Sustainability indices

LibraryImport aliasPurposeUsed byStatus
uwi@aquagen-mf-webapp/uwiUrban Water Indexproduction, demo, uwms
rwi@aquagen-mf-webapp/rwiRainwater Indexproduction, demo, rwi
gwi@aquagen-mf-webapp/gwiGround Water Indexproduction, demo
waterRisk@aquagen-mf-webapp/waterRiskWater-risk predictionNobody (not routed)🟠

Feature libraries

LibraryImport aliasPurposeUsed byStatus
monitoring@aquagen-mf-webapp/monitoringCore water monitoring (largest feature lib)prod, demo, uwms, rwi
dashboard@aquagen-mf-webapp/dashboardMain dashboardproduction, demo
leadership@aquagen-mf-webapp/leadershipExecutive dashboardproduction, demo
energy@aquagen-mf-webapp/energyEnergy monitoringproduction, demo
alerts@aquagen-mf-webapp/alertsAlerts & notificationsAll 5 apps
manageAccount@aquagen-mf-webapp/manageAccountAccount & settingsAll 5 apps
aquaAi@aquagen-mf-webapp/aquaAiAI assistant (project name ecogpt)All 5 apps
featureLocked@aquagen-mf-webapp/featureLockedPaywall / upsell for locked featuresAll 5 apps
waterBalance@aquagen-mf-webapp/waterBalanceWater balanceproduction, demo
waterNeutrality@aquagen-mf-webapp/waterNeutralityWater neutralityproduction, demo
waterRatio@aquagen-mf-webapp/waterRatioWater usage ratio (project name waterUsage)production, demo
roEfficiency@aquagen-mf-webapp/roEfficiencyRO (reverse-osmosis) efficiencyproduction, demo
ilm@aquagen-mf-webapp/ilmLake / water-quality (satellite, heatmap)production, demo, lakepulse
hmi@aquagen-mf-webapp/hmiHuman-Machine Interfaceproduction, demo
scadaEditor@aquagen-mf-webapp/scadaEditorSCADA diagram editorproduction, demo
scadaViewer@aquagen-mf-webapp/scadaViewerSCADA diagram viewerproduction, demo
aquagenLabs@aquagen-mf-webapp/aquagenLabsExperimental "Labs" featuresproduction, demo
trueCost@aquagen-mf-webapp/trueCostTrue cost of waterdemo only
reportsV2@aquagen-mf-webapp/reportsV2Reports (v2 — with store & subpages)production, demo
reports@aquagen-mf-webapp/reportsReports (v1)uwms, lakepulse, rwi🟡
aquagpt@aquagen-mf-webapp/aquagptGPT chat assistantNobody🟠
demoAquaGpt@aquagen-mf-webapp/demoAquaGptMock GPT chat (dummy data)Nobody🟠
legacyReports— (none)Empty skeletonNobody🔴

Two phantom aliases also exist in tsconfig.base.jsonpricing and wri — that point at folders which do not exist. See Legacy & Deprecated.


The reports libraries

There are three reports libraries; only two are alive:

LibraryUsed byNotes
reportsV2AquaGen, DemoCurrent version — has its own store and subpages
reports (v1)AquaRecycle, Lakepulse, AquaRainOlder, still active in the standalone apps
legacyReportsnobody🔴 Empty — the pre-v1 remnant

So reports v1 and reportsV2 coexist by app tier: the flagship apps use v2, the standalone apps use v1. Moving the standalone apps onto reportsV2 and deleting v1 + legacyReports is a future cleanup.


Which apps use which libraries

Every app shares a common baseline, then adds its own feature libraries.

Baseline (all 5 apps): shared, components, manageAccount, alerts, aquaAi, featureLocked.

AppAdds
productionThe full catalog — monitoring, dashboard, leadership, energy, all indices, water balance/neutrality/ratio, roEfficiency, hmi, scada×2, ilm, aquagenLabs, reportsV2
demoSame as production + trueCost
uwms (AquaRecycle)monitoring, uwi, reports (v1)
lakepulse (Lakepulse)ilm, reports (v1) — no monitoring
rwi (AquaRain)monitoring, rwi, reports (v1)

Dependency rules and where they break

The intended layering is shared → components → features (features are leaves; foundation never imports features). It holds as intent, but there are real violations to be aware of:

  • sharedcomponents cycle. shared imports components in ~12 places (for example, AppStore.js imports the login controller), while components imports shared heavily. The two foundation libraries depend on each other.
  • components reaches into features. components imports from dashboard, monitoring, and energy (for example, MainLayout imports monitoring's store) — a foundation library reaching up into features.
  • Feature ↔ feature imports. Several features import each other: dashboard → uwi, ilm → gwi, monitoring → aquagenLabs, roEfficiency → dashboard, plus two cycles — scadaEditor ↔ scadaViewer and scadaViewer ↔ uwi.

None of these break the build, but they mean the layering is not enforced. Treat the rule as a guideline, and avoid adding new cross-feature or foundation-to-feature edges.


Library folder convention

New libraries are created with npm run create:lib <name>, which produces this structure. Most feature libraries follow it, though folder names vary (e.g. enum vs enums) and some libs omit helper or enum:

libs/<feature>/
├── src/
│ ├── components/ # feature-specific UI
│ ├── controller/ # business logic
│ ├── dataSource/ # API calls
│ ├── store/ # state (React Context)
│ ├── enum/ # constants and enums (some libs use enums/)
│ ├── helper/ # utility functions
│ └── <Feature>Page.jsx # the main page component

This maps to the app's design patterns — see Architecture → Micro-Frontend Architecture and API Call Flow.


Naming oddities

A few libraries have folder names and internal project names that don't match. Keep this handy when reading project.json files:

Folderproject.json nameWhat it is
aquaAiecogptThe current AI assistant
rwirwi-libRainwater Index feature
waterRatiowaterUsageWater usage ratio

(The aquagpt / demoAquaGpt / aquaAi trio is the easiest place to get lost: aquaAi — confusingly named ecogpt — is the live one; the other two are orphaned.)


Next steps