Parcel Tracking Service is a Go-based application that allows users to track parcels using their tracking numbers. The service fetches tracking information from the 4PX tracking website and provides it via a REST API.
cmd/
api/
main.go
config/
config.yml
internal/
handler/
handler.go
parser/
manager_test.go
manager.go
parser_test.go
parser.go
scraper_test.go
scraper.go
pkg/
app/
app.go
routes/
routes.go
service/
service.go
models/
models.go
go.mod
go.sum
trackingservice.dockerfile
docker-compose.yml
- Go 1.23.3 or later
- Docker
- Docker Compose
The application configuration is stored in config.yml:
port: "8181"
max-queue-count: 10
timeout: "30s"
-
Build and run the Docker container:
docker-compose up --build
-
The service will be available at http://localhost:8181
-
Install dependencies:
go mod download
-
Build the application:
go build -o trackingservice ./cmd/api
-
Run the application:
./trackingservice
-
URL:
/track
-
Method:
POST
-
Request Body:
{ "tracking_number": "4PX3001521662170CN" }
-
Response:
{ "origin_country": "CN", "destination_country": "IE", "checkpoints": [ { "status": "Delivery information has been provided to An Post", "date": "2024-12-18 19:02" } ] }
- cmd/api/main.go: Entry point of the application.
- config/config.yml: Configuration file.
- models/models.go: Data models.
- internal/pkg/app/app.go: Application setup and initialization.
- internal/routes/routes.go: Route definitions.
- internal/handler/handler.go: HTTP handler for the tracking endpoint.
- internal/service/service.go: Service layer for handling business logic.
- internal/parser: Contains the logic for parsing tracking information.
To run the tests, use the following command:
go test ./...
This project is licensed under the MIT License.