Here are the main tools and technologies used in this project:
MicroMocker is a simple and flexible solution designed for developers working on microservices that need to simulate service-to-service communication during the development phase. It allows developers to easily mock APIs for different services, including the use of JWT authentication, to simulate real-world scenarios in a safe and controlled environment.
This project was built with FastAPI and is ideal for those who need to work on their microservices' business logic in parallel, without waiting for actual service endpoints to be implemented.
- Parallel Development: Mock multiple services to simulate real communication between them while working on business logic.
- JWT Authentication: Supports JWT authentication to mimic secure communication between microservices.
- Customizable Data: Provides easy-to-use methods to load custom mock data from JSON files.
- Service Isolation: Each service can run on a different port and simulate different service endpoints.
The project consists of multiple services, each running on a different port, and simulating the communication between services. The architecture includes:
- User Service: Simulates the user management service.
- Vehicle Service: Simulates the vehicle management service.
- JWT Authentication: Both services are secured using JWT tokens for communication.
-
User Service (
http://localhost:8001
):GET /api/user/{user_id}
: Fetches user information from a mock JSON file.- Example response:
{ "user_id": "123", "name": "John Doe", "email": "[email protected]" }
-
Vehicle Service (
http://localhost:8002
):GET /api/vehicle/{vehicle_id}
: Fetches vehicle data from a mock JSON file.- Example response:
{ "vehicle_id": "456", "make": "Toyota", "model": "Corolla", "year": 2020 }
-
Clone the repository:
git clone https://github.com/mirolim-dev/MicroMocker.git
-
Install dependencies: Make sure you have Python 3.x installed. Then, install the required packages:
pip install -r requirements.txt
-
Run the services: The project uses
uvicorn
to run FastAPI apps. You can run both services simultaneously by executing the following:python main.py
This will start two services:
- User service:
http://localhost:8001
- Vehicle service:
http://localhost:8002
- Test the endpoints: After starting the services, you can access the mock endpoints via a browser or tools like Postman or curl:
http://localhost:8001/api/user/{user_id}
http://localhost:8002/api/vehicle/{vehicle_id}