{"id":19303106,"url":"https://github.com/asc-lab/aws-lambda-billing","last_synced_at":"2025-07-28T02:05:39.929Z","repository":{"id":113371639,"uuid":"152582236","full_name":"asc-lab/aws-lambda-billing","owner":"asc-lab","description":"AWS Lambda with Micronaut and without any framework - billing in serverless architecture.","archived":false,"fork":false,"pushed_at":"2019-03-12T06:25:06.000Z","size":389,"stargazers_count":32,"open_issues_count":0,"forks_count":12,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-01T22:46:48.316Z","etag":null,"topics":["aws-lambda","insurance","micronaut","serverless"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asc-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-10-11T11:41:48.000Z","updated_at":"2024-05-08T12:08:55.000Z","dependencies_parsed_at":"2023-06-15T11:30:32.759Z","dependency_job_id":null,"html_url":"https://github.com/asc-lab/aws-lambda-billing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asc-lab%2Faws-lambda-billing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asc-lab%2Faws-lambda-billing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asc-lab%2Faws-lambda-billing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asc-lab%2Faws-lambda-billing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asc-lab","download_url":"https://codeload.github.com/asc-lab/aws-lambda-billing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250232161,"owners_count":21396583,"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":["aws-lambda","insurance","micronaut","serverless"],"created_at":"2024-11-09T23:25:04.198Z","updated_at":"2025-04-22T11:32:01.321Z","avatar_url":"https://github.com/asc-lab.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Lambda Billing PoC\r\n\r\nThis example shows simplified billing system in serverless architecture.\r\n\r\nComprehensive guide describing exactly the architecture, applied design patterns and technologies can be found on our blog in article **[Simplified billing system with AWS Lambda. Comparision: Kotlin + Micronaut vs Kotlin + Dagger vs vanilla Kotlin](https://altkomsoftware.pl/en/blog/billing-system/)**.\r\n\r\n**We encourage you to read, because in this README there is only a substitute for all information.**\r\n\r\n\u003cp align=\"center\"\u003e\r\n    \u003cimg alt=\"Architecture\" src=\"https://raw.githubusercontent.com/asc-lab/aws-lambda-billing/master/readme-images/aws-lambda-architecture.png\" /\u003e\r\n\u003c/p\u003e\r\n\r\n1. User uploads CSV file (with name structure `CLIENTCODE_YEAR_MONTH_activeList.txt`) with Beneficiaries (the sample file is located in the `data-examples` folder) to a specific data storage - `asc-lab-serverless-input` S3 Bucket.\r\n\r\n2. The above action triggers a function (`GenerateBillingItemsFunc`) that is responsible for:\r\n\r\n    * generating billing items (using prices from an external database - `PriceList` table in `DynamoDB`) and saving them in the table `BillingItem`;\r\n    * sending message about the need to create a new invoice to `invoice-generation-request-queue`;\r\n\r\n3. When a new message appears on the `invoice-generation-request-queue`, next function is triggered (`GenerateInvoiceFunc`). This function creates domain object `Invoice` and save this object in database (`DynamoDB Invoices` table) and send message to queues: `invoice-print-request-queue` and `invoice-notification-request-queue`.\r\n\r\n4. When a new message appears on the `invoice-print-request-queue`, function `PrintInvoiceFunc` is triggered. This function uses external engine to PDF generation - `JsReport` and saves PDF file in `asc-lab-serverless-printout` S3 Bucket.\r\n\r\n5. When a new message appears on the `invoice-notification-request-queue`, function `NotifyInvoiceFunc` is triggered. This function uses two external systems - `SendGrid` to email sending and `Twilio` to SMS sending.\r\n\r\n## Preparation\r\nDeployment requires `AWS CLI` and `Terraform`\r\n\r\nBefore first deployment you need to initialize `Terraform` with  \r\n```\r\ninit.sh\r\n```\r\n\r\nAlso you need to create some external accounts and informations\r\n1. jsreportonline (https://jsreportonline.net/) - just username and password\r\n2. SendGrid (https://sendgrid.com/) - API key\r\n3. Twilio (https://www.twilio.com/) - Account SID and Auth Token\r\n\r\nAs a last step, you need to create variables file to give all the above information to Terraform.\r\nCreate file billing.tfvars in main folder\r\ninsides should looks like this:\r\n```properties\r\njsreport_url = \"https://some_user.jsreportonline.net/api/report\"\r\njsreport_username = \"some_user\"\r\njsreport_password = \"some_password\"\r\nsendgrid_api_key = \"SG.rePNAA_AAAAaAA1aAAAi6w.r5AAAUZhyaaaUo7w0030MFAauAaTWvXw-n11mpAaqe0\"\r\ntwilio_account_sid = \"ACd111feb1c11f11111111cd1dd1111c11\"\r\ntwilio_auth_token = \"1ed1a11111b1af1111b111d1111dd11d\"\r\n```\r\n\r\n\r\n## Building and Deployment\r\nTerraform should create all necessary infrastructure (S3 bucket, SQS Queues, DynamoDB Tables (with data))\r\nand deploy lambdas code.\r\n\r\n```\r\nbuildAndDeploy.sh\r\n```\r\n\r\n## Testing\r\nYou should see S3 Bucket called asc-lab-serverless-input. Put there sample file and enjoy logs in AWS CloudWatch. \r\n\r\n## Disabling\r\nSQS triggers can actively check queues for new messages. If you don't want to exceed your free tier, you can disable them using our Terraform configuration. Just run:\r\n```\r\nterraform apply -auto-approve -var-file=\"billing.tfvars\" -var \"active=false\" terraform\r\n```\r\nTo re-enable triggers run:\r\n```\r\nterraform apply -auto-approve -var-file=\"billing.tfvars\" -var \"active=true\" terraform\r\n```    \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasc-lab%2Faws-lambda-billing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasc-lab%2Faws-lambda-billing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasc-lab%2Faws-lambda-billing/lists"}