Skip to content

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.

Notifications You must be signed in to change notification settings

thereds11/receipt-processor

Repository files navigation

Receipt Processor

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.

Table of Contents

Overview

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).

API Specification

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.

Building and Running

  1. Build the Docker image:
    docker-compose build app
  1. Run the application container:
    docker-compose up app

The service will be available at http://localhost:8080.

Running Tests with Docker

A dedicated service in docker-compose.yml buils the image from the builder stage(which has go installed) and runs the tests.

  1. Run tests:
    docker-compose up test --build

To run it locally:

    go test -v ./...

Built with ❤️ by Sirius829

About

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.

Resources

Stars

Watchers

Forks