{"id":26648984,"url":"https://github.com/sachith89/currencydiscountcalculator","last_synced_at":"2026-02-23T19:06:01.227Z","repository":{"id":281802343,"uuid":"946469257","full_name":"sachith89/CurrencyDiscountCalculator","owner":"sachith89","description":"A demo project","archived":false,"fork":false,"pushed_at":"2025-04-22T06:02:12.000Z","size":64,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T19:32:49.946Z","etag":null,"topics":["checkstyle","docker","docker-compose","jacoco","kubernetes","linting","sonarqube","springboot","webflux"],"latest_commit_sha":null,"homepage":"http://sachith.dev","language":"Java","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/sachith89.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,"zenodo":null}},"created_at":"2025-03-11T07:29:53.000Z","updated_at":"2025-04-22T06:02:16.000Z","dependencies_parsed_at":"2025-03-11T08:30:53.182Z","dependency_job_id":"e32f3d6e-ae83-400a-927c-8d6d9d16c855","html_url":"https://github.com/sachith89/CurrencyDiscountCalculator","commit_stats":null,"previous_names":["sachith89/currencydiscountcalculator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sachith89/CurrencyDiscountCalculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachith89%2FCurrencyDiscountCalculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachith89%2FCurrencyDiscountCalculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachith89%2FCurrencyDiscountCalculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachith89%2FCurrencyDiscountCalculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sachith89","download_url":"https://codeload.github.com/sachith89/CurrencyDiscountCalculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sachith89%2FCurrencyDiscountCalculator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29751862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["checkstyle","docker","docker-compose","jacoco","kubernetes","linting","sonarqube","springboot","webflux"],"created_at":"2025-03-25T00:47:33.737Z","updated_at":"2026-02-23T19:06:01.201Z","avatar_url":"https://github.com/sachith89.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Java CI with Maven](https://github.com/sachith89/CurrencyDiscountCalculator/actions/workflows/maven.yml/badge.svg)](https://github.com/sachith89/CurrencyDiscountCalculator/actions/workflows/maven.yml)\n# 💱 Currency Exchange and Discount Calculation API\n\n## 📝 Project Description\nThis Spring Boot application integrates with a third-party currency exchange API to retrieve real-time exchange rates. It calculates the total payable amount for a bill in a specified currency after applying applicable discounts. The project demonstrates object-oriented design, authentication, testing, and modern coding practices.\n\n---\n\n## 📦 Features\n- Real-time currency conversion using third-party APIs.\n- Discounts based on user type and tenure.\n- Supports flat discounts on bills over $100.\n- Authentication for secure endpoints.\n\n---\n\n## 🏗️ Tech Stack\n- Java 23 with Spring Boot. 3.4.3\n- Maven.\n- JUnit5 and Mockito for testing.\n- SonarQube for code quality.\n- External Currency Exchange API (e.g., ExchangeRate-API or Open Exchange Rates).\n\n---\n\n```mermaid\nclassDiagram\ndirection BT\n    class AffiliateDiscount {\n\t    + checkEligibility(UserDto, Item) boolean\n    }\n\n    class CustomerDiscount {\n\t    + checkEligibility(UserDto, Item) boolean\n    }\n\n    class Discount {\n\t    + checkEligibility(UserDto, Item) boolean\n    }\n\n    class DiscountCalculateService {\n\t    + calculate(ShoppingCartEntity) InvoiceDto\n\t    + applyDiscount(Item, UserDto) void\n    }\n\n    class DiscountCalculateServiceImpl {\n\t    + calculate(ShoppingCartEntity) InvoiceDto\n\t    + applyDiscount(Item, UserDto) void\n    }\n\n    class EmployeeDiscount {\n\t    + checkEligibility(UserDto, Item) boolean\n    }\n\n    class FlatDiscount {\n    }\n\n    class FlatFiveForHundredBillDiscount {\n\t    + checkEligibility(UserDto, Item) boolean\n    }\n\n    class PercentageDiscount {\n    }\n\n\t\u003c\u003cInterface\u003e\u003e DiscountCalculateService\n\n    AffiliateDiscount --\u003e PercentageDiscount\n    CustomerDiscount --\u003e PercentageDiscount\n    DiscountCalculateServiceImpl ..\u003e DiscountCalculateService\n    EmployeeDiscount --\u003e PercentageDiscount\n    FlatDiscount --\u003e Discount\n    FlatFiveForHundredBillDiscount --\u003e FlatDiscount\n    PercentageDiscount --\u003e Discount\n\n\tclass Discount:::Peach\n\tclass DiscountCalculateService:::Ash\n\tclass FlatDiscount:::Sky\n\tclass PercentageDiscount:::Sky\n\n```\n\n---\n\n## ⚙️ Setup Instructions\n1. **Clone the Repository:**\n```bash\ngit clone https://github.com/sachith89/CurrencyDiscountCalculator.git\ncd CurrencyDiscountCalculator\n```\n2. **Configure API Key:**\n    - Add your API key in `application.properties`:\n```properties\ncurrency.api.url=https://open.er-api.com/v6/latest/\ncurrency.api.key=your-api-key\n```\n3. **Build and Run:**\n```bash\n./mvnw clean install\n./mvnw spring-boot:run\n```\n4. **Access the API:**\n    - Base URL: `http://localhost:8080`\n\n---\n\n## 📤 API Endpoints\n### 🧾 Calculate Payable Amount\n**Endpoint:** `POST /api/calculate`\n\n**Request Body:**\n```json\n{\n  \"items\": [\n    {\"name\": \"item1\", \"category\": \"grocery\", \"price\": 50},\n    {\"name\": \"item2\", \"category\": \"electronics\", \"price\": 150}\n  ],\n  \"userType\": \"employee\",  \n  \"customerTenure\": 3,  \n  \"originalCurrency\": \"USD\",\n  \"targetCurrency\": \"EUR\"\n}\n```\n\n**Response:**\n```json\n{\n  \"payableAmount\": 120.50,\n  \"currency\": \"EUR\"\n}\n```\n\n---\n\n## 🧪 Testing\n1. **Run Unit Tests:**\n```bash\n./mvnw test\n```\n2. **Generate Coverage Reports:**\n```bash\n./mvnw jacoco:report\n```\n\n---\n\n## 📈 Code Quality\n1. **Run SonarQube:**\n```bash\n./mvnw sonar:sonar\n```\n\n---\n\n## ⚙️ Build Automation\n- Run build and tests with:\n```bash\n./mvnw clean install\n```\n- Generate reports and analyze code quality:\n```bash\n./mvnw verify\n```\n\n---\n\n## 📌 Assumptions\n- Only one percentage-based discount applies per bill.\n- Percentage-based discounts do not apply to groceries.\n- A $5 flat discount applies per $100 on the bill.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachith89%2Fcurrencydiscountcalculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsachith89%2Fcurrencydiscountcalculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsachith89%2Fcurrencydiscountcalculator/lists"}