How bhatti/api-mock-service works
Main Components
a. Core Service Components:
• HTTP Server (Port 8080) for API management
• HTTP Proxy Server (Port 8081) for request recording
• Swagger UI Interface
• Contract Testing Engine
• Mock Response Generator
• Request Recorder/Playback System
b. Storage Components:
• File-based Repository System
• Fixture Storage
• Scenario Storage
• History Storage
• OpenAPI Specs Storage
c. External Integration Points:
• Client Applications
• Target Services (being mocked)
• OpenAPI/Swagger Specifications
• HAR Files
• Postman Collections
Component Relationships
[Client Applications] ←→ [HTTP Proxy Server (8081)]
• ↓
• [Request Recorder]
• ↓
• [File Repository]
• ↑
[Client Applications] ←→ [HTTP Server (8080)] ←→ [Mock Response Generator]
• ↑ ↑
• [Swagger UI] [Template Engine]
• ↑ ↑
• [OpenAPI Specs] ←→ [Contract Testing Engine]
Key Architectural Elements to Highlight
a. Request Flow Paths:
• Recording Path: Client → Proxy → Recorder → Storage
• Playback Path: Client → Server → Generator → Response
• Contract Testing Path: Test Engine → Target Service → Validator
b. Data Storage Organization:
• Hierarchical storage structure for:
• API Scenarios
• Fixtures
• Templates
• Test Results
• OpenAPI Specs
Important Subsystems
a. Template Processing:
• Template engine's connection to:
• Random Data Generation
• Variable Substitution
• Conditional Logic
• Loop Processing
b. Contract Testing:
• Consumer-Driven Testing Flow
• Producer-Driven Testing Flow
• Chaos Testing Integration
Additional Elements
• Configuration management
• Metrics collection points
• Error handling paths
• Authentication/authorization checkpoints