How pythagora-io/pythagora works
Pythagora records server activity and replays it to validate integration tests, including HTTP responses and MongoDB behavior; it also exposes a separate GPT-assisted unit-test generation and expansion workflow. Generated tests can be exported to Jest. The runtime excerpts establish the capture/replay and export relationships shown below. Unit-generation internals and some integrations are only documented or indexed, so uncertain connections are dashed or omitted.
Main entry points: export.js Export orchestration · Pythagora.js Capture replay engine · mongodb.js Mongo replay · starting.js Runtime startup
Components 27
Capture and replay
- CLI entry
src/bin/run.js - Runtime startup
src/helpers/starting.js - Capture replay engine
src/Pythagora.js - HTTP middleware
src/helpers/middlewares.js - Replay runner
src/RunPythagoraTests.js - HTTP patches
src/patches/http.js - Express patch
src/patches/express.js
State and integrations
- Mongo instrumentation
src/patches/mongo-collection.js - Mongo replay
src/helpers/mongodb.js - Mongo operation rules
src/const/mongodb.js - Redis interceptor
src/helpers/redis.js
Unit test generation
- Generate unit tests
src/helpers/unitTests.js - Expand unit tests
src/helpers/unitTestsExpand.js - API configuration
src/helpers/api.js - CLI interaction
src/helpers/cmdGUI.js
Jest export
- Export orchestration
src/commands/export.js - Jest test export
src/helpers/exports.js - Run Jest tests
src/commands/jest.js
Shared support
- Argument config
src/utils/getArgs.js - Test data utilities
src/utils/common.js - Status and diagnostics
src/utils/cmdPrint.js - Legacy conversion
src/utils/legacy.js
Other components
- Developer
- Express app
- MongoDB
- Redis
- GPT service
Connections 34
- Developer → CLI entry: starts command
- CLI entry → Runtime startup: starts runtime
- Runtime startup → Capture replay engine: initializes
src/helpers/starting.js - Runtime startup → Replay runner: starts replay
src/helpers/starting.js - Express app → HTTP middleware: handles requests
- HTTP middleware → Mongo replay: prepares database
src/helpers/middlewares.js - HTTP middleware → Redis interceptor: sets mode
src/helpers/middlewares.js - Capture replay engine → Mongo replay: cleans database
src/Pythagora.js - Capture replay engine → Replay runner: replays requests
src/Pythagora.js - Capture replay engine → Redis interceptor: initializes
src/Pythagora.js - Capture replay engine → Test data utilities: uses utilities
src/Pythagora.js - Mongo instrumentation → Mongo replay: delegates replay
src/patches/mongo-collection.js - Mongo instrumentation → Mongo operation rules: reads operation rules
src/patches/mongo-collection.js - Mongo replay → Mongo operation rules: uses operation rules
src/helpers/mongodb.js - Mongo replay → MongoDB: reads and writes
- Redis interceptor → Redis: intercepts activity
- Express patch → HTTP middleware: installs middleware
src/patches/express.js - HTTP patches → Runtime startup: uses startup
src/patches/http.js - Replay runner → Test data utilities: compares test data
src/RunPythagoraTests.js - Developer → Generate unit tests: requests generation
- Developer → Expand unit tests: requests expansion
- Generate unit tests → API configuration: uses API config
src/helpers/unitTests.js - Generate unit tests → CLI interaction: uses CLI interface
src/helpers/unitTests.js - Expand unit tests → API configuration: uses API config
src/helpers/unitTestsExpand.js - Expand unit tests → CLI interaction: uses CLI interface
src/helpers/unitTestsExpand.js - API configuration → GPT service: configures API access
- Export orchestration → Test data utilities: loads generated tests
src/commands/export.js - Export orchestration → Legacy conversion: converts legacy tests
src/commands/export.js - Export orchestration → API configuration: gets API config
src/commands/export.js - Export orchestration → Jest test export: exports eligible tests
src/commands/export.js - Export orchestration → Argument config: reads arguments
src/commands/export.js - Jest test export → GPT service: generates Jest content
- Run Jest tests → Developer: runs generated tests
- Replay runner → Status and diagnostics: reports results
src/RunPythagoraTests.js