- Install Docker
- Make sure kubernetes is turned on in docker (Settings -> Kubernetes -> Enable -> Apply)
- Install Linkerd (for load balancing)
Run the commands
make init
make run
Enjoy.
make stop
make tests
Distributed app for veterinary clinics and pet data management. Includes pet registration, appointments, notifications/emails about pet vaccination, pet records update after each consultation.
Health check endpoint for all services
Endpoint: /status
Method: GET
Response: 200 OK
Body: {
"status": "ok"
}
Owner service endpoints from gateway
Endpoint: /api/owner/register
Method: POST
Payload: {
"email": "email@asd.com"
}
Response: 201 Created
Body: {
"message": "Register successful",
"ownerId": "0b2f4780-46f0-4d0f-806a-2b3033f9b285"
}
Endpoint: /api/owner/register-pet
Method: POST
Payload: {
"email": "{{email}}",
"type": "Dog",
"race": "Chihuaua",
"name": "Devil incarnate"
}
Response: 201 Created
Body: {
"message": "Pet Register successful"
}
Endpoint: /api/owner/{{email}}/pets
Method: GET
Response: 200 OK
Body: {
"message": "ok",
"pets": [
{
"Type": "Dog",
"Race": "Chihuaua",
"Name": "Devil incarnate"
}
]
}
Endpoint: /api/owner/remove-data/{{email}}
Method: DELETE
Response: 200 OK
Body: {
"message": "Owner deleted successfully"
}
Veterinary service endpoints from gateway
Endpoint: /api/veterinary/make-appointment
Method: POST
Payload: {
"petId": "1",
"dateTime": "2023-09-09T13:00:00.000Z"
}
Response: 201 Created
Body: {
"message": "Appointment made"
}
Endpoint: /end-appointment
Method: POST
Payload: {
"appointmentId": "73346b7d-288e-4ec3-a801-042576603372",
"details": "dog is evil"
}
Response: 200 OK
Body: {
"message": "Appointment ended"
}
Test endpoints
Endpoint: /api/test/timeout
Method: GET
Response: 408 Request Timeout
Body: {
"error": "Request timed out"
}
Spam this until you get 429
Endpoint: /api/test/rate-limit
Method: GET
Response: 429 Too Many Requests
Body: {
"error": "You're being rate limited"
}
Endpoint: /api/test/circuit-breaker
Method: GET
Response: 500 Internal Server Error
Body: {
"error": "Exception thrown on purpose"
}
Microservice architecture is suitable for veterinary clinic services and pet data management. These are the main pros for a microservice architecture:
-
Microservices allow for individual components to scale independently. If the veterinary clinic's services and pet data management require scalability due to varying loads, microservices can be beneficial.
-
Microservices offer flexibility in technology choices for each service. This can be helpful if different aspects of the application require different technologies or updates.
-
Isolating different functions or services can enhance security. For example, you might want to separate sensitive pet health data.
-
Microservices can make it easier to maintain and update specific components of the application without affecting the entire system. This can be advantageous for a long-term project.
-
If you need to integrate with external systems like governmental services or payments, having independent microservices can make it easier to manage these integrations without affecting the entire system.
The services will be written in C# and will use SQL server as a database. The API Gateway, Service Discovery and Load Balancers will be written in Go. Additionally, the API Gateway will have a cache in Redis.
The communication between client and API Gateway will be done using REST while the communication between services will be done via gRPC.
The Owner Service and Veterinary service will have their own databases. The Gateway will have a Redis Cache to return some cached requests. All messages wil be in JSON format.
Containerization (Docker) and orchestration (Kubernetes) will be used for Deployment and Scaling.
-
Julien Le Coupanec. ”Redis Cheatsheet - Basic Commands You Must Know”.
-
Thomas Hamilton. ”Unit Testing Tutorial – What is, Types and Test Example”.
-
Thomas Hamilton. ”Integration Testing: What is, Types with Example”.
-
Keyang Xiang. “Patterns for distributed transactions within a microservices architecture.
-
Juan Pablo Carzolio. “The Ultimate Guide to Consistent Hashing”.