This project implements the required POST /bfhl API and a single-page frontend that interacts with it. The backend is written in plain Node.js without external dependencies, so it is easy to run on platforms like Render or Railway and straightforward to audit during evaluation.
- Accepts a JSON payload shaped like
{ "data": ["A->B", "A->C"] } - Validates node format after trimming whitespace
- Tracks invalid entries and duplicate edges separately
- Silently ignores later multi-parent edges for the same child
- Splits independent groups into separate hierarchy objects
- Detects cyclic groups and returns
has_cycle: truewith an empty tree - Computes depth for non-cyclic trees and summary metrics for the full response
- Serves a frontend at
/that calls the API and renders the results clearly
The challenge expects your real identity fields. This project now reads them from a local .env file when you run npm start or npm test.
Set these environment variables:
FULL_NAMEDOB_DDMMYYYYCOLLEGE_EMAILCOLLEGE_ROLL_NUMBERPORT(optional, defaults to3000)
A starter template is included in .env.example. The active local values live in .env.
npm install npm start
This project has no package dependencies, so npm install only creates the lockfile metadata if you want one. You can also start it directly with:
node src/server.js
Then open http://localhost:3000.
Any Node host that supports a long-running server works well:
- Render: set the start command to
node src/server.js - Railway: same start command, add the environment variables above
The frontend is served by the same process, so you only need one deployment URL. The evaluator can call https://your-domain/bfhl directly.