{"id":25196098,"url":"https://github.com/ryanlevee/receipt-processor-solution","last_synced_at":"2025-04-04T15:44:30.723Z","repository":{"id":275721563,"uuid":"926960327","full_name":"ryanlevee/receipt-processor-solution","owner":"ryanlevee","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-04T08:23:27.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T08:27:03.031Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanlevee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-04T06:45:56.000Z","updated_at":"2025-02-04T08:23:30.000Z","dependencies_parsed_at":"2025-02-04T08:37:59.078Z","dependency_job_id":null,"html_url":"https://github.com/ryanlevee/receipt-processor-solution","commit_stats":null,"previous_names":["ryanlevee/receipt-processor-solution"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanlevee%2Freceipt-processor-solution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanlevee%2Freceipt-processor-solution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanlevee%2Freceipt-processor-solution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanlevee%2Freceipt-processor-solution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanlevee","download_url":"https://codeload.github.com/ryanlevee/receipt-processor-solution/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208063,"owners_count":20901568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-10T01:39:52.577Z","updated_at":"2025-04-04T15:44:30.704Z","avatar_url":"https://github.com/ryanlevee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Receipt Processor\n=================\n\nOverview\n--------\n\nThis project implements a web service for processing receipts and calculating points based on a specific ruleset from the [Fetch Rewards Receipt Processor Challenge](https://github.com/fetch-rewards/receipt-processor-challenge).\n\nThe service is built using FastAPI and includes endpoints for submitting receipts and retrieving points awarded for a given receipt ID. The project is designed to fulfill the requirements of a coding challenge, with a focus on in-memory data storage, efficient request handling, and comprehensive testing.\n\n## Key Features and Challenge Requirements\n\n- **Efficient Request Handling**: Utilizes FastAPI's async capabilities for efficient request handling.\n- **In-Memory Storage**: Stores receipt data in memory, ensuring no data persistence across application restarts.\n- **Comprehensive Testing**: Includes both unit and integration tests to ensure the correctness of the implementation.\n- **Dockerized Setup**: Provides a Dockerfile for easy containerization and deployment.\n- **Exception Handlers**: Provides exception handler examples for `ValidationError` and `HTTPException` to return meaningful error responses.\n\nAPI Endpoints\n-------------\n\n### 1.  Process Receipts\n\n*   **Endpoint**: `/receipts/process`\n*   **Method**: `POST`\n*   **Description**: Submits a receipt for processing and returns a JSON object with an ID generated by the application.\n*   **Request Body**: JSON object representing the receipt.\n*   **Response**: JSON object containing the receipt ID.\n\n#### Example Request\n\n    {\n      \"retailer\": \"Target\",\n      \"purchaseDate\": \"2022-01-01\",\n      \"purchaseTime\": \"13:01\",\n      \"items\": [\n        {\"shortDescription\": \"Mountain Dew 12PK\", \"price\": \"6.49\"},\n        {\"shortDescription\": \"Emils Cheese Pizza\", \"price\": \"12.25\"},\n        {\"shortDescription\": \"Knorr Creamy Chicken\", \"price\": \"1.26\"},\n        {\"shortDescription\": \"Doritos Nacho Cheese\", \"price\": \"3.35\"},\n        {\"shortDescription\": \"Klarbrunn 12-PK 12 FL OZ\", \"price\": \"12.00\"}\n      ],\n      \"total\": \"35.35\"\n    }\n\n#### Example Response\n\n    {\n      \"id\": \"7fb1377b-b223-49d9-a31a-5a02701dd310\"\n    }\n\n### 2.  Get Points\n\n*   **Endpoint**: `/receipts/{id}/points`\n*   **Method**: `GET`\n*   **Description**: Retrieves the points awarded for the receipt with the given ID.\n*   **Response**: JSON object containing the number of points awarded.\n\n#### Example Request\n\n    GET /receipts/7fb1377b-b223-49d9-a31a-5a02701dd310/points\n\n#### Example Response\n\n    {\n      \"points\": 28\n    }\n\nPoints Calculation Rules\n------------------------\n\n1.  One point for every alphanumeric character in the retailer name.\n2.  50 points if the total is a round dollar amount with no cents.\n3.  25 points if the total is a multiple of 0.25.\n4.  5 points for every two items on the receipt.\n5.  If the trimmed length of the item description is a multiple of 3, multiply the price by 0.2 and round up to the nearest integer.\n6.  6 points if the day in the purchase date is odd.\n7.  10 points if the time of purchase is after 2:00pm and before 4:00pm.\n\nRunning the Application via Docker\n-----------------------\nInstallation\n------------\n\n### Clone the repository\n\n    git clone https://github.com/ryanlevee/receipt-processor.git\n    \n\nMake sure you are in the root directory for the project (`receipt-processor`).\n\n### Build Docker image\n\n    docker build -t receipt-processor-image:1.0 .\n\n### Verify Docker image was successfully built\n\n    docker images\n    \n### Run a container using the image\n\n    docker run -d --name receipt-processor -p 8000:8000 receipt-processor-image:1.0\n\n### Verify the container is running\n\n    docker ps\n    \n### Verify the web service has started\n\n    docker logs receipt-processor\n    \nAPI documentation and UI can now be accessed at `http://localhost:8000/docs`.\n\n### Running Tests\n\n1.  Run the tests using pytest:\n    \n        pytest\n\nProject Structure\n-----------------\n\n    receipt-processor/\n    ├── main.py                # Main application code\n    ├── tests/\n    │   ├── __init__.py        # Test package initializer\n    │   ├── test_integration.py# Integration tests\n    │   ├── test_unit.py       # Unit tests\n    ├── requirements.txt       # Project dependencies\n    ├── Dockerfile             # Dockerfile for containerization\n    └── README.md              # Project documentation\n    \n\nRunning the Application Locally\n----------------------------------------\n\n1.  Clone the repository:\n    \n        git clone https://github.com/ryanlevee/receipt-processor.git\n        cd receipt-processor\n        \n2.  Install dependencies:\n    \n        pip install -r requirements.txt\n    \n3.  Run the application:\n    \n        uvicorn main:app --host 0.0.0.0 --port 8000\n        \n    \n4.  Access the API documentation and UI at `http://localhost:8000/docs`.\n\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanlevee%2Freceipt-processor-solution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanlevee%2Freceipt-processor-solution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanlevee%2Freceipt-processor-solution/lists"}