A simple web service that processes receipts and awards points based on defined rules. The service exposes a RESTful API that allows you to submit receipts and later retrieve the points awarded. This project also demonstrates the building of a RESTful API using Go, along with Dockerization for seamless deployment and scalability.
The Receipt Processor service accepts a JSON receipt via the POST /receipts/process endpoint and returns an ID. You can then retrieve the points awarded for that receipt by calling the GET /receipts/{id}/points endpoint. The points calculation is based on several rules (such as counting alphanumeric characters in the retailer's name, checking total amounts, bonus for certain item descriptions, etc).
Key endpoints include:
-
POST /receipts/process
- Description: Submits a receipt for processing.
- Request: JSON receipt conforming to the
Receipt
schema. - Response: JSON with an
id
field.
-
GET /receipts/{id}/points
- Description: Returns the points awarded for the receipt identified by the provided ID.
- Response: JSON with a
points
field.
- Build the Docker image:
docker-compose build app
- Run the application container:
docker-compose up app
The service will be available at http://localhost:8080.
A dedicated service in docker-compose.yml
buils the image from the builder stage(which has go installed) and runs the tests.
- Run tests:
docker-compose up test --build
To run it locally:
go test -v ./...
Built with ❤️ by Sirius829