# Module: fe-filems (`b2g_filems_fe/`)
Purpose: file-management micro-frontend (package `micro-fe`, Angular ^16.1, NgModule + `@angular/elements`) that b2g and gMarket inject as `micro-fe.js`; served at Kong `/filems`. Owner: Sanjay.
Entry points: `src/main.ts`, `src/app/app.module.ts` (registers custom elements `app-header-fe`, `app-footer-fe`, `app-profilecard-fe`, `app-elev8drive-fe`, `app-usercard-fe`, `app-unifiedsearch-fe`, … — no real routes, `RouterModule.forRoot([])`), `src/app/remote.service.ts`, `src/app/@shared/drive.service.ts`, `concat.js` (merges `app/runtime.js` + `polyfills.js` + `main.js` → `app/micro-fe.js`).
Build: `npm run bundle-docker` (= `ng build --configuration docker --output-hashing=none --delete-output-path=false && node concat.js`; what the Dockerfile runs). Other scripts: `bundle` (production), `bundle-prod`/`bundle-demo` (bake absolute blu2green.earth base-hrefs — legacy), `build:microfe`, `compile` (LAN-IP dev server). Configs: `docker`, `production`, `demo`, `uat`, `development`. Legacy `@angular-devkit/build-angular:browser` builder, `outputPath: "app"`. `ng test` (Karma). No lint script.
Talks to: `b2gapiBaserUrl` `/filemst/api/` (filemst :81) in `environment.docker.ts`; that is the only platform API key in docker config.
Invariants:
- `const KONG = ''` in `src/environments/environment.docker.ts` — never `http://localhost:8000` (CI bundle guard fails the build).
- Keep the `docker` configuration with `baseHref: "/filems/"`; host apps load `/filems/micro-fe.js` via `MICROFE_HOST=/filems` on their task definitions.
- Bundles must be built with `--output-hashing=none` — `concat.js` reads the unhashed filenames; a plain `ng build` produces no `micro-fe.js` and `/filems/micro-fe.js` 404s.
- Never commit `app/` (build output; ignored by `.gitignore` and `.dockerignore`). It was once tracked and shipped a stale bundle (still containing localhost:8000) beside the fresh one.
- Make sure `.dockerignore` stays in the PR — it went missing once via a squash merge of an older source commit and broke the build for three days.
- Resolve `package.json` + `package-lock.json` together; install with `--legacy-peer-deps`.
Gotchas:
- `environment.demo.ts`/`environment.prod.ts` still carry absolute hosts (prod uses an older `/b2gnew/...` layout) — verify before using those configs.
- `drive.service.ts` and `remote.service.ts` contain a hardcoded `uac` access token shipped to every browser — flagged for rotation; never copy it elsewhere.
- Breaking a custom-element tag name or input breaks the b2g/gMarket shells that embed it — check both hosts when changing the API.
- Local compose (port 4204) bind-mounts host-built `app/` — run `npm run bundle-docker` on the host after changes.
Prod debugging: CloudWatch `/ecs/b2g-prod/fe-filems` (demo: `/ecs/b2g-demo/fe-filems`); health on :80 (`/healthz`); ECS service `fe-filems`, task family `b2g-fe-filems` / `b2g-demo-fe-filems`; browser devtools network tab for 4xx/CORS (a request to a non-own origin means a hardcoded host leaked in). Runbooks: `docs/runbooks/`.
