{"id":22781788,"url":"https://github.com/soyvural/spring-data-dynamodb","last_synced_at":"2025-07-29T09:34:02.548Z","repository":{"id":43830821,"uuid":"459137667","full_name":"soyvural/spring-data-dynamoDB","owner":"soyvural","description":"Spring Data DynamoDB Repository Demo Application","archived":false,"fork":false,"pushed_at":"2025-06-28T11:39:29.000Z","size":41,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T12:34:13.652Z","etag":null,"topics":["aws","docker","dynamodb","jwt","rest-api","spring","spring-security","springboot","terraform"],"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/soyvural.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":"2022-02-14T11:39:21.000Z","updated_at":"2025-06-28T11:39:33.000Z","dependencies_parsed_at":"2025-07-29T09:31:13.338Z","dependency_job_id":null,"html_url":"https://github.com/soyvural/spring-data-dynamoDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soyvural/spring-data-dynamoDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyvural%2Fspring-data-dynamoDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyvural%2Fspring-data-dynamoDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyvural%2Fspring-data-dynamoDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyvural%2Fspring-data-dynamoDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soyvural","download_url":"https://codeload.github.com/soyvural/spring-data-dynamoDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soyvural%2Fspring-data-dynamoDB/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267662460,"owners_count":24123891,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["aws","docker","dynamodb","jwt","rest-api","spring","spring-security","springboot","terraform"],"created_at":"2024-12-11T21:08:35.651Z","updated_at":"2025-07-29T09:34:02.472Z","avatar_url":"https://github.com/soyvural.png","language":"Java","readme":"## Spring Data DynamoDB Repository Demo Application\n\nIn this repo we create a table named Product with ID placed the \"partition key\".\nWe will use the technologies below to create a demo application:\n\n- **Terraform** to provision DynamoDB table. \n  - Terraform backend will be in aws:s3 and lock will be kept in the DynamoDB table. So, you need to create s3 bucket for the backend and lock table beforehand.\n- **Spring Data DynamoDB** for DynamoDB repository module.\n   - Spring has no officially spring data module for DynamoDB and suggests using this [External Library](https://github.com/boostchicken/spring-data-dynamodb) in [Spring doc.](https://spring.io/projects/spring-data ) \n- **Spring Actuator** for component and application health status.\n- **Spring Web** for Restful API for CRUD operations.\n- **Swagger** for Rest API documentation.\n- **JWT Token** for API endpoints.\n- **Docker** for containerizing our distribution package.\n\n* [Storage Deploy](#storage-deploy)\n* [Build and push Docker](#build-and-push-docker)\n* [Run the application in Local](#run-the-application-in-local)\n* [Call API endpoints](#call-api-endpoints)\n* [Swagger Documentation](#swagger-documentation)\n* [Storage Destroy](#storage-destroy)\n\n\n## Storage Deploy\nIn this section we will deploy the storage by using Terraform. We proviosion a DynamoDB table with the following configuration:\n```terraform\nresource \"aws_dynamodb_table\" \"product\" {\n  name         = \"product\"\n  billing_mode = \"PAY_PER_REQUEST\"\n  hash_key     = \"id\"\n\n  attribute {\n    name = \"id\"\n    type = \"S\"\n  }\n\n  tags = {\n    Name        = \"product\"\n    Environment = \"staging\"\n  }\n}\n```\nTo build the storage, we need to run the following command and let the Product table provisioned:\n```shell\nsh deploy/storage/deploy.sh\n```\n\n## Build and push Docker\nTo build and push the Docker image, we need to run the following command:\n```shell\nsh deploy/backend/api/image/deploy.sh\n```\n\n## Run and test the application\nTo run the application, we need to run the following command:\n```shell\ndocker run -p 8080:8080 \\\n  -e JWT_SECRET=${JWT_SECRET} \\\n  -e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \\\n  -e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_CESS_KEY} \\\n   docker.io/soyvural/spring-data-dynamodb\n````\n\n## Call API endpoints\n1. Authenticate and get a JWT token:\n  - User role can only call \"GET /products\" and \"GET /products/{id}\" endpoints.\n  - So, let's get a JWT token for the admin user and access every endpoint.\n\n```shell\n  curl --location --request POST 'http://localhost:8080/authenticate' --header 'Content-Type: application/json' \\\n  --data-raw '{\n      \"username\": \"admin\",\n      \"password\": \"pwd\"\n  }''\n  \n  Response:\n  {\n    \"token\": \"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NDg0MDE5NSwiZXhwIjoxNjQ0OTI2NTk1LCJpc3MiOiJjb20ubXZzIn0.D3jONpGmivO_ZrI141LgfC35Hyje_bMW_1D5kzf4_G-xtIH9F4I-FaiyLskZG_tjPUEvQ5O2Xbu-RF2GR3mM7A\",\n    \"expiresIn\": \"Tue Feb 15 12:03:15 UTC 2022\"\n  }\n```\n\n2. Call \"GET /products\" and \"GET products/{id}\" endpoint:\n  - We can get all products by calling \"GET /products\" endpoint.\n```shell\ncurl --location --request GET 'http://localhost:8080/api/v1/products' \\\n--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NDgzMDM3MSwiZXhwIjoxNjQ0OTE2NzcxLCJpc3MiOiJjb20ubXZzIn0.n0DI9SMhYzFKCg7K4atg1iaTEfqR1Td8SEbULin-ybeFsNzd9pScoGjAwKypaV-BRhq1Vr2PiLSg7_KMDgb50w'\n\nResponse:\n[\n    {\n        \"id\": \"869d9b64-6159-4b5b-9fc3-944c6407ad38\",\n        \"name\": \"Iphone 13\",\n        \"category\": \"Mobile Phone\",\n        \"price\": 134.0\n    },\n    {\n        \"id\": \"de5d47f1-460a-4217-b862-f1b3a9a1fc05\",\n        \"name\": \"Iphone 13\",\n        \"category\": \"Mobile Phone\",\n        \"price\": 1302.16\n    }\n]\n\ncurl --location --request GET 'http://localhost:8080/api/v1/products/de5d47f1-460a-4217-b862-f1b3a9a1fc05' \\\n--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NDgzMDM3MSwiZXhwIjoxNjQ0OTE2NzcxLCJpc3MiOiJjb20ubXZzIn0.n0DI9SMhYzFKCg7K4atg1iaTEfqR1Td8SEbULin-ybeFsNzd9pScoGjAwKypaV-BRhq1Vr2PiLSg7_KMDgb50w' \\\n--data-raw ''\n\nResponse:\n{\n    \"id\": \"de5d47f1-460a-4217-b862-f1b3a9a1fc05\",\n    \"name\": \"Iphone 13\",\n    \"category\": \"Mobile Phone\",\n    \"price\": 1302.16\n}\n```\n\n3. Call \"DELETE products/{id}\" endpoint:\n```shell\ncurl --location --request DELETE 'http://localhost:8080/api/v1/products/7c4d88b0-fb2f-45fe-885f-5a8117972d11' \\\n--header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NDgzMDM3MSwiZXhwIjoxNjQ0OTE2NzcxLCJpc3MiOiJjb20ubXZzIn0.n0DI9SMhYzFKCg7K4atg1iaTEfqR1Td8SEbULin-ybeFsNzd9pScoGjAwKypaV-BRhq1Vr2PiLSg7_KMDgb50w' \\\n--data-raw ''\n\nInvalid Product Example:\ncurl --location --request DELETE 'http://localhost:8080/api/v1/products/7c4d88b0-fb2f-45fe-885f-5a81179' \\\n\u003e --header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTY0NDgzMDM3MSwiZXhwIjoxNjQ0OTE2NzcxLCJpc3MiOiJjb20ubXZzIn0.n0DI9SMhYzFKCg7K4atg1iaTEfqR1Td8SEbULin-ybeFsNzd9pScoGjAwKypaV-BRhq1Vr2PiLSg7_KMDgb50w' \\\n\u003e --data-raw ''\n{\"timestamp\":\"2022-02-14T12:21:29.159+00:00\",\"message\":\"Not found\",\"details\":\"uri=/api/v1/products/7c4d88b0-fb2f-45fe-885f-5a81179\"}\n```\n\nYou can populate for put as well.\n\n## Swagger Documentation\nTo access REST API documentation you can use: http://localhost:8080/swagger-ui/\n1. To access product-api-v1 version 1.0 documentation by using http://localhost:8080/v2/api-docs?group=product-api-v1.0\n\n![swagger-ui-secreenshot](https://i.ibb.co/6Pm8H4q/Screenshot-2022-02-14-at-12-49-07.png)\n\n## Storage Destroy\nTo destroy the storage, we need to run the following command:\n```shell\nsh deploy/storage/destroy.sh\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyvural%2Fspring-data-dynamodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoyvural%2Fspring-data-dynamodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoyvural%2Fspring-data-dynamodb/lists"}