How optum/dce works
Main Components
• User Interface & CLI:
– The DCE CLI (referenced in the README and linked to https://github.com/Optum/dce-cli) is the primary entry point for users to deploy the system, add accounts, initiate leases, and log in.
• API Layer:
– The pkg/api directory holds the API controllers and routes. This layer likely acts as the HTTP interface for clients and coordinates requests to the underlying business logic.
• Core Business Logic & Services:
– The many subdirectories under pkg (such as pkg/account, pkg/lease, pkg/usage, pkg/event, etc.) suggest that there is modular business logic handling domain concepts like account management, lease creation/updating, event notifications, and budget management.
– Common, config, and error-handling modules are also present to support service logic.
• AWS Lambda Functions:
– The cmd/lambda directory contains multiple Lambda functions each dedicated to a specific feature: managing accounts, leases, credentials web pages, updating lease status, and other event-based tasks.
– Each Lambda function (and its corresponding test files) represents a distinct microservice triggered by events (API calls, scheduled processes, etc.).
• Infrastructure Provisioning (Terraform Modules):
– The modules directory contains various Terraform (.tf) configurations that provision AWS resources (IAM policies, Lambda functions, S3 buckets, DynamoDB tables, Cloudwatch dashboards, etc.). This layer represents “Infrastructure as Code” for deploying and managing the cloud resources behind DCE.
• Build & Deployment Tools:
– The cmd/codebuild directory and several scripts (like deploy.sh, build.sh, and CodeBuild configuration files) indicate that the project supports automated builds, deployments, and environment resets.
• Testing & Documentation:
– The tests and docs directories show a strong emphasis on automated (integration and acceptance) tests and comprehensive documentation of the system concepts, policies, and setup guidelines.
Relationships and Interactions
• End Users interact with DCE primarily via the DCE CLI (or potentially a web interface built into the credentials_web_page Lambda) to issue commands for leasing accounts.
• The CLI communicates with the API layer (via REST calls), which then dispatches requests to the appropriate microservices.
• Each microservice (mainly deployed as AWS Lambda functions) is responsible for discrete functionalities such as creating an account lease, updating lease status, or resetting a cloud account through CodeBuild jobs.
• The Lambda functions interact with underlying AWS services—such as DynamoDB for data persistence, IAM for permissions, SNS/SQS for notifications and asynchronous event processing, and CloudWatch for logging and events—details that are also captured in the Terraform modules.
• The infrastructure management (Terraform modules) represents how the system is provisioned and tied into AWS components like authentication (Cognito under modules/authentication), databases, and IAM components.
Important Architectural Patterns/Design Principles
• Microservices Architecture:
– Functionality is clearly divided among a number of Lambda-based microservices. There is a separation of concerns (accounts, leases, usage, notifications, etc.) which allows for independent scaling and development.
• Infrastructure as Code:
– Terraform modules encapsulate AWS resource definitions. This ensures that the entire cloud environment can be deployed, managed, and reset in an automated, repeatable fashion.
• API Gateway & Event-Driven Design:
– Although not explicitly mentioned in every file, the design implies that API Gateway (or similar API management) sits in front of the Lambda functions, and events (via SNS/SQS) are a key part of the process flow.
• Test-Driven Development:
– Extensive test directories indicate a robust testing strategy across acceptance, integration, and unit tests, ensuring reliability.
Relevant Technologies, Frameworks, and Libraries
• Programming Language: Go (with its standard testing framework and module system).
• AWS Services: Lambda, CodeBuild, DynamoDB, IAM, CloudWatch, SNS, SQS (as inferred from the file and module names).
• Terraform: Used for provisioning and managing the cloud infrastructure.
• CI/CD Tools: GitHub actions (via .github directory), Makefiles, and custom deployment scripts.
• Testing: Unit and integration tests, including mocks for AWS interfaces and business logic.