# Fresh HBB Flow Builder

A new no-login Flow Builder UI with a backend integrated to a dedicated Netflix Conductor instance.

## Stack
- Frontend: React + Vite + React Flow
- Backend: Express + Axios
- Orchestrator: Conductor OSS (dedicated docker compose instance)

## Ports
- Conductor API: `http://localhost:6520/api`
- Backend API: `http://localhost:6522`
- Internal Mock API (backend-internal): `http://127.0.0.1:6524`
- Frontend UI: `http://localhost:6523`

## Quick Start
1. Start dedicated Conductor:
   - `docker compose up -d`
2. Install dependencies:
   - `npm install`
   - `npm --prefix backend install`
   - `npm --prefix frontend install`
3. Run app:
   - `npm run dev`

## Conductor Endpoints Used
- `GET /api/conductor/health`
- `POST /api/conductor/deploy`
- `POST /api/conductor/start`
- `GET /api/conductor/status/:id`

## Flow Export
- Export endpoint:
  - `POST /api/flow/export`
- Returns a JSON package containing:
  - full flow (`nodes`, `edges`, `positions`)
  - workflow metadata (`name`, `version`)
  - mock API details (`baseUrl`, node mappings, and per-node API tool call definitions with sample request/response)
- UI includes an `Export JSON` button to download this package directly.

## Internal Mock API
- A dedicated internal mock server runs on `MOCK_API_PORT` (default `6524`).
- Backend worker calls this mock server for API-type flow nodes (fraud check, RMN/NRMN, bundles, balance, billing, ticket, SMS, etc.).
- Mock health can be checked via backend route:
  - `GET /api/mock-api/health`

## Default Preload
- On backend startup, `AA_NE_HBB_Call (Rebuilt)` is preloaded by default.
- To keep last saved flow across restarts, set:
  - `PRELOAD_TEMPLATE_ON_BOOT=false`

## Flow Source
The template was rebuilt from `AA_NE_HBB_Call flow.pdf` and preloaded in backend data.
