How disney/mocking-jukebox works
Main Components
a. Client-Side Components:
• MockingJukebox Client Library
• Service Worker (for network interception)
• Client Application (that uses the library)
b. Server-Side Components:
• Express Server
• Mock Storage System
• Proxy Handler
• Mock Service Routes
Use a three-layer architecture representation
• Top Layer: Client Browser
• Middle Layer: Mocking Jukebox Components
• Bottom Layer: Server & Storage
Component Placement
Client Side (Top):
• Client Browser |
• Client App | |
• Service Worker | |
• MJ Client Lib | |
Server Side (Bottom):
• Express Server |
• Mock Endpoint | |
• Proxy Handler | |
• Mock Storage | |
Important Flows to Illustrate
Recording Flow:
Client App -> Service Worker -> Real API
• > Mock Storage
Playback Flow:
Client App -> Service Worker -> Mock Storage
• > Client App
Technical Details to Note
• Mock Service Worker integration
• /mock endpoint
• Album-based storage structure
• Request/response transformation points
Implementation Notes
• The service worker's central role in request interception
• The separation between recording and playback modes
• The configuration flexibility
• The storage mechanism
Remember to include these key files/components from the structure:
• src/client/interception.ts
• src/server/proxy/recording.ts
• src/server/proxy/playback.ts
• mock-recordings directory
Request -> transformRequest -> Match/Record/Playback -> transformResponse -> Response
This system design should clearly show how Mocking Jukebox acts as a middleware layer between the client application and its backend services, with the ability to switch between recording real responses and playing back recorded ones.