How gsthalves/customers works
Main Components
• API/Presentation Layer:
– Located under api/src/presentation with further separations for NestJS controllers (for synchronous HTTP interactions) and Lambda handlers (for serverless entry points).
– This layer is responsible for handling incoming API requests (e.g., create, update, delete, search, and get customer operations).
• Application Layer:
– Found under api/src/application, this layer encapsulates the business logic and use-cases (for customer operations).
– It also handles orchestration, error management, and validation logic.
• Domain Layer:
– Located under api/src/domain and contains entities, contracts (interfaces), enums, and domain errors.
– Represents the core business rules (e.g., customer entity details, customer status enums) and ensures the integrity of business data.
• Infrastructure Layer (Within API):
– Located under api/src/infrastructure, includes adapters, factories, and repositories for interfacing with external services like DynamoDB and OpenSearch, as well as logging.
– This layer abstracts the implementation details of external storage, search, and logging systems.
• Cloud Infrastructure:
– Represented by the “infrastructure” directory that holds Terraform configuration, makefiles, and environment definitions.
– This sets up all the necessary AWS services (such as Lambda, DynamoDB, possibly API Gateway, etc.) that the application requires to run in the cloud.
Interactions and Relationships
• Front-end communication (via API Gateway or direct HTTP calls) will hit the Presentation Layer (either NestJS controllers or Lambda handlers).
• The Presentation Layer delegates requests to the Application Layer’s use-cases.
• The Application Layer interacts with the Domain Layer (business entities, domain errors) to enforce business rules.
• For persistent storage and search queries, the Application Layer calls upon the Infrastructure Layer’s repositories through adapters for DynamoDB and OpenSearch.
• Logging and error reporting are managed via an infrastructure adapter (e.g., Winston Logger) that is also integrated within the Infrastructure Layer.
Architectural Patterns and Design Principles
• Layered (or hexagonal/clean) architecture is evident: clear separations exist between presentation, application, domain, and infrastructure.
• Dependency Inversion: Domain contracts and interfaces allow you to plug in various infrastructure implementations (e.g., DynamoDB adapter, OpenSearch adapter) without affecting the core business logic.
• Serverless design: With Lambda functions as part of the presentation layer and terraform-managed resources, the system emphasizes scalability and cloud-native deployment.
• Testability: The presence of detailed spec files (e.g., *.spec.ts) indicates an emphasis on unit testing across the various layers.
Essential Elements
• Each component (e.g., NestJS Controllers, Lambda Handlers, Customer Use-Cases, Customer Entity, DynamoDB and OpenSearch repositories, Logging adapter, Terraform-managed AWS resources).
• Labels that indicate protocol or dependency types (e.g., “HTTP API Request”, “Database Repository”, “Search Index”, “Logging”).
• Annotations that briefly note the role of each layer.