# Module: fe-b2g (`b2g/`)
Purpose: main Blu2Green portal SPA (Angular ^20.1, standalone, `@angular/build:application`) served at Kong `/app`. Owner: Sanjay.
Entry points: `src/main.ts`, `src/app/app.config.ts`, `src/app/app.routes.ts` (~1,370 lines, ~190 lazy `loadChildren`/`loadComponent`; guards `authGuard`/`publicGuard`/`superAdminGuard` in `src/app/core/auth/auth-guard`). Feature folders: `auth`, `dashboard`, `usermanagement`, `profilemanagement`, `configuration`, `digitall`, `cengex`, `gmarket`, `nibeb2g`, `analytics`, `subscription`, `payment`, `sectorpartner`, `auditorshub`, `consultantshub`, `admin`. `src/index.html` loads `assets/env.js` and injects the filems micro-frontend.
Build: `npx ng build --configuration=docker` (what Docker/CI and setup.sh use; output `dist/b2g-frontend/browser`). Other configs: `production`, `demo`, `uat`, `development`. `npm run build:prod|build:demo|build:uat` first run `node update-version.js`. `ng serve`, `ng test` (Karma). No lint script.
Talks to (via `environment.docker.ts`, all root-relative): `apiBaseUrl` `/api` (usermgmt auth API :81); `masterApi`/`microApi` `/micro/web`; `usermgmt` `/usermg/web`; `profilemgmt` `/profilemg/web`; `configmgmt` `/configmg/web`; `digtall` `/digitall/web`; `filee` `/filemst/api`; `cengex` `/cengex/web`; `gmarketApi` `/gmarketapi/web`; `subscrmgmt` `/subscriptnmg/web` (no Kong route — 404s). Links to sibling SPAs: `gmarketAppUrl` `/market/`, `nibeAppUrl` `/nibe/`, `dataManagementUrl` `/nibe/nibe/datamanager`. External: PostHog, `translateApi` (office LAN host, not containerized).
Invariants:
- `const KONG = ''` in `src/environments/environment.docker.ts` — never `http://localhost:8000` (CI bundle guard in `ci/pipeline.py` greps for it and fails the build).
- Keep the `docker` configuration in `angular.json` with `baseHref: "/app/"` and its `fileReplacements`; never pass an absolute `--base-href`.
- Resolve `package.json` + `package-lock.json` together from the same side; installs use `--legacy-peer-deps`.
- Never hardcode a gateway hostname in TS or in `src/assets/env.js` (see `docs/frontend-endpoint-rules.md`); per-tier hosts belong only in `environment.*.ts`.
- Keep the `location = /assets/env.js` no-store block in `docker/nginx-spa.conf`; keep the `/healthz` location (ECS/CI health check).
Gotchas:
- `assets/env.js` is regenerated at container start by `docker/spa-entrypoint.sh` from the ECS env var `MICROFE_HOST` (no rebuild needed); locally `docker/fe-env/env.docker.js` is bind-mounted instead. The committed `src/assets/env.js` still contains `https://demo.blu2green.earth/menu/` and `src/index.html` still has the unguarded, duplicated injection block, although the endpoint-rules doc says both were fixed (verify — fix may not be on this branch).
- `update-version.js` rewrites `buildTimestamp`/`buildNumber` in every non-docker `environment.*.ts` and writes `../b2g_digitall/config/app-version.json` — don't commit that churn unless intended.
- `app.config.server.ts` / `serve:ssr` script exist but `angular.json` has no SSR configuration (verify — likely dead).
- Environment key is spelled `digtall` (sic); `esg-subscription.service.ts` falls back to a LAN host if it is empty.
- Local compose (port 4201) bind-mounts host-built `dist/` and the root `docker/nginx-spa.conf`, not the per-app one — rebuild on the host after changes.
- Stray tracked junk file `b2g/t the app` (and untracked `:wq` files) in the module root.
Prod debugging: CloudWatch `/ecs/b2g-prod/fe-b2g` (demo: `/ecs/b2g-demo/fe-b2g`); health on :80 (`/healthz`); ECS service `fe-b2g`, task family `b2g-fe-b2g` / `b2g-demo-fe-b2g`; browser devtools network tab for 4xx/CORS. Runbooks: `docs/runbooks/`.
