# Module: fe-gmarket (`gMarket/`)
Purpose: gMarket sustainable-marketplace SPA (Angular ^21.2, standalone, `@angular/build:application`) served at Kong `/market`. Owner: Sanjay.
Entry points: `src/main.ts`, `src/app/app.config.ts`, `src/app/app.routes.ts` (~870 lines; `''` → `gmarket/gmarket-landingpage`; product/service wizards `add-product`, `add-service`, `business-source`, `addfactoryinformation`, trackers, catalogs, `buyer-registration`, certificate pages; `**` → `''`). Shared code in `src/app/core/` (api, auth, config, services, theme) and `src/app/shared/`. `src/index.html` loads `assets/env.js` and injects the filems micro-frontend.
Build: `npx ng build --configuration=docker` (Docker/CI; output `dist/gmarket/browser`). Other configs: `production`, `uat`. `npm run lint` (ESLint, `eslint.config.mjs`), `ng test` (`@angular/build:unit-test`), `ng serve`.
Talks to (via `environment.docker.ts`, root-relative): `gmarketApi` `/gmarketapi/web` (primary backend); `apiBaseUrl` `/api` (usermgmt auth); `masterApi`/`microApi` `/micro/web`; `usermgmt` `/usermg/web`; `profilemgmt` `/profilemg/web`; `configmgmt` `/configmg/web`; `digtall` `/digitall/web`; `filee` `/filemst/api`; `cengex` `/cengex/web`; `subscrmgmt` `/subscriptnmg/web` (no Kong route — 404s). Sibling SPA: `b2gAppUrl` `/app/`. External: `translateApi` (office LAN host).
Invariants:
- `const KONG = ''` in `src/environments/environment.docker.ts` — never `http://localhost:8000` (CI bundle guard in `ci/pipeline.py` fails the build).
- Keep the `docker` configuration in `angular.json` with `baseHref: "/market/"`; 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 `src/assets/env.js` (`docs/frontend-endpoint-rules.md`).
- Keep the `/healthz` and `location = /assets/env.js` no-store blocks in `docker/nginx-spa.conf`.
Gotchas:
- Dockerfile uses `npm install`, not `npm ci`: `package-lock.json` is missing four declared packages (`@tabler/icons-webfont`, `@tabler/icons`, `material-icons`, `posthog-js`), so `npm ci` refuses to run.
- `assets/env.js` is regenerated at container start by `docker/spa-entrypoint.sh` from `MICROFE_HOST` (ECS task definition, expected `/filems`); locally `docker/fe-env/env.docker.js` is bind-mounted. The committed `src/assets/env.js` still points at `https://blu2green.earth/menu/` and `index.html` loads `assets/env.js` several times with an unguarded injection (verify — endpoint-rules doc says this was fixed).
- `nibeAppUrl` in `environment.docker.ts` is `http://localhost:5600/` — passes the CI guard but is broken in any deployed tier (verify usage).
- Local compose (port 4202) bind-mounts host-built `dist/` and the root `docker/nginx-spa.conf` — rebuild on the host after changes.
Conventions (carried over from the previous long-form `claude.md`):
- Standalone components, Angular Signals for state, lazy-loaded feature routes, strict TypeScript, OnPush where practical.
- Tailwind, responsive-first; no inline styles. Reusable UI comes from the `b2g-theme-factory` skill; don't fork one-off copies.
- Functional areas: products (sustainability tags, approval workflow), services (ESG categorisation), certificates (upload, verification), supplier/buyer management.
Prod debugging: CloudWatch `/ecs/b2g-prod/fe-gmarket` (demo: `/ecs/b2g-demo/fe-gmarket`); health on :80 (`/healthz`); ECS service `fe-gmarket`, task family `b2g-fe-gmarket` / `b2g-demo-fe-gmarket`; browser devtools network tab for 4xx/CORS. Runbooks: `docs/runbooks/`.
