{"id":26060490,"url":"https://github.com/saravanan81java/blind-auction-system","last_synced_at":"2025-10-26T09:45:22.578Z","repository":{"id":259642196,"uuid":"879106056","full_name":"saravanan81java/blind-auction-system","owner":"saravanan81java","description":"Blind auction system","archived":false,"fork":false,"pushed_at":"2025-02-21T23:43:38.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T00:26:32.592Z","etag":null,"topics":["java","jpa","jpa-hibernate","repository","springboot"],"latest_commit_sha":null,"homepage":"","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/saravanan81java.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":"2024-10-27T01:50:37.000Z","updated_at":"2025-02-21T23:43:42.000Z","dependencies_parsed_at":"2024-10-27T03:26:56.099Z","dependency_job_id":"0ae17c44-7bcf-4de9-b53b-25dc975ef0a4","html_url":"https://github.com/saravanan81java/blind-auction-system","commit_stats":null,"previous_names":["saravanan81java/blind-auction-system"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanan81java%2Fblind-auction-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanan81java%2Fblind-auction-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanan81java%2Fblind-auction-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saravanan81java%2Fblind-auction-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saravanan81java","download_url":"https://codeload.github.com/saravanan81java/blind-auction-system/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242559216,"owners_count":20149326,"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":["java","jpa","jpa-hibernate","repository","springboot"],"created_at":"2025-03-08T14:08:29.366Z","updated_at":"2025-10-26T09:45:22.458Z","avatar_url":"https://github.com/saravanan81java.png","language":"Java","readme":"# Blind auction system\n\n# Project Basic Structure\nThe folder structure of the Blind Auction System repository is as follows:\n\n\n```\nroot\n├── user-service\n│   ├── src\n│   │   └── main\n│   │       └── java/com/yourcompany/users\n│   │           └── UserController.java\n│   │           └── User.java\n│   │           └── UserRepository.java\n│   └── pom.xml\n│\n├── auction-service\n│   ├── src\n│   │   └── main\n│   │       └── java/com/yourcompany/auctions\n│   │           └── AuctionController.java\n│   │           └── ProductController.java\n│   │           └── Auction.java\n│   │           └── Product.java\n│   │           └── Bid.java\n│   │           └── AuctionRepository.java\n│   │           └── BidRepository.java\n│   │           └── ProductRepository.java\n│   └── pom.xml\n│\n└── pom.xml\n```\nThis structure includes two services: user-service and auction-service, each with its respective Java files and Maven configuration (pom.xml).\n\n# Run the Services\n\n1) Start the user-service:\n    ```\n    cd user-service\n    mvn spring-boot:run\n    ```\n    \n2) Start the auction-service:\n    ```\n    cd ../auction-service\n    mvn spring-boot:run\n    ```\n\nNow, both services are up and running. You can interact with the API endpoints (e.g., /auctions/ping, /users/ping, /users/validate) using tools like Postman or curl.\n\nAPI Details and Endpoints explanation:\n\n# Auction Service \n\n1) createAuction:\n\n    - Validates the seller's token by calling the User Service.\n    - If validation passes, saves the auction details and sets the seller’s token.\n\n2) placeBid:\n\n    - Validates the buyer’s token.\n    - Ensures that the bid amount meets the minimum bid price.\n    - Associates the bid with the auction and saves it.\n\n3) getAllAuctions:\n\n    - Returns a list of all auctions available for bidding.\n\n4) endAuction:\n\n    - Ends the auction by finding the highest bid.\n    - In case of a tie on the bid amount, the earliest bid (timestamp) is selected as the winner.\n\n5) validateUserToken:\n\n    - Calls the User Service to validate user tokens by role type (buyer or seller).\n    - Throws an error if the token is invalid or the validation service fails.\n \n6) Auctions Endpoints:\n   \n    - /auctions/register : Creates a new auction with a seller’s token and minimum bid requirement.\n    - /auctions/list : Lists all open auctions.\n    - /auctions/{auctionId}/bid : Places a bid on an auction if the bid meets the minimum amount and the auction is open.\n    - /auctions/{auctionId}/end : Closes the auction and returns the winning bid, if any. The first highest bid in descending order is considered the winner.\n\n8) getAllProducts:\n   \n    - Returns a list of all products.\n      \nNotes\n    - The RestTemplate in validateUserToken simulates a call to the UserService to verify tokens.\n    - Error Handling: Error messages are thrown if auction or bid validation fails.\n    - Comparators: endAuction selects the highest bid and resolves ties by timestamp.\n\n\n# User Service\n\n1) Token Map:\n\n    - userTokens is a Map\u003cString, String\u003e that simulates a database of user tokens \n      mapped to user types (e.g., \"seller\" or \"buyer\").\n    - For this example, tokens are pre-populated. In a real application, these would likely be stored \n      in a database or managed by an authentication service.\n\n2) validateUserToken Endpoint:\n\n    - URL: /users/validate\n    - Parameters:\n        - token: The token to validate.\n        - type: Expected type of user (\"seller\" or \"buyer\").\n\n3) Validation Logic:\n    - Checks if the provided token exists in the userTokens map.\n    - Verifies that the token corresponds to the correct user type (buyer or seller).\n\n4) Return:\n    - Returns \"Valid User\" if the token and type match.\n    - Returns \"Invalid Token\" if the token doesn’t exist in the map.\n    - Returns \"Invalid User Type\" if the token exists but is for the wrong user type.\n\n\n# Sample Data Pre-population\nTo pre-populate the database, Add a CommandLineRunner bean to insert sample users and auction when the application starts:\n \n    @Bean\n    CommandLineRunner initDatabase(UserRepository userRepository) { \n\n    }\n \n    @Bean\n    CommandLineRunner initDatabase(ProductRepository productRepository, AuctionRepository auctionRepository) {\n\t\treturn args -\u003e {\n\t\t\t\n\t\t\tList\u003cProduct\u003e listOfProducts = new ArrayList\u003c\u003e();\n\t\t\t.....\n\t\t\tproductRepository.saveAll(listOfProducts); \n\t\t\t\n\t\t\tauctionRepository.save(new Auction(....));\n\t\t};\n\t}\n\n# Test Cases \nUser service API endpoints JUnit Test cases\n\n  - testGetPing(): Validates that the /ping endpoint returns the expected string.\n  - testValidateToken_ValidUser(): Mocks a valid user return from userService.validateToken() and checks if the response is \"Valid User\".\n  - testValidateToken_InvalidUser(): Mocks a null return from userService.validateToken() and verifies that the response is \"Invalid User\".\n\nMake sure JUnit and Mockito dependencies to successfully execute these tests.\n\nUser service services layer JUnit Test cases\n\n  - testValidateToken_Valid(): Verifies that a valid token returns a non-null user.\n  - testValidateToken_Invalid(): Tests that an invalid token throws a RuntimeException with the message \"Invalid token\".\n\nThis structure uses Mockito to mock the UserRepository and validate the behavior of validateToken().\n\nAuction service API endpoints JUnit Test cases\n...\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanan81java%2Fblind-auction-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaravanan81java%2Fblind-auction-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaravanan81java%2Fblind-auction-system/lists"}