A team has a legacy Express.js API (Node 14, JavaScript, minimal tests) and wants to modernize it. The app can be built and run locally.
An Express API with 45 routes, MongoDB via Mongoose, no TypeScript, 12% test coverage.
- Codebase Scanner: Node.js 14, Express 4.17, MongoDB/Mongoose, 3 middleware layers
- Dependency Inventory: 67 dependencies, 12 vulnerable, 8 deprecated
- Architecture Mapper: Monolithic, 3 layers (routes → services → models)
- API Extractor: 45 REST endpoints documented, 7 undocumented
- Data Model Extractor: 8 Mongoose models, 3 with no indexes
- Test Discovery: 12% coverage, integration tests only
🚦 Human Gate: Extraction reviewed — accurate.
- PRD generated from codebase analysis
- 6 FRDs generated, each with "Current Implementation" documenting how features work today
🚦 Human Gate: PRD and FRDs approved.
The team assesses:
- ☑ Can build and start locally (
npm startworks) - ☑ MongoDB runs in Docker (
docker-compose up) - ☑ API endpoints return responses
- ☐ No frontend (API only)
- ☑ Dev environment config exists (
.env.development) - ☑ Existing tests run (
npm test— 12 pass)
Decision: Track A — the app is testable.
For each of the 6 feature areas:
- Gherkin capture: 12 scenarios describing login, logout, token refresh, password reset as they work today. Tagged
@existing-behavior. - Test scaffolding: Cucumber steps + Supertest API tests. All target current behavior.
- Green verification: All 12 tests pass against the running app.
🚦 Human Gate: Gherkin reviewed — accurate.
User management (8 scenarios), Search (6), Orders (14), Notifications (4), Admin (7).
Total green baseline: 51 scenarios, all passing. This is the regression safety net.
Team selects: Modernize (update deps, add TypeScript) + Security (fix vulnerabilities)
- Modernization: Node 14 EOL, 8 deprecated packages, callback patterns, missing error handling
- Security: 12 vulnerable deps, 3 injection risks, missing rate limiting
4 increments planned, each with Gherkin deltas:
-
sec-001: Patch critical vulnerabilities
- Gherkin deltas: 3 new scenarios for injection prevention
- 51 existing scenarios must still pass
-
mod-001: Migrate to TypeScript
- Gherkin deltas: 0 new (behavior unchanged)
- 51 existing + 3 security scenarios must pass
-
mod-002: Update to Node 20 + Express 5
- Gherkin deltas: 2 modified (API behavior changes slightly)
- All existing scenarios must pass
-
mod-003: Add comprehensive test coverage
- Gherkin deltas: 24 new scenarios for uncovered paths
- All existing scenarios must pass
Each increment: update Gherkin → update tests → contracts → implement → deploy.
The green baseline catches any regressions — if modernization breaks existing behavior, the tests fail immediately.
The legacy API now has TypeScript, Node 20, Express 5, patched vulnerabilities, 80%+ test coverage — without a full rewrite. Every change was verified against the green baseline.