This guide walks through the LifeLine operator workflow one command at a time.
Install dependencies once:
npm installStart the services with Docker if your setup uses the included compose file:
docker compose up -dOr start each service locally in separate terminals:
npm run start:gateway
npm run start:matching
npm run start:inventory
npm run start:notification
npm run start:analytics
npm run start:sagaCheck the gateway:
lifeline healthThe gateway and backing services also expose operational health endpoints:
curl http://localhost:3000/health
curl http://localhost:3000/ready/health is the liveness check. /ready includes configured dependency status and returns 503 if a dependency such as MongoDB, Redis, or RabbitMQ is unavailable.
Use the built-in demo seed before trying matching and inventory commands:
lifeline demo seedThe demo hospital id is:
660000000000000000000101
Use this full 24-character MongoDB ObjectId in commands. Short ids such as 1001 or 10001 are not valid MongoDB ObjectIds and will be rejected.
Interactive mode:
lifeline emergency createNon-interactive mode:
lifeline emergency create \
--patient amar \
--blood O+ \
--organ kidney \
--hospital 660000000000000000000101 \
--lat 18.902 \
--lng 67.8764 \
--urgency criticalSupported urgency values are critical, urgent, and standard. The CLI also accepts high as an alias for urgent.
lifeline donors nearby \
--lat 19.076 \
--lng 72.8777 \
--radius 25000 \
--blood A+ \
--organ kidney \
--limit 10The --blood value is the recipient blood type. The matching service returns compatible donors based on blood type, organ type, availability, health status, location, and score.
Copy the emergency request _id returned from step 3:
lifeline match run <requestId>Check the status later:
lifeline match status <requestId>lifeline inventory reserve 660000000000000000000101 \
--blood A+ \
--units 1View hospital stock:
lifeline inventory stock 660000000000000000000101Update stock:
lifeline inventory update 660000000000000000000101 \
--blood A+ \
--units +5 \
--lat 19.076 \
--lng 72.8777Direct notification:
lifeline notify sms --to +911111111111 --message "Compatible donor found"Broadcast notification:
lifeline notify broadcast --message "Maintenance starts at 8 PM"Broadcasts do not require --to.
lifeline saga event --event emergency.created --request <requestId>
lifeline saga history <requestId>
lifeline analytics event --event emergency.created --request <requestId>
lifeline analytics metricsConfig Error: <PORT_NAME> must be a valid number between 1-65535 means a service port environment variable is invalid. Fix the value before starting the service.
Config Error: JWT_SECRET is required in production means the gateway is running with NODE_ENV=production and no gateway secret is configured.
Config Error: JWT_SECRET must be at least 32 characters when STRICT_SECRET_VALIDATION=true means strict secret validation is enabled. Either provide stronger secrets or set STRICT_SECRET_VALIDATION=false for local compatibility.
Use X-Correlation-ID when debugging a workflow across services:
curl -H "X-Correlation-ID: debug-001" http://localhost:3000/healthThe same value is returned in the response and included in request logs.
400 Invalid hospitalId: 1001 means the command needs a real 24-character MongoDB ObjectId.
400 Invalid bloodType means the blood type must be one of A+, A-, B+, B-, AB+, AB-, O+, or O-.
400 Invalid urgency means the urgency must be critical, urgent, standard, or the CLI alias high.
400 Missing required fields: to should not happen for broadcast notifications. Broadcast commands require only --message.
These workflows are covered by automated tests in tests/unit/lifelineWorkflow.test.js.
Test case 1: critical kidney request, nearby donors, and broadcast.
lifeline emergency create --patient case-001 --blood O+ --organ kidney --hospital 660000000000000000000101 --lat 18.902 --lng 67.8764 --urgency critical
lifeline donors nearby --lat 18.902 --lng 67.8764 --radius 15000 --blood O+ --organ kidney --limit 5
lifeline notify broadcast --message "Maintenance starts at 8 PM"Test case 2: high urgency heart request, match run/status, and SMS.
lifeline emergency create --patient case-002 --blood A+ --organ heart --hospital 660000000000000000000101 --lat 19.071 --lng 72.345 --urgency High
lifeline match run 66000000000000000000e001
lifeline match status 66000000000000000000e001
lifeline notify sms --to +911111111111 --message "Compatible donor found"Test case 3: inventory update/reserve, low-stock alerts, saga event, and analytics.
lifeline inventory stock 660000000000000000000101
lifeline inventory update 660000000000000000000101 --blood A+ --units +5 --lat 19.076 --lng 72.8777
lifeline inventory reserve 660000000000000000000101 --blood A+ --units 1
lifeline inventory alerts --threshold 3
lifeline saga event --event emergency.created --request 66000000000000000000e001
lifeline analytics event --event emergency.created --request 66000000000000000000e001
lifeline analytics metrics