Skip to main content

Shared Library

libs/shared/src/ is the foundation library every app and feature lib depends on. It holds app-wide state, the API / analytics / storage / websocket services, constants, enums, controllers, and helpers — no feature UI (that's the Component Library).

Import via subpaths under @aquagen-mf-webapp/shared/*. The bare root doesn't resolve — always import a subpath:

import { AppStoreContext } from '@aquagen-mf-webapp/shared/store/AppStore';
import { PermissionController } from '@aquagen-mf-webapp/shared/controller/permission/PermissionController';

What's inside

Each module is one line here; follow the "Deep dive" link where one exists rather than repeating detail.

ModuleWhat it doesDeep dive
store/Global state — AppStore (login data, theme, water context) and AlertsStoreState Management
services/api/apiClient (axios), urls.js endpoints, common.js — auth header, device headers, 440/420 interceptorAPI Call Flow
services/analytics/analyticsService + providers (GA, Mixpanel, Firebase); gated by the backwards analyticsEnv flagConfiguration & Security
services/deviceFingerprint/FingerprintJS visitorId → the deviceId request headerAuthentication
services/localdb/, services/sessionStorage/Browser-storage wrappers; LocalDB backs the session (loginResponse)Authentication
services/websocket/Thin wrapper over the native WebSocket for realtime notifications
constants/constants.js (env flags, timeouts, feature toggles) and authConfig.js (MSAL / Google)Configuration & Security
enums/~22 enum files — permissions, loginType, categoryType, graphType, measurementUnits, datePickerEnumPermissions
controller/appController, alertsController, UniversalSearchBarController, and permission/PermissionControllerPermissions
dataSource/appDataSource, alertsDataSource — the API-call layer feeding the controllersAPI Call Flow
helper/Navigation-config singletons (nav, energy, executive, lakePulse, rwi, uwms), alertHelper, subscriptionHelperUtilities & Helpers
hooks/Reusable React hooks (useQueryParams, useNavigateSearchParams, useSendMail…)Utilities & Helpers
utils/Formatters, date/number helpers, graph-data builders, validators, PDF/downloadUtilities & Helpers
markdown/MarkdownViewer (react-markdown) behind the /mdDocs routeApplication Routes
components/A few app-wide components (ContextViewingBanner, FullScreenLoader, SafeImage, SmallScreenBlocker, subscriptionRenewal) — not the Component Library
assets/Shared images, Lottie animations, video
Same layering as feature libs

dataSource/controller/store/ is the same layered pattern every feature lib follows — see Libraries & Modules.


Key libraries

The notable third-party packages the shared lib pulls in:

PurposeLibrary
HTTPaxios
Datesmoment
Utility helperslodash
Analyticsreact-ga4, mixpanel-browser, firebase
Device ID / info@fingerprintjs/fingerprintjs, react-device-detect
Markdownreact-markdown
Navigationreact-router

Exact versions live in package.json — don't duplicate them here.