Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¨ MS Delivery Courier Service


🧭 Table of Contents


πŸ“¦ Overview

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.


🎯 Core Responsibilities

  • Provide REST endpoints for courier order management (change state, history, and detail).
  • Delegate business operations to CourierOrderClient via Feign integration.
  • Validate and secure courier requests.
  • Cache authentication tokens using Redis.
  • Handle internationalized responses and exception management.

πŸ—οΈ Architecture

 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚   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  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧰 Technology Stack

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+

πŸš€ Getting Started

Installation

# Clone the repository
git clone https://github.com/guavapay/ms-delivery-courier.git
cd ms-delivery-courier

# Build the project
./gradlew clean build

Running the Service

# Run with Gradle
./gradlew bootRun

# Or run the packaged JAR
java -jar build/libs/ms-delivery-courier-*.jar

Default port: 8082


βš™οΈ Configuration

Main configuration file: src/main/resources/application.yml

server:
  port: 8082

spring:
  redis:
    host: localhost
    port: 6379

feign:
  client:
    config:
      default:
        connectTimeout: 5000
        readTimeout: 5000

πŸ“˜ API Reference

All endpoints are under the base path:

/courier/order

1. Change Order State

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"
}

2. Retrieve Order History

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"
  }
]

3. Get Order Details

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 Definitions

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

πŸ” Security

  • JWT authentication is enforced on all endpoints.
  • Tokens are validated and cached via Redis (TokenStorage).
  • Implemented filters: SecurityFilter and FeignInterceptor.

Header Example:

Authorization: Bearer <jwt_token>

🧭 Swagger API Docs

Swagger UI available at:

http://localhost:8082/swagger-ui.html

OpenAPI JSON spec:

http://localhost:8082/v3/api-docs

🐳 Docker Deployment

Build

docker build -t guavapay/ms-delivery-courier .

Run

docker run -d -p 8082:8082 guavapay/ms-delivery-courier

🧩 Troubleshooting

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

🀝 Contributing

We welcome pull requests and feature suggestions!

  1. Fork the repository
  2. Create a new feature branch
  3. Submit a PR with clear description and test coverage

πŸ“œ License

Licensed under the MIT License. See the LICENSE file for details.


About

The MS Delivery Courier Service is a backend microservice built with Spring Boot that serves as the courier gateway within the Guavapay logistics platform. It provides REST APIs that enable courier applications and other front-end clients to: Change the state of delivery orders Retrieve courier order histories View detailed order information

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages