API & Services
How the app talks to its backend, and the shared services that support it.
API Client
Central HTTP client (Axios 1.10.0) used for all REST calls.
Location: libs/shared/src/services/api/apiClient.js
Import: import { apiClient } from '@aquagen-mf-webapp/shared/services';
- Base URL: selected by
constants.currentEnv(see Environment URLs); defaults to production. - Timeout: 50 s (
constants.request.defaultTimeout). - Auth: JWT bearer token attached automatically.
Methods
import { apiClient } from '@aquagen-mf-webapp/shared/services';
await apiClient.get(url, params, headers, customConfig);
await apiClient.post(url, body, params, headers, customConfig);
await apiClient.put(url, body, params, headers, customConfig);
await apiClient.patch(url, body, params, headers, customConfig);
await apiClient.del(url, params, headers, customConfig);
await apiClient.postFile(url, file, fieldName, params, headers, customConfig);
All six are attached to apiClient (get, post, put, patch, del,
postFile).
Request interceptor
Every request automatically gets the JWT Authorization header plus device
headers (from deviceFingerprint). The header names are exactly:
| Header | Value |
|---|---|
Authorization | Bearer <jwt> |
browserName | browser name |
browserVersion | browser version |
deviceType | desktop / mobile |
operationSystem | OS |
deviceId | device fingerprint |
x-request-id | per-request id |
These are the literal header keys in apiClient.js — they are not x-
prefixed (except x-request-id). Don't add them manually; the interceptor does.
Response interceptor — status handling
| Status | Meaning |
|---|---|
200 | Success |
400 | Bad request |
401 | Unauthorized → session expired, redirect to login |
402 / 420 | Payment/subscription required |
440 | Token expired |
500 | Server error |
(Codes and messages are defined in constants.request.error — see
Enums & Configs.)
Core Services
All are re-exported from @aquagen-mf-webapp/shared/services
(libs/shared/src/services/index.js).
Analytics — AnalyticsService
Tracks user events across three providers: Google Analytics, Firebase, and Mixpanel.
Location: libs/shared/src/services/analytics/analyticsService.js
import { AnalyticsService } from '@aquagen-mf-webapp/shared/services';
import { AnalyticEvents } from '@aquagen-mf-webapp/shared/enums';
// signature: sendEvent(event, props, pageView = false)
AnalyticsService.sendEvent(AnalyticEvents.DASHBOARD_CARD_CLICK, { card: 'energy' });
// a page view sets the boolean 3rd argument (there is no separate pageView method)
AnalyticsService.sendEvent(AnalyticEvents.PAGE_VIEW, {}, true);
See Analytics Events for the full event catalog.
Device Fingerprint
Generates the stable deviceId and browser/OS values used in request headers
(via FingerprintJS).
Location: libs/shared/src/services/deviceFingerprint/deviceFingerprint.js
WebSocket
Real-time updates via Azure Web PubSub (wss://*.webpubsub.azure.com).
Location: libs/shared/src/services/websocket/websocket.js
Local Storage — LocalDBInstance / LocalDBKeys
Wrapper over localStorage with a fixed set of keys.
Location: libs/shared/src/services/localdb/localdb.js
import { LocalDBInstance, LocalDBKeys } from '@aquagen-mf-webapp/shared/services';
LocalDBInstance.setItem(LocalDBKeys.loginResponse, data);
const raw = LocalDBInstance.getItem(LocalDBKeys.loginResponse);
LocalDBInstance.removeItem(LocalDBKeys.loginResponse);
Session Storage
sessionStorage wrapper, session-scoped equivalent of LocalDB.
Location: libs/shared/src/services/sessionStorage/sessionStorage.js
Notifications
Browser notification permission + display.
Location: libs/shared/src/services/notificationUtil.js
Endpoints
Endpoints are defined as getters on the Urls singleton in
libs/shared/src/services/api/urls.js and passed to apiClient:
import { apiClient, Urls } from '@aquagen-mf-webapp/shared/services';
const data = await apiClient.get(Urls.dashboardData); // → /landingPage/userData
Paths are relative to the base URL (.../api/user/) unless noted. This is the
authoritative list from urls.js — the getter name is the property you call on
Urls.
Auth
| Getter | Path |
|---|---|
login | user/login |
validateCredentials | user/validateCredentials |
otpPhnCheck | user/otplogin |
refreshToken | user/refresh |
logout | user/logout |
Dashboard & monitoring
| Getter | Path |
|---|---|
dashboardData | /landingPage/userData |
categoryData | deviceData/ |
categoryDataV2 | deviceDataV2 |
compareData | /deviceDataV2/compare |
getGranularCategoryData / granularCategoryData | granular/category |
getGranularUnitData / granularUnitData | granular/unit |
getGroundWaterGraphData | groundWaterLevel/graph |
getVirtualNodesData / postVirtualNodesData | virtual/device_data |
Alerts & notifications
| Getter | Path |
|---|---|
getAlerts | alerts |
getAlertsByDateRange | alerts/dateRange |
getLeakageAlertsData | alerts/unitGraph |
notificationData | notification/ |
notificationDataByRange | /notificationRange |
updateNotificationRead | notification/updateRead |
assignNotification | /notification/assignee |
Water features
| Getter | Path |
|---|---|
waterBalanceData | waterBalance/data |
getNeutralityData | neutrality/ |
getWaterRatioData / postWaterRatioData / putWaterRatioData | /waterRatio/ |
gwiData | gwi/data |
getRainefficiencysavingsdata | /rainfall/efficiencySaving |
getRainFallTrend | /rainfall/trend |
Lake / WRI / ILM
| Getter | Path |
|---|---|
lakeList | wri/lakeList |
calculateVolumeAndBathymetry | wri/bathymetryResult |
wriDatesList | wri/datesList |
wriSatelliteData | wri/satelliteData |
asvDates / asvQuality | wri/asv/dates · wri/asv/quality |
ilmPointTrends | wri/ilm/pointTrends |
ilmTrendWaterAvailability | wri/ilm/trendWaterAvailability |
AI (AquaGPT)
| Getter | Path |
|---|---|
getGptResponse | gpt/aqua |
getGptStreamResponse | gpt/stream/aqua |
getGptPastResponse | gpt/responses/ndays |
Leadership / executive
| Getter | Path |
|---|---|
getExecutiveData | executiveSummary/data |
executiveIndustryLogin | executiveSummary/login |
putExecutivePin | executiveSummary/pin |
Energy / UWI / UWMS
| Getter | Path |
|---|---|
getEnergyDashboardData / getUwidashboardData / getAquaLabsData | /deviceDataV2 |
getEnergySavedUwiData | /deviceData |
uwmsStats | uwms/stats |
uwmsControlLogs | uwms/control-logs |
RO efficiency
| Getter | Path |
|---|---|
roEfficiencyData | /roEfficiency/ |
getLogActivities / postLogActivity | /roEfficiency/logActivities |
SCADA / HMI / PLC
| Getter | Path |
|---|---|
scadaGraphEditor | scada/graphEditor |
scadaData | scada/data |
hmiDeviceValues / postHmiParamValue | hmi |
plcWriteRegisters | plc/write-registers |
plcEventHubData | (full admin URL — different host) |
Account, subscription, reports & misc
| Getter | Path |
|---|---|
accountSettingsUpdate | accounts/settings |
accountSettingsLogoUpdate | /accounts/logoupdate |
accountDetails | accounts/landingpage |
lastUpdatedTime | accounts/info/lastupdated |
getSubscriptionDetails | /subscription/ |
postAquaLabsReport | dataExtraction/ |
getAquaLabsReports | /dataExtraction/reports |
reportUrl(...) | report builder — separate host, not the base URL |
sendMail | /sendMail |
urls.js is the source of truth. If a getter isn't listed here, check the file
directly — and the report download (reportUrl(...)) and plcEventHubData point
at their own hosts, not the /api/user/ base.
Environment URLs
Urls.baseUrl switches on constants.currentEnv:
currentEnv | Base URL |
|---|---|
prod | https://prod-aquagen.azurewebsites.net/api/user/ |
dev | https://dev2-aquagenapi.azurewebsites.net/api/user/ |
local | http://localhost:5001/api/user/ |
demo | https://aqua-demo-api-djeaedfdh3gjhzey.centralindia-01.azurewebsites.net/api/user/ |
ngrok | ngrok tunnel |
Separate backends: AI agent (getAIAgentBaseUrl() → .../ai-agent-backend...
or localhost:8000) and UWI AI (uwiAIBaseUrl). See
Local environment & backend switching.
Location: libs/shared/src/services/api/urls.js
Integration pattern
Component → Store (Context) → Controller → DataSource → apiClient (Axios) → Backend
Keep API calls in the DataSource layer; components go through the store, not
apiClient directly.
Next Steps
- Enums & Configs — status codes, categories, auth config
- Analytics Events — the event catalog