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.
| Module | What it does | Deep dive |
|---|---|---|
store/ | Global state — AppStore (login data, theme, water context) and AlertsStore | State Management |
services/api/ | apiClient (axios), urls.js endpoints, common.js — auth header, device headers, 440/420 interceptor | API Call Flow |
services/analytics/ | analyticsService + providers (GA, Mixpanel, Firebase); gated by the backwards analyticsEnv flag | Configuration & Security |
services/deviceFingerprint/ | FingerprintJS visitorId → the deviceId request header | Authentication |
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, datePickerEnum… | Permissions |
controller/ | appController, alertsController, UniversalSearchBarController, and permission/PermissionController | Permissions |
dataSource/ | appDataSource, alertsDataSource — the API-call layer feeding the controllers | API Call Flow |
helper/ | Navigation-config singletons (nav, energy, executive, lakePulse, rwi, uwms), alertHelper, subscriptionHelper | Utilities & Helpers |
hooks/ | Reusable React hooks (useQueryParams, useNavigateSearchParams, useSendMail…) | Utilities & Helpers |
utils/ | Formatters, date/number helpers, graph-data builders, validators, PDF/download | Utilities & Helpers |
markdown/ | MarkdownViewer (react-markdown) behind the /mdDocs route | Application 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:
| Purpose | Library |
|---|---|
| HTTP | axios |
| Dates | moment |
| Utility helpers | lodash |
| Analytics | react-ga4, mixpanel-browser, firebase |
| Device ID / info | @fingerprintjs/fingerprintjs, react-device-detect |
| Markdown | react-markdown |
| Navigation | react-router |
Exact versions live in package.json — don't duplicate them here.
Related
- Component Library — the UI counterpart to this library
- Libraries & Modules — how
sharedfits the wider lib inventory - State Management · API Call Flow · Permissions — the subsystems that live here