The MS Delivery Courier Service is a lightweight REST microservice that exposes courier order endpoints for internal or external clients (such as courier mobile apps). It acts as an intermediary between the courier interface and the core Order Management Service, using Spring Cloud OpenFeign to forward and manage communication.
This design isolates courier-specific API contracts while maintaining a clean separation of business logic, which resides in the backend service.
- Provide REST endpoints for courier order management (change state, history, and detail).
- Delegate business operations to
CourierOrderClientvia Feign integration. - Validate and secure courier requests.
- Cache authentication tokens using Redis.
- Handle internationalized responses and exception management.
ββββββββββββββββββββββββββββββββ
β Courier Mobile App / UI β
ββββββββββββββββ¬ββββββββββββββββ
β (REST API)
ββββββββββββββββ΄βββββββββββββββββββββββββββ
β MS Delivery Courier Service β
β------------------------------------------β
β @RestController (CourierController) β
β βββ Delegates to CourierOrderClient β
β βββ Uses Feign to call Order Service β
β βββ Token caching with Redis β
β βββ Security & Localization β
ββββββββββββββββ¬βββββββββββββββββββββββββββ
β
βββββββββ΄βββββββββ
β Order Service β
ββββββββββββββββββ
| Layer | Technology |
|---|---|
| Language | Java 17+ |
| Framework | Spring Boot 3.x |
| API Client | Spring Cloud OpenFeign |
| Cache | Redis |
| Security | Spring Security + JWT |
| Validation | Jakarta Validation (@Valid) |
| Documentation | Swagger / Springdoc OpenAPI |
| Build Tool | Gradle 8+ |
# Clone the repository
git clone https://github.com/guavapay/ms-delivery-courier.git
cd ms-delivery-courier
# Build the project
./gradlew clean build# Run with Gradle
./gradlew bootRun
# Or run the packaged JAR
java -jar build/libs/ms-delivery-courier-*.jarDefault port: 8082
Main configuration file:
src/main/resources/application.yml
server:
port: 8082
spring:
redis:
host: localhost
port: 6379
feign:
client:
config:
default:
connectTimeout: 5000
readTimeout: 5000All endpoints are under the base path:
/courier/order
POST /courier/order/change/state
Updates the current delivery state of an order.
Request Body
{
"orderId": 1023,
"newState": "IN_TRANSIT",
"comment": "Courier picked up the package"
}Response
{
"status": "success",
"message": "Order state updated successfully"
}POST /courier/order/history
Returns a list of historical orders for a courier.
Request Body
{
"courierId": 501,
"startDate": "2025-10-01T00:00:00",
"endDate": "2025-10-05T23:59:59",
"status": "DELIVERED"
}Response
[
{
"orderId": 1023,
"state": "DELIVERED",
"deliveryTime": "2025-10-05T14:35:00"
}
]GET /courier/order/detail?id={parcelId}
Retrieves detailed information about a single order.
Example Request
GET /courier/order/detail?id=12345
Response
{
"orderId": 12345,
"courierId": 501,
"state": "DELIVERED",
"destination": "123 Elm Street, London"
}| Model | Description |
|---|---|
| OrderStateChangeRequest | Request object to update an orderβs delivery state |
| CourierOrderFilter | Filters for retrieving order history |
| CourierOrderHistoryDto | Detailed representation of a courierβs order or delivery record |
- JWT authentication is enforced on all endpoints.
- Tokens are validated and cached via Redis (
TokenStorage). - Implemented filters:
SecurityFilterandFeignInterceptor.
Header Example:
Authorization: Bearer <jwt_token>Swagger UI available at:
http://localhost:8082/swagger-ui.html
OpenAPI JSON spec:
http://localhost:8082/v3/api-docs
docker build -t guavapay/ms-delivery-courier .docker run -d -p 8082:8082 guavapay/ms-delivery-courier| Issue | Cause | Fix |
|---|---|---|
401 Unauthorized |
Missing/invalid JWT | Provide a valid token |
Feign timeout |
Target service unreachable | Check network or Feign client config |
Redis connection error |
Redis not running | Start Redis or update host config |
We welcome pull requests and feature suggestions!
- Fork the repository
- Create a new feature branch
- Submit a PR with clear description and test coverage
Licensed under the MIT License. See the LICENSE file for details.